aivika-transformers-6.1.1: Transformers for the Aivika 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.Trans.Internal.Parameter

Description

Tested with: GHC 8.0.1

The module defines the Parameter monad transformer 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

newtype Parameter m 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.

Constructors

Parameter (Run m -> m a) 

Instances

Instances details
MonadTrans Parameter Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

lift :: Monad m => m a -> Parameter m a #

Monad m => MonadCompTrans Parameter m Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

liftComp :: m a -> Parameter m a Source #

Monad m => ParameterLift Parameter m Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

MonadDES m => ResultComputing Parameter m Source # 
Instance details

Defined in Simulation.Aivika.Trans.Results

Monad m => MonadFail (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

fail :: String -> Parameter m a #

MonadFix m => MonadFix (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

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

MonadIO m => MonadIO (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

liftIO :: IO a -> Parameter m a #

Applicative m => Applicative (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

pure :: a -> Parameter m a #

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

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

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

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

Functor m => Functor (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

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

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

Monad m => Monad (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

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

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

return :: a -> Parameter m a #

MonadException m => MonadCatch (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

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

(MonadException m, MonadMask m) => MonadMask (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

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

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

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

MonadException m => MonadThrow (Parameter m) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

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

(Floating a, Monad m) => Floating (Parameter m a) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

pi :: Parameter m a #

exp :: Parameter m a -> Parameter m a #

log :: Parameter m a -> Parameter m a #

sqrt :: Parameter m a -> Parameter m a #

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

logBase :: Parameter m a -> Parameter m a -> Parameter m a #

sin :: Parameter m a -> Parameter m a #

cos :: Parameter m a -> Parameter m a #

tan :: Parameter m a -> Parameter m a #

asin :: Parameter m a -> Parameter m a #

acos :: Parameter m a -> Parameter m a #

atan :: Parameter m a -> Parameter m a #

sinh :: Parameter m a -> Parameter m a #

cosh :: Parameter m a -> Parameter m a #

tanh :: Parameter m a -> Parameter m a #

asinh :: Parameter m a -> Parameter m a #

acosh :: Parameter m a -> Parameter m a #

atanh :: Parameter m a -> Parameter m a #

log1p :: Parameter m a -> Parameter m a #

expm1 :: Parameter m a -> Parameter m a #

log1pexp :: Parameter m a -> Parameter m a #

log1mexp :: Parameter m a -> Parameter m a #

(Num a, Monad m) => Num (Parameter m a) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

(+) :: Parameter m a -> Parameter m a -> Parameter m a #

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

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

negate :: Parameter m a -> Parameter m a #

abs :: Parameter m a -> Parameter m a #

signum :: Parameter m a -> Parameter m a #

fromInteger :: Integer -> Parameter m a #

(Fractional a, Monad m) => Fractional (Parameter m a) Source # 
Instance details

Defined in Simulation.Aivika.Trans.Internal.Parameter

Methods

(/) :: Parameter m a -> Parameter m a -> Parameter m a #

recip :: Parameter m a -> Parameter m a #

fromRational :: Rational -> Parameter m a #

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

Defined in Simulation.Aivika.Trans.Results

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

Defined in Simulation.Aivika.Trans.Results

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

Defined in Simulation.Aivika.Trans.Results

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

Defined in Simulation.Aivika.Trans.Results

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

Defined in Simulation.Aivika.Trans.Results

class ParameterLift t m where Source #

A type class to lift the parameters into other computations.

Methods

liftParameter :: Parameter m a -> t m a Source #

Lift the specified Parameter computation into another computation.

invokeParameter :: Run m -> Parameter m a -> m a Source #

Invoke the Parameter computation.

runParameter :: MonadDES m => Parameter m a -> Specs m -> m a Source #

Run the parameter using the specified specs.

runParameters :: MonadDES m => Parameter m a -> Specs m -> Int -> [m a] Source #

Run the given number of parameters using the specified specs, where each parameter is distinguished by its index parameterIndex.

Error Handling

catchParameter :: (MonadException m, Exception e) => Parameter m a -> (e -> Parameter m a) -> Parameter m a Source #

Exception handling within Parameter computations.

finallyParameter :: MonadException m => Parameter m a -> Parameter m b -> Parameter m a Source #

A computation with finalization part like the finally function.

throwParameter :: (MonadException m, Exception e) => e -> Parameter m a Source #

Like the standard throw function.

Predefined Parameters

simulationIndex :: Monad m => Parameter m Int Source #

Return the run index for the current simulation.

simulationCount :: Monad m => Parameter m Int Source #

Return the number of simulations currently run.

simulationSpecs :: Monad m => Parameter m (Specs m) Source #

Return the simulation specs.

simulationEventQueue :: Monad m => Parameter m (EventQueue m) Source #

Return the event queue.

starttime :: Monad m => Parameter m Double Source #

Computation that returns the start simulation time.

stoptime :: Monad m => Parameter m Double Source #

Computation that returns the final simulation time.

dt :: Monad m => Parameter m Double Source #

Computation that returns the integration time step.

generatorParameter :: Monad m => Parameter m (Generator m) Source #

Return the random number generator for the simulation run.

Memoization

memoParameter :: (MonadComp m, MonadIO m, MonadMask m) => Parameter m a -> m (Parameter m 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 :: Monad m => Array Int a -> Parameter m 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.

Orphan instances

MonadTrans Parameter Source # 
Instance details

Methods

lift :: Monad m => m a -> Parameter m a #

Monad m => MonadCompTrans Parameter m Source # 
Instance details

Methods

liftComp :: m a -> Parameter m a Source #

Monad m => MonadFail (Parameter m) Source # 
Instance details

Methods

fail :: String -> Parameter m a #

MonadFix m => MonadFix (Parameter m) Source # 
Instance details

Methods

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

MonadIO m => MonadIO (Parameter m) Source # 
Instance details

Methods

liftIO :: IO a -> Parameter m a #

Applicative m => Applicative (Parameter m) Source # 
Instance details

Methods

pure :: a -> Parameter m a #

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

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

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

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

Functor m => Functor (Parameter m) Source # 
Instance details

Methods

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

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

Monad m => Monad (Parameter m) Source # 
Instance details

Methods

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

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

return :: a -> Parameter m a #

MonadException m => MonadCatch (Parameter m) Source # 
Instance details

Methods

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

(MonadException m, MonadMask m) => MonadMask (Parameter m) Source # 
Instance details

Methods

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

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

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

MonadException m => MonadThrow (Parameter m) Source # 
Instance details

Methods

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

(Floating a, Monad m) => Floating (Parameter m a) Source # 
Instance details

Methods

pi :: Parameter m a #

exp :: Parameter m a -> Parameter m a #

log :: Parameter m a -> Parameter m a #

sqrt :: Parameter m a -> Parameter m a #

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

logBase :: Parameter m a -> Parameter m a -> Parameter m a #

sin :: Parameter m a -> Parameter m a #

cos :: Parameter m a -> Parameter m a #

tan :: Parameter m a -> Parameter m a #

asin :: Parameter m a -> Parameter m a #

acos :: Parameter m a -> Parameter m a #

atan :: Parameter m a -> Parameter m a #

sinh :: Parameter m a -> Parameter m a #

cosh :: Parameter m a -> Parameter m a #

tanh :: Parameter m a -> Parameter m a #

asinh :: Parameter m a -> Parameter m a #

acosh :: Parameter m a -> Parameter m a #

atanh :: Parameter m a -> Parameter m a #

log1p :: Parameter m a -> Parameter m a #

expm1 :: Parameter m a -> Parameter m a #

log1pexp :: Parameter m a -> Parameter m a #

log1mexp :: Parameter m a -> Parameter m a #

(Num a, Monad m) => Num (Parameter m a) Source # 
Instance details

Methods

(+) :: Parameter m a -> Parameter m a -> Parameter m a #

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

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

negate :: Parameter m a -> Parameter m a #

abs :: Parameter m a -> Parameter m a #

signum :: Parameter m a -> Parameter m a #

fromInteger :: Integer -> Parameter m a #

(Fractional a, Monad m) => Fractional (Parameter m a) Source # 
Instance details

Methods

(/) :: Parameter m a -> Parameter m a -> Parameter m a #

recip :: Parameter m a -> Parameter m a #

fromRational :: Rational -> Parameter m a #