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

CopyrightCopyright (c) 2012-2015, David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Simulation.Aivika.Experiment.Types

Description

Tested with: GHC 7.8.3

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

data Experiment Source

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

Constructors

Experiment 

Fields

experimentSpecs :: Specs

The simulation specs for the experiment.

experimentTransform :: ResultTransform

How the results must be transformed before rendering.

experimentLocalisation :: ResultLocalisation

Specifies a localisation applied when rendering the experiment.

experimentRunCount :: Int

How many simulation runs should be launched.

experimentDirectoryName :: ExperimentFilePath

The directory in which the output results should be saved.

experimentTitle :: String

The experiment title.

experimentDescription :: String

The experiment description.

experimentVerbose :: Bool

Whether the process of generating the results is verbose.

experimentNumCapabilities :: IO Int

The number of threads used for the Monte-Carlo simulation if the executable was compiled with the support of multi-threading.

defaultExperiment :: Experiment Source

The default experiment.

class ExperimentRendering r where Source

It allows rendering the simulation results in an arbitrary way.

Associated Types

data ExperimentContext r :: * Source

Defines a context used when rendering the experiment.

Methods

renderExperiment :: Experiment -> r -> [ExperimentReporter r] -> FilePath -> ExperimentWriter () Source

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

Instances

ExperimentRendering (WebPageRenderer a)

Rending a web page with results when running the simulation experiment.

ExperimentRendering (FileRenderer a)

Saving the results of simulation in files when running the experiment.

data ExperimentGenerator r Source

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

Constructors

ExperimentGenerator 

Fields

generateReporter :: Experiment -> r -> FilePath -> ExperimentWriter (ExperimentReporter r)

Generate a reporter bound up with the specified directory.

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.

Methods

outputView :: v -> ExperimentGenerator r Source

Create a generator of the reporter.

data ExperimentData Source

It describes the source simulation data used in the experiment.

Constructors

ExperimentData 

Fields

experimentResults :: Results

The simulation results used in the experiment.

experimentPredefinedSignals :: ResultPredefinedSignals

The predefined signals provided by every model.

data ExperimentReporter r Source

Defines what creates the simulation reports by the specified renderer.

Constructors

ExperimentReporter 

Fields

reporterInitialise :: ExperimentWriter ()

Initialise the reporting before the simulation runs are started.

reporterFinalise :: ExperimentWriter ()

Finalise the reporting after all simulation runs are finished.

reporterSimulate :: ExperimentData -> Event DisposableEvent

Start the simulation run in the start time and return a finalizer that will be called in the stop time after the last signal is triggered and processed.

reporterContext :: ExperimentContext r

Return a context used by the renderer.

runExperiment Source

Arguments

:: ExperimentRendering 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 () 

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

runExperimentParallel Source

Arguments

:: ExperimentRendering 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 () 

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.

runExperimentWithExecutor Source

Arguments

:: ExperimentRendering r 
=> ([IO ()] -> IO ())

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 () 

Run the simulation experiment with the specified executor.