Copyright | Copyright (c) 2012-2014, David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
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.
- data Experiment = Experiment {}
- class ExperimentRendering r a | r -> a where
- renderExperiment :: Experiment -> r -> [ExperimentReporter a] -> FilePath -> IO ()
- defaultExperiment :: Experiment
- runExperiment :: ExperimentRendering r a => Experiment -> [ExperimentGenerator r a] -> r -> Simulation Results -> IO ()
- runExperimentParallel :: ExperimentRendering r a => Experiment -> [ExperimentGenerator r a] -> r -> Simulation Results -> IO ()
- data ExperimentData = ExperimentData {}
- class ExperimentRendering r a => ExperimentView v r a | r -> a where
- outputView :: v -> ExperimentGenerator r a
- data ExperimentGenerator r a = ExperimentGenerator {
- generateReporter :: Experiment -> r -> FilePath -> IO (ExperimentReporter a)
- data ExperimentReporter a = ExperimentReporter {
- reporterInitialise :: IO ()
- reporterFinalise :: IO ()
- reporterSimulate :: ExperimentData -> Event DisposableEvent
- reporterRequest :: a
- data ExperimentFilePath
- resolveFilePath :: FilePath -> ExperimentFilePath -> IO FilePath
- expandFilePath :: ExperimentFilePath -> Map String String -> ExperimentFilePath
- mapFilePath :: (FilePath -> FilePath) -> ExperimentFilePath -> ExperimentFilePath
- class ExperimentRendering r WebPageWriter => WebPageRendering r
- data WebPageRenderer = WebPageRenderer
- data WebPageWriter = WebPageWriter {
- reporterWriteTOCHtml :: Int -> HtmlWriter ()
- reporterWriteHtml :: Int -> HtmlWriter ()
- type WebPageGenerator r = ExperimentGenerator r WebPageWriter
General Definitions
data Experiment Source
It defines the simulation experiment with the specified rendering backend and its bound data.
Experiment | |
|
class ExperimentRendering r a | r -> a where Source
It allows rendering the simulation results in an arbitrary way.
renderExperiment :: Experiment -> r -> [ExperimentReporter a] -> FilePath -> IO () Source
Render the experiment after the simulation is finished, for example,
creating the index.html
file in the specified directory.
defaultExperiment :: Experiment Source
The default experiment.
:: ExperimentRendering r a | |
=> Experiment | the simulation experiment to run |
-> [ExperimentGenerator r a] | 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.
:: ExperimentRendering r a | |
=> Experiment | the simulation experiment to run |
-> [ExperimentGenerator r a] | 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.
data ExperimentData Source
It describes the source simulation data used in the experiment.
ExperimentData | |
|
class ExperimentRendering r a => ExperimentView v r a | r -> a 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 -> ExperimentGenerator r a Source
Create a generator of the reporter.
data ExperimentGenerator r a Source
This is a generator of the reporter with the specified rendering backend.
ExperimentGenerator | |
|
data ExperimentReporter a Source
Defines what creates the simulation reports by the specified renderer.
ExperimentReporter | |
|
data ExperimentFilePath Source
Specifies the file name, unique or writable, which can be appended with extension if required.
WritableFilePath FilePath | The file which is overwritten in case if it existed before. |
UniqueFilePath FilePath | The file which is always unique, when an automatically generated suffix is added to the name in case of need. |
resolveFilePath :: FilePath -> ExperimentFilePath -> IO FilePath Source
Resolve the file path relative to the specified directory passed in the first argument and taking into account a possible requirement to have an unique file name.
expandFilePath :: ExperimentFilePath -> Map String String -> ExperimentFilePath Source
Expand the file path using the specified table of substitutions.
mapFilePath :: (FilePath -> FilePath) -> ExperimentFilePath -> ExperimentFilePath Source
Transform the file path using the specified function.
Web Page Rendering
class ExperimentRendering r WebPageWriter => WebPageRendering r Source
A subclass of renderers that know how to save the index.html
file
when rendering the simulation experiment.
data WebPageRenderer Source
It defines the web page renderer for simulation Experiment
.
data WebPageWriter Source
It replies to the requests made by the web page renderer.
WebPageWriter | |
|
type WebPageGenerator r = ExperimentGenerator r WebPageWriter Source
A convenient type synonym for describing the web page generators.