aivika-1.3: A multi-paradigm simulation library

Stabilityexperimental
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Safe HaskellSafe-Inferred

Simulation.Aivika.Parameter

Contents

Description

Tested with: GHC 7.6.3

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

Parameter

data Parameter a Source

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.

class ParameterLift m whereSource

A type class to lift the parameters to other computations.

Methods

liftParameter :: Parameter a -> m aSource

Lift the specified Parameter computation to another computation.

runParameter :: Parameter a -> Specs -> IO aSource

Run the parameter using the specified specs.

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 :: Parameter a -> (IOException -> Parameter a) -> Parameter aSource

Exception handling within Parameter computations.

finallyParameter :: Parameter a -> Parameter b -> Parameter aSource

A computation with finalization part like the finally function.

throwParameter :: IOException -> Parameter aSource

Like the standard throw function.

Predefined Parameters

simulationIndex :: Parameter IntSource

Return the run index for the current simulation.

simulationCount :: Parameter IntSource

Return the number of simulations currently run.

simulationSpecs :: Parameter SpecsSource

Return the simulation specs.

generatorParameter :: Parameter GeneratorSource

Return the random number generator for the simulation run.

starttime :: Parameter DoubleSource

Computation that returns the start simulation time.

stoptime :: Parameter DoubleSource

Computation that returns the final simulation time.

dt :: Parameter DoubleSource

Computation that returns the integration time step.

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 aSource

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.