aivika-6.1.1: A multi-method simulation library
CopyrightCopyright (c) 2009-2017 David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Simulation.Aivika.Parameter

Description

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

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.

Instances

Instances details
ParameterLift Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

ResultComputing Parameter Source # 
Instance details

Defined in Simulation.Aivika.Results

MonadFail Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

fail :: String -> Parameter a #

MonadFix Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

mfix :: (a -> Parameter a) -> Parameter a #

MonadIO Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

liftIO :: IO a -> Parameter a #

Applicative Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

pure :: a -> Parameter a #

(<*>) :: Parameter (a -> b) -> Parameter a -> Parameter b #

liftA2 :: (a -> b -> c) -> Parameter a -> Parameter b -> Parameter c #

(*>) :: Parameter a -> Parameter b -> Parameter b #

(<*) :: Parameter a -> Parameter b -> Parameter a #

Functor Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

fmap :: (a -> b) -> Parameter a -> Parameter b #

(<$) :: a -> Parameter b -> Parameter a #

Monad Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

(>>=) :: Parameter a -> (a -> Parameter b) -> Parameter b #

(>>) :: Parameter a -> Parameter b -> Parameter b #

return :: a -> Parameter a #

MonadCatch Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

catch :: (HasCallStack, Exception e) => Parameter a -> (e -> Parameter a) -> Parameter a #

MonadMask Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

mask :: HasCallStack => ((forall a. Parameter a -> Parameter a) -> Parameter b) -> Parameter b #

uninterruptibleMask :: HasCallStack => ((forall a. Parameter a -> Parameter a) -> Parameter b) -> Parameter b #

generalBracket :: HasCallStack => Parameter a -> (a -> ExitCase b -> Parameter c) -> (a -> Parameter b) -> Parameter (b, c) #

MonadThrow Parameter Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

throwM :: (HasCallStack, Exception e) => e -> Parameter a #

(ResultItemable (ResultValue a), ResultItemable (ResultValue (SamplingStats a))) => ResultProvider (Parameter (SamplingCounter a)) Source # 
Instance details

Defined in Simulation.Aivika.Results

(ResultItemable (ResultValue a), ResultItemable (ResultValue (TimingStats a))) => ResultProvider (Parameter (TimingCounter a)) Source # 
Instance details

Defined in Simulation.Aivika.Results

(Ix i, Show i, ResultItemable (ResultValue [e])) => ResultProvider (Parameter (Array i e)) Source # 
Instance details

Defined in Simulation.Aivika.Results

ResultItemable (ResultValue [e]) => ResultProvider (Parameter (Vector e)) Source # 
Instance details

Defined in Simulation.Aivika.Results

ResultItemable (ResultValue a) => ResultProvider (Parameter a) Source # 
Instance details

Defined in Simulation.Aivika.Results

Floating a => Floating (Parameter a) Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Num a => Num (Parameter a) Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Fractional a => Fractional (Parameter a) Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Show (Parameter a) Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Eq (Parameter a) Source # 
Instance details

Defined in Simulation.Aivika.Internal.Parameter

Methods

(==) :: Parameter a -> Parameter a -> Bool #

(/=) :: Parameter a -> Parameter a -> Bool #

class ParameterLift m where Source #

A type class to lift the parameters to other computations.

Methods

liftParameter :: Parameter a -> m a Source #

Lift the specified Parameter computation to another computation.

runParameter :: Parameter a -> Specs -> IO a Source #

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 :: 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.

throwParameter :: Exception e => e -> Parameter a Source #

Like the standard throw 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.

starttime :: Parameter Double Source #

Computation that returns the start simulation time.

stoptime :: Parameter Double Source #

Computation that returns the final simulation time.

dt :: Parameter Double Source #

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 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.