Copyright | Copyright (c) 2009-2014, 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 7.8.3
The module defines the ParameterT
monad transformer that allows representing the model
parameters. For example, they can be used when running the Monte-Carlo simulation.
In general, this monad tranformer is very useful for representing a computation which is external relative to the model itself.
- data Parameter m a
- class ParameterLift t where
- liftParameter :: MonadComp m => Parameter m a -> t m a
- runParameter :: MonadComp m => Parameter m a -> Specs m -> m a
- runParameters :: MonadComp m => Parameter m a -> Specs m -> Int -> [m a]
- catchParameter :: (MonadComp m, Exception e) => Parameter m a -> (e -> Parameter m a) -> Parameter m a
- finallyParameter :: MonadComp m => Parameter m a -> Parameter m b -> Parameter m a
- throwParameter :: (MonadComp m, Exception e) => e -> Parameter m a
- simulationIndex :: Monad m => Parameter m Int
- simulationCount :: Monad m => Parameter m Int
- simulationSpecs :: Monad m => Parameter m (Specs m)
- simulationSession :: Monad m => Parameter m (Session m)
- generatorParameter :: Monad m => Parameter m (Generator m)
- starttime :: Monad m => Parameter m Double
- stoptime :: Monad m => Parameter m Double
- dt :: Monad m => Parameter m Double
- memoParameter :: Parameter IO a -> IO (Parameter IO a)
- tableParameter :: Monad m => Array Int a -> Parameter m 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.
MonadTrans Parameter | |
MonadCompTrans Parameter | |
ParameterLift Parameter | |
MonadComp m => ResultComputing Parameter m | |
Monad m => Monad (Parameter m) | |
Functor m => Functor (Parameter m) | |
MonadFix m => MonadFix (Parameter m) | |
Applicative m => Applicative (Parameter m) | |
MonadIO m => MonadIO (Parameter m) | |
(Floating a, Monad m) => Floating (Parameter m a) | |
(Fractional a, Monad m) => Fractional (Parameter m a) | |
(Num a, Monad m) => Num (Parameter m a) |
class ParameterLift t where Source
A type class to lift the parameters into other computations.
liftParameter :: MonadComp m => Parameter m a -> t m a Source
Lift the specified Parameter
computation into another computation.
runParameter :: MonadComp m => Parameter m a -> Specs m -> m a Source
Run the parameter using the specified specs.
runParameters :: MonadComp 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 :: (MonadComp m, Exception e) => Parameter m a -> (e -> Parameter m a) -> Parameter m a Source
Exception handling within Parameter
computations.
finallyParameter :: MonadComp m => Parameter m a -> Parameter m b -> Parameter m a Source
A computation with finalization part like the finally
function.
throwParameter :: (MonadComp 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.
simulationSession :: Monad m => Parameter m (Session m) Source
Return the simulation session.
generatorParameter :: Monad m => Parameter m (Generator m) Source
Return the random number generator for the simulation run.
starttime :: Monad m => Parameter m Double Source
Computation that returns the start simulation time.
Memoization
memoParameter :: Parameter IO a -> IO (Parameter IO 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.