Copyright | Copyright (c) 2012-2017 David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- data Experiment m = Experiment {}
- defaultExperiment :: Experiment m
- class ExperimentMonadProviding r (m :: * -> *) where
- type ExperimentMonad r m :: * -> *
- type ExperimentMonadTry r m a = ExperimentMonad r m (Either SomeException a)
- class ExperimentMonadProviding r m => ExperimentRendering r m where
- data ExperimentContext r m :: *
- type ExperimentEnvironment r m :: *
- prepareExperiment :: Experiment m -> r -> ExperimentMonad r m (ExperimentEnvironment r m)
- renderExperiment :: Experiment m -> r -> [ExperimentReporter r m] -> ExperimentEnvironment r m -> ExperimentMonad r m ()
- onExperimentCompleted :: Experiment m -> r -> ExperimentEnvironment r m -> ExperimentMonad r m ()
- onExperimentFailed :: Exception e => Experiment m -> r -> ExperimentEnvironment r m -> e -> ExperimentMonad r m ()
- data ExperimentGenerator r m = ExperimentGenerator {
- generateReporter :: Experiment m -> r -> ExperimentEnvironment r m -> ExperimentMonad r m (ExperimentReporter r m)
- class ExperimentRendering r m => ExperimentView v r m where
- outputView :: v m -> ExperimentGenerator r m
- data ExperimentData m = ExperimentData {}
- data ExperimentReporter r m = ExperimentReporter {
- reporterInitialise :: ExperimentMonad r m ()
- reporterFinalise :: ExperimentMonad r m ()
- reporterSimulate :: ExperimentData m -> Composite m ()
- reporterContext :: ExperimentContext r m
- runExperiment_ :: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) => (m () -> ExperimentMonad r m a) -> Experiment m -> [ExperimentGenerator r m] -> r -> Simulation m (Results m) -> ExperimentMonadTry r m ()
- runExperiment :: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) => (m () -> ExperimentMonad r m a) -> Experiment m -> [ExperimentGenerator r m] -> r -> Simulation m (Results m) -> ExperimentMonadTry r m [a]
- runExperimentWithExecutor :: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) => ([m ()] -> ExperimentMonad r m a) -> Experiment m -> [ExperimentGenerator r m] -> r -> Simulation m (Results m) -> ExperimentMonadTry r m a
- runExperimentByIndex :: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) => (m () -> ExperimentMonad r m a) -> Experiment m -> [ExperimentGenerator r m] -> r -> Simulation m (Results m) -> Int -> ExperimentMonadTry r m a
- runExperimentByIndex_ :: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) => (m () -> ExperimentMonad r m a) -> Experiment m -> [ExperimentGenerator r m] -> r -> Simulation m (Results m) -> Int -> ExperimentMonadTry r m ()
- runExperimentContByIndex :: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) => (m () -> ExperimentMonad r m (a, ExperimentMonad r m b)) -> Experiment m -> [ExperimentGenerator r m] -> r -> Simulation m (Results m) -> Int -> ExperimentMonadTry r m (a, ExperimentMonadTry r m b)
- runExperimentContByIndex_ :: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) => (m () -> ExperimentMonad r m (a, ExperimentMonad r m b)) -> Experiment m -> [ExperimentGenerator r m] -> r -> Simulation m (Results m) -> Int -> ExperimentMonadTry r m (a, ExperimentMonadTry r m ())
Documentation
data Experiment m Source #
It defines the simulation experiment with the specified rendering backend and its bound data.
Experiment | |
|
defaultExperiment :: Experiment m Source #
The default experiment.
class ExperimentMonadProviding r (m :: * -> *) Source #
Allows specifying the experiment monad.
type ExperimentMonad r m :: * -> * Source #
Defines the experiment monad type.
type ExperimentMonadTry r m a = ExperimentMonad r m (Either SomeException a) Source #
Defines the experiment computation that tries to perform the calculation.
class ExperimentMonadProviding r m => ExperimentRendering r m where Source #
It allows rendering the simulation results in an arbitrary way.
data ExperimentContext r m :: * Source #
Defines a context used when rendering the experiment.
type ExperimentEnvironment r m :: * Source #
Defines the experiment environment.
prepareExperiment :: Experiment m -> r -> ExperimentMonad r m (ExperimentEnvironment r m) Source #
Prepare before rendering the experiment.
renderExperiment :: Experiment m -> r -> [ExperimentReporter r m] -> ExperimentEnvironment r m -> ExperimentMonad r m () Source #
Render the experiment after the simulation is finished, for example,
creating the index.html
file in the specified directory.
onExperimentCompleted :: Experiment m -> r -> ExperimentEnvironment r m -> ExperimentMonad r m () Source #
It is called when the experiment has been completed.
onExperimentFailed :: Exception e => Experiment m -> r -> ExperimentEnvironment r m -> e -> ExperimentMonad r m () Source #
It is called when the experiment rendering has failed.
data ExperimentGenerator r m Source #
This is a generator of the reporter with the specified rendering backend.
ExperimentGenerator | |
|
class ExperimentRendering r m => ExperimentView v r m 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.
outputView :: v m -> ExperimentGenerator r m Source #
Create a generator of the reporter.
data ExperimentData m Source #
It describes the source simulation data used in the experiment.
ExperimentData | |
|
data ExperimentReporter r m Source #
Defines what creates the simulation reports by the specified renderer.
ExperimentReporter | |
|
:: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) | |
=> (m () -> ExperimentMonad r m a) | the function that actually starts the simulation run |
-> Experiment m | the simulation experiment to run |
-> [ExperimentGenerator r m] | generators used for rendering |
-> r | the rendering backend |
-> Simulation m (Results m) | the simulation results received from the model |
-> ExperimentMonadTry r m () |
Run the simulation experiment sequentially.
:: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) | |
=> (m () -> ExperimentMonad r m a) | the function that actually starts the simulation run |
-> Experiment m | the simulation experiment to run |
-> [ExperimentGenerator r m] | generators used for rendering |
-> r | the rendering backend |
-> Simulation m (Results m) | the simulation results received from the model |
-> ExperimentMonadTry r m [a] |
Run the simulation experiment sequentially.
runExperimentWithExecutor Source #
:: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) | |
=> ([m ()] -> ExperimentMonad r m a) | an executor that allows parallelizing the simulation if required |
-> Experiment m | the simulation experiment to run |
-> [ExperimentGenerator r m] | generators used for rendering |
-> r | the rendering backend |
-> Simulation m (Results m) | the simulation results received from the model |
-> ExperimentMonadTry r m a |
Run the simulation experiment with the specified executor.
:: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) | |
=> (m () -> ExperimentMonad r m a) | the function that actually starts the simulation run |
-> Experiment m | the simulation experiment to run |
-> [ExperimentGenerator r m] | generators used for rendering |
-> r | the rendering backend |
-> Simulation m (Results m) | the simulation results received from the model |
-> Int | the index of the current run (started from 1) |
-> ExperimentMonadTry r m a |
Run the simulation experiment by the specified run index in series.
runExperimentByIndex_ Source #
:: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) | |
=> (m () -> ExperimentMonad r m a) | the function that actually starts the simulation run |
-> Experiment m | the simulation experiment to run |
-> [ExperimentGenerator r m] | generators used for rendering |
-> r | the rendering backend |
-> Simulation m (Results m) | the simulation results received from the model |
-> Int | the index of the current run (started from 1) |
-> ExperimentMonadTry r m () |
Run the simulation experiment by the specified run index in series.
runExperimentContByIndex Source #
:: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) | |
=> (m () -> ExperimentMonad r m (a, ExperimentMonad r m b)) | the function that actually starts the simulation run and returns the corresponding continuation |
-> Experiment m | the simulation experiment to run |
-> [ExperimentGenerator r m] | generators used for rendering |
-> r | the rendering backend |
-> Simulation m (Results m) | the simulation results received from the model |
-> Int | the index of the current run (started from 1) |
-> ExperimentMonadTry r m (a, ExperimentMonadTry r m b) |
Run the simulation experiment by the specified run index in series returning the continuation of the actual computation.
runExperimentContByIndex_ Source #
:: (MonadDES m, ExperimentRendering r m, Monad (ExperimentMonad r m), MonadException (ExperimentMonad r m)) | |
=> (m () -> ExperimentMonad r m (a, ExperimentMonad r m b)) | the function that actually starts the simulation run and returns the corresponding continuation |
-> Experiment m | the simulation experiment to run |
-> [ExperimentGenerator r m] | generators used for rendering |
-> r | the rendering backend |
-> Simulation m (Results m) | the simulation results received from the model |
-> Int | the index of the current run (started from 1) |
-> ExperimentMonadTry r m (a, ExperimentMonadTry r m ()) |
Run the simulation experiment by the specified run index in series returning the continuation of the actual computation.