aivika-experiment-5.3: Simulation experiments for the Aivika library

Simulation.Aivika.Experiment.Types

Description

Tested with: GHC 8.0.1

The module defines the simulation experiments. They automate the process of generating and analyzing the results. Moreover, this module is open to extensions, allowing you to define your own output views for the simulation results, for example, such views that would allow saving the results in PDF or as charts. To decrease the number of dependencies, such possible extenstions are not included in this package, although simple views are provided.

Synopsis

# Documentation

It defines the simulation experiment with the specified rendering backend and its bound data.

Constructors

 Experiment FieldsexperimentSpecs :: SpecsThe simulation specs for the experiment.experimentTransform :: ResultTransformHow the results must be transformed before rendering.experimentLocalisation :: ResultLocalisationSpecifies a localisation applied when rendering the experiment.experimentRunCount :: IntHow many simulation runs should be launched.experimentTitle :: StringThe experiment title.experimentDescription :: StringThe experiment description.experimentVerbose :: BoolWhether the process of generating the results is verbose.experimentNumCapabilities :: IO IntThe number of threads used for the Monte-Carlo simulation if the executable was compiled with the support of multi-threading.

The default experiment.

class ExperimentRendering r where Source #

It allows rendering the simulation results in an arbitrary way.

Minimal complete definition

Associated Types

data ExperimentContext r :: * Source #

Defines a context used when rendering the experiment.

type ExperimentEnvironment r :: * Source #

Defines the experiment environment.

type ExperimentMonad r :: * -> * Source #

Methods

liftExperiment :: r -> ExperimentMonad r a -> IO a Source #

Lift the experiment computation.

Prepare before rendering the experiment.

renderExperiment :: Experiment -> r -> [ExperimentReporter r] -> ExperimentEnvironment r -> ExperimentMonad r () Source #

Render the experiment after the simulation is finished, for example, creating the index.html file in the specified directory.

It is called when the experiment has been completed.

onExperimentFailed :: Exception e => Experiment -> r -> ExperimentEnvironment r -> e -> ExperimentMonad r () Source #

It is called when the experiment rendering has failed.

Instances

 Source # Saving the results of simulation in files when running the experiment. Associated Typesdata ExperimentContext (FileRenderer a) :: * Source #type ExperimentMonad (FileRenderer a) :: * -> * Source # MethodsonExperimentFailed :: Exception e => Experiment -> FileRenderer a -> ExperimentEnvironment (FileRenderer a) -> e -> ExperimentMonad (FileRenderer a) () Source # Source # Rendering a web page with results when running the simulation experiment. Associated Typesdata ExperimentContext (WebPageRenderer a) :: * Source #type ExperimentMonad (WebPageRenderer a) :: * -> * Source # Methods

This is a generator of the reporter with the specified rendering backend.

Constructors

 ExperimentGenerator FieldsgenerateReporter :: Experiment -> r -> ExperimentEnvironment r -> ExperimentMonad r (ExperimentReporter r)Generate a reporter.

class ExperimentRendering r => ExperimentView v r where Source #

Defines a view in which the simulation results should be saved. You should extend this type class to define your own views such as the PDF document.

Minimal complete definition

outputView

Methods

Create a generator of the reporter.

Instances

 Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods

It describes the source simulation data used in the experiment.

Constructors

 ExperimentData FieldsexperimentResults :: ResultsThe simulation results used in the experiment.experimentPredefinedSignals :: ResultPredefinedSignalsThe predefined signals provided by every model.

Defines what creates the simulation reports by the specified renderer.

Constructors

 ExperimentReporter FieldsreporterInitialise :: ExperimentMonad r ()Initialise the reporting before the simulation runs are started.reporterFinalise :: ExperimentMonad r ()Finalise the reporting after all simulation runs are finished.reporterSimulate :: ExperimentData -> Composite ()Start the simulation run in the start time.reporterContext :: ExperimentContext rReturn a context used by the renderer.

Arguments

 :: (ExperimentRendering r, Monad (ExperimentMonad r), MonadIO (ExperimentMonad r), MonadException (ExperimentMonad r)) => Experiment the simulation experiment to run -> [ExperimentGenerator r] generators used for rendering -> r the rendering backend -> Simulation Results the simulation results received from the model -> IO (Either SomeException ())

Run the simulation experiment sequentially. For example, it can be a Monte-Carlo simulation dependentent on the external Parameter values.

Arguments

 :: (ExperimentRendering r, Monad (ExperimentMonad r), MonadIO (ExperimentMonad r), MonadException (ExperimentMonad r)) => Experiment the simulation experiment to run -> [ExperimentGenerator r] generators used for rendering -> r the rendering backend -> Simulation Results the simulation results received from the model -> IO (Either SomeException ())

Run the simulation experiment in parallel.

Make sure that you compile with -threaded and supply +RTS -N2 -RTS to the generated Haskell executable on dual core processor, or you won't get any parallelism. Generally, the mentioned N parameter should correspond to the number of cores for your processor.

In case of need you might want to specify the number of threads directly with help of experimentNumCapabilities, although the real number of parallel threads can depend on many factors.

Arguments

 :: (ExperimentRendering r, Monad (ExperimentMonad r), MonadIO (ExperimentMonad r), MonadException (ExperimentMonad r)) => ([IO ()] -> IO a) an executor that allows parallelizing the simulation if required -> Experiment the simulation experiment to run -> [ExperimentGenerator r] generators used for rendering -> r the rendering backend -> Simulation Results the simulation results received from the model -> IO (Either SomeException a)

Run the simulation experiment with the specified executor.