aivika-transformers 5.1 → 5.2
raw patch · 6 files changed
+28/−15 lines, 6 filesdep +mwc-randomdep ~aivikaPVP ok
version bump matches the API change (PVP)
Dependencies added: mwc-random
Dependency ranges changed: aivika
API changes (from Hackage documentation)
- Simulation.Aivika.Trans.Generator: SimpleGeneratorWithSeed :: Int -> GeneratorType m
+ Simulation.Aivika.Trans.Generator: SimpleGeneratorWithSeed :: Word32 -> GeneratorType m
Files
- CHANGELOG.md +5/−0
- Simulation/Aivika/IO/Generator.hs +6/−4
- Simulation/Aivika/Trans/Generator.hs +2/−1
- Simulation/Aivika/Trans/Generator/Primitive.hs +9/−3
- Simulation/Aivika/Trans/Parameter/Random.hs +0/−2
- aivika-transformers.cabal +6/−5
CHANGELOG.md view
@@ -1,4 +1,9 @@ +Version 5.2+-----++* Using the mwc-random package for generating random numbers by default.+ Version 5.1 -----
Simulation/Aivika/IO/Generator.hs view
@@ -14,12 +14,14 @@ -- module Simulation.Aivika.IO.Generator () where +import System.Random+import qualified System.Random.MWC as MWC+ import Control.Monad import Control.Monad.Trans -import System.Random- import Data.IORef+import Data.Vector import Simulation.Aivika.Trans.Generator import Simulation.Aivika.Trans.Generator.Primitive@@ -84,9 +86,9 @@ newGenerator tp = case tp of SimpleGenerator ->- liftIO newStdGen >>= newRandomGenerator+ MWC.uniform <$> MWC.withSystemRandom (return :: MWC.GenIO -> IO MWC.GenIO) >>= newRandomGenerator01 SimpleGeneratorWithSeed x ->- newRandomGenerator $ mkStdGen x+ MWC.uniform <$> MWC.initialize (singleton x) >>= newRandomGenerator01 CustomGenerator g -> g CustomGenerator01 g ->
Simulation/Aivika/Trans/Generator.hs view
@@ -17,6 +17,7 @@ DiscretePDF(..)) where import System.Random+import Data.Word import Simulation.Aivika.Generator (DiscretePDF) @@ -100,7 +101,7 @@ -- | Defines a type of the random number generator. data GeneratorType m = SimpleGenerator -- ^ The simple random number generator.- | SimpleGeneratorWithSeed Int+ | SimpleGeneratorWithSeed Word32 -- ^ The simple random number generator with the specified seed. | CustomGenerator (m (Generator m)) -- ^ The custom random number generator.
Simulation/Aivika/Trans/Generator/Primitive.hs view
@@ -42,9 +42,15 @@ {-# INLINE generateUniformInt01 #-} generateUniformInt01 g min max = do x <- g- let min' = fromIntegral min- max' = fromIntegral max- return $ round (min' + x * (max' - min'))+ let min' = fromIntegral min - 0.5+ max' = fromIntegral max + 0.5+ z = round (min' + x * (max' - min'))+ z' = if z < min+ then min+ else if z > max+ then max+ else z+ return z' -- | Generate the triangular random number by the specified minimum, median and maximum. generateTriangular01 :: Monad m
Simulation/Aivika/Trans/Parameter/Random.hs view
@@ -36,8 +36,6 @@ randomTrue, randomFalse) where -import System.Random- import Control.Monad.Trans import Simulation.Aivika.Trans.Generator
aivika-transformers.cabal view
@@ -1,18 +1,18 @@ name: aivika-transformers-version: 5.1+version: 5.2 synopsis: Transformers for the Aivika simulation library description: This package is a generalization of the aivika [1] simulation library with extensive use of monad transformers and type families. It can be applied for nested simulation [2] and parallel distributed simulation [3]. .- Unlike sequential simulation, the distribution simulation is more difficult for implementing+ Unlike sequential simulation, the distributed simulation is more difficult for implementing the simulation experiments by the Monte-Carlo method. Therefore, there are additional packages- that allow saving the results of distribution simulation in SQL databases+ that allow saving the results of distributed simulation in SQL databases and only then the simulation reports are generated. These reports are HTML pages with charts, histograms, links to CSV tables, statistics summary and so on. .- This method can be used not only for the parallel distribution simulation, but also for other + This method can be used not only for the parallel distributed simulation, but also for other simulation models created with help of the generalized version of the Aivika simulation library. Please consult the AivikaSoft [4] website for more details. .@@ -170,8 +170,9 @@ array >= 0.3.0.0, containers >= 0.4.0.0, random >= 1.0.0.3,+ mwc-random >= 0.13.0.0, vector >= 0.10.0.1,- aivika >= 5.1+ aivika >= 5.2 other-extensions: FlexibleContexts, FlexibleInstances,