Copyright | Copyright (c) 2009-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 Parameter
monad that allows representing the model
parameters. For example, they can be used when running the Monte-Carlo simulation.
In general, this monad is very useful for representing a computation which is external relative to the model itself.
Synopsis
- data Parameter a
- class ParameterLift m where
- liftParameter :: Parameter a -> m a
- runParameter :: Parameter a -> Specs -> IO a
- runParameters :: Parameter a -> Specs -> Int -> [IO a]
- catchParameter :: Exception e => Parameter a -> (e -> Parameter a) -> Parameter a
- finallyParameter :: Parameter a -> Parameter b -> Parameter a
- throwParameter :: Exception e => e -> Parameter a
- simulationIndex :: Parameter Int
- simulationCount :: Parameter Int
- simulationSpecs :: Parameter Specs
- generatorParameter :: Parameter Generator
- starttime :: Parameter Double
- stoptime :: Parameter Double
- dt :: Parameter Double
- memoParameter :: Parameter a -> IO (Parameter a)
- tableParameter :: Array Int a -> Parameter a
Parameter
The Parameter
monad that allows specifying the model parameters.
For example, they can be used when running the Monte-Carlo simulation.
In general, this monad is very useful for representing a computation which is external relative to the model itself.
Instances
class ParameterLift m where Source #
A type class to lift the parameters to other computations.
liftParameter :: Parameter a -> m a Source #
Lift the specified Parameter
computation to another computation.
Instances
ParameterLift Composite Source # | |
Defined in Simulation.Aivika.Composite liftParameter :: Parameter a -> Composite a Source # | |
ParameterLift Cont Source # | |
Defined in Simulation.Aivika.Internal.Cont liftParameter :: Parameter a -> Cont a Source # | |
ParameterLift Dynamics Source # | |
Defined in Simulation.Aivika.Internal.Dynamics liftParameter :: Parameter a -> Dynamics a Source # | |
ParameterLift Event Source # | |
Defined in Simulation.Aivika.Internal.Event liftParameter :: Parameter a -> Event a Source # | |
ParameterLift Parameter Source # | |
Defined in Simulation.Aivika.Internal.Parameter liftParameter :: Parameter a -> Parameter a Source # | |
ParameterLift Process Source # | |
Defined in Simulation.Aivika.Internal.Process liftParameter :: Parameter a -> Process a Source # | |
ParameterLift Simulation Source # | |
Defined in Simulation.Aivika.Internal.Simulation liftParameter :: Parameter a -> Simulation a Source # |
runParameters :: Parameter a -> Specs -> Int -> [IO a] Source #
Run the given number of parameters using the specified specs,
where each parameter is distinguished by its index parameterIndex
.
Error Handling
catchParameter :: Exception e => Parameter a -> (e -> Parameter a) -> Parameter a Source #
Exception handling within Parameter
computations.
finallyParameter :: Parameter a -> Parameter b -> Parameter a Source #
A computation with finalization part like the finally
function.
Predefined Parameters
simulationIndex :: Parameter Int Source #
Return the run index for the current simulation.
simulationCount :: Parameter Int Source #
Return the number of simulations currently run.
simulationSpecs :: Parameter Specs Source #
Return the simulation specs.
generatorParameter :: Parameter Generator Source #
Return the random number generator for the simulation run.
Memoization
memoParameter :: Parameter a -> IO (Parameter a) Source #
Memoize the Parameter
computation, always returning the same value
within a simulation run. However, the value will be recalculated for other
simulation runs. Also it is thread-safe when different simulation runs
are executed in parallel on physically different operating system threads.
Utilities
tableParameter :: Array Int a -> Parameter a Source #
Return a parameter which value is taken consequently from the specified table based on the run index of the current simulation starting from zero. After all values from the table are used, it takes again the first value of the table, then the second one and so on.