-- |
-- Module     : Simulation.Aivika.Trans.Activity.Random
-- Copyright  : Copyright (c) 2009-2017, David Sorokin <david.sorokin@gmail.com>
-- License    : BSD3
-- Maintainer : David Sorokin <david.sorokin@gmail.com>
-- Stability  : experimental
-- Tested with: GHC 8.0.1
--
-- This module defines some useful predefined activities that
-- hold the current process for the corresponding random time
-- interval, when processing every input element.
--

module Simulation.Aivika.Trans.Activity.Random
       (newRandomUniformActivity,
        newRandomUniformIntActivity,
        newRandomTriangularActivity,
        newRandomNormalActivity,
        newRandomLogNormalActivity,
        newRandomExponentialActivity,
        newRandomErlangActivity,
        newRandomPoissonActivity,
        newRandomBinomialActivity,
        newRandomGammaActivity,
        newRandomBetaActivity,
        newRandomWeibullActivity,
        newRandomDiscreteActivity,
        newPreemptibleRandomUniformActivity,
        newPreemptibleRandomUniformIntActivity,
        newPreemptibleRandomTriangularActivity,
        newPreemptibleRandomNormalActivity,
        newPreemptibleRandomLogNormalActivity,
        newPreemptibleRandomExponentialActivity,
        newPreemptibleRandomErlangActivity,
        newPreemptibleRandomPoissonActivity,
        newPreemptibleRandomBinomialActivity,
        newPreemptibleRandomGammaActivity,
        newPreemptibleRandomBetaActivity,
        newPreemptibleRandomWeibullActivity,
        newPreemptibleRandomDiscreteActivity) where

import Simulation.Aivika.Trans.DES
import Simulation.Aivika.Trans.Generator
import Simulation.Aivika.Trans.Simulation
import Simulation.Aivika.Trans.Process
import Simulation.Aivika.Trans.Process.Random
import Simulation.Aivika.Trans.Activity

-- | Create a new activity that holds the process for a random time interval
-- distributed uniformly, when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomUniformActivity :: MonadDES m
                            => Double
                            -- ^ the minimum time interval
                            -> Double
                            -- ^ the maximum time interval
                            -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomUniformActivity #-}
newRandomUniformActivity :: Double -> Double -> Simulation m (Activity m () a a)
newRandomUniformActivity =
  Bool -> Double -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomUniformActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- distributed uniformly, when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomUniformIntActivity :: MonadDES m
                               => Int
                               -- ^ the minimum time interval
                               -> Int
                               -- ^ the maximum time interval
                               -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomUniformIntActivity #-}
newRandomUniformIntActivity :: Int -> Int -> Simulation m (Activity m () a a)
newRandomUniformIntActivity =
  Bool -> Int -> Int -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Int -> Int -> Simulation m (Activity m () a a)
newPreemptibleRandomUniformIntActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- having the triangular distribution, when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomTriangularActivity :: MonadDES m
                               => Double
                               -- ^ the minimum time interval
                               -> Double
                               -- ^ the median of the time interval
                               -> Double
                               -- ^ the maximum time interval
                               -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomTriangularActivity #-}
newRandomTriangularActivity :: Double -> Double -> Double -> Simulation m (Activity m () a a)
newRandomTriangularActivity =
  Bool
-> Double -> Double -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool
-> Double -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomTriangularActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- distributed normally, when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomNormalActivity :: MonadDES m
                           => Double
                           -- ^ the mean time interval
                           -> Double
                           -- ^ the time interval deviation
                           -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomNormalActivity #-}
newRandomNormalActivity :: Double -> Double -> Simulation m (Activity m () a a)
newRandomNormalActivity =
  Bool -> Double -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomNormalActivity Bool
False
         
-- | Create a new activity that holds the process for a random time interval
-- having the lognormal distribution, when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomLogNormalActivity :: MonadDES m
                              => Double
                              -- ^ the mean of a normal distribution which
                              -- this distribution is derived from
                              -> Double
                              -- ^ the deviation of a normal distribution which
                              -- this distribution is derived from
                              -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomLogNormalActivity #-}
newRandomLogNormalActivity :: Double -> Double -> Simulation m (Activity m () a a)
newRandomLogNormalActivity =
  Bool -> Double -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomLogNormalActivity Bool
False
         
-- | Create a new activity that holds the process for a random time interval
-- distributed exponentially with the specified mean (the reciprocal of the rate),
-- when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomExponentialActivity :: MonadDES m
                                => Double
                                -- ^ the mean time interval (the reciprocal of the rate)
                                -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomExponentialActivity #-}
newRandomExponentialActivity :: Double -> Simulation m (Activity m () a a)
newRandomExponentialActivity =
  Bool -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomExponentialActivity Bool
False
         
-- | Create a new activity that holds the process for a random time interval
-- having the Erlang distribution with the specified scale (the reciprocal of the rate)
-- and shape parameters, when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomErlangActivity :: MonadDES m
                           => Double
                           -- ^ the scale (the reciprocal of the rate)
                           -> Int
                           -- ^ the shape
                           -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomErlangActivity #-}
newRandomErlangActivity :: Double -> Int -> Simulation m (Activity m () a a)
newRandomErlangActivity =
  Bool -> Double -> Int -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Int -> Simulation m (Activity m () a a)
newPreemptibleRandomErlangActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- having the Poisson distribution with the specified mean, when processing
-- every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomPoissonActivity :: MonadDES m
                            => Double
                            -- ^ the mean time interval
                            -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomPoissonActivity #-}
newRandomPoissonActivity :: Double -> Simulation m (Activity m () a a)
newRandomPoissonActivity =
  Bool -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomPoissonActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- having the binomial distribution with the specified probability and trials,
-- when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomBinomialActivity :: MonadDES m
                             => Double
                             -- ^ the probability
                             -> Int
                             -- ^ the number of trials
                             -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomBinomialActivity #-}
newRandomBinomialActivity :: Double -> Int -> Simulation m (Activity m () a a)
newRandomBinomialActivity =
  Bool -> Double -> Int -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Int -> Simulation m (Activity m () a a)
newPreemptibleRandomBinomialActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- having the Gamma distribution with the specified shape and scale,
-- when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomGammaActivity :: MonadDES m
                          => Double
                          -- ^ the shape
                          -> Double
                          -- ^ the scale (a reciprocal of the rate)
                          -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomGammaActivity #-}
newRandomGammaActivity :: Double -> Double -> Simulation m (Activity m () a a)
newRandomGammaActivity =
  Bool -> Double -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomGammaActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- having the Beta distribution with the specified shape parameters (alpha and beta),
-- when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomBetaActivity :: MonadDES m
                         => Double
                         -- ^ shape (alpha)
                         -> Double
                         -- ^ shape (beta)
                         -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomBetaActivity #-}
newRandomBetaActivity :: Double -> Double -> Simulation m (Activity m () a a)
newRandomBetaActivity =
  Bool -> Double -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomBetaActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- having the Weibull distribution with the specified shape and scale,
-- when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomWeibullActivity :: MonadDES m
                            => Double
                            -- ^ shape
                            -> Double
                            -- ^ scale
                            -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomWeibullActivity #-}
newRandomWeibullActivity :: Double -> Double -> Simulation m (Activity m () a a)
newRandomWeibullActivity =
  Bool -> Double -> Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomWeibullActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- having the specified discrete distribution, when processing every input element.
--
-- By default, it is assumed that the activity process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomDiscreteActivity :: MonadDES m
                             => DiscretePDF Double
                             -- ^ the discrete probability density function
                             -> Simulation m (Activity m () a a)
{-# INLINABLE newRandomDiscreteActivity #-}
newRandomDiscreteActivity :: DiscretePDF Double -> Simulation m (Activity m () a a)
newRandomDiscreteActivity =
  Bool -> DiscretePDF Double -> Simulation m (Activity m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> DiscretePDF Double -> Simulation m (Activity m () a a)
newPreemptibleRandomDiscreteActivity Bool
False

-- | Create a new activity that holds the process for a random time interval
-- distributed uniformly, when processing every input element.
newPreemptibleRandomUniformActivity :: MonadDES m
                                       => Bool
                                       -- ^ whether the activity process can be preempted
                                       -> Double
                                       -- ^ the minimum time interval
                                       -> Double
                                       -- ^ the maximum time interval
                                       -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomUniformActivity #-}
newPreemptibleRandomUniformActivity :: Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomUniformActivity Bool
preemptible Double
min Double
max =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Double -> Process m ()
forall (m :: * -> *).
MonadDES m =>
Double -> Double -> Process m ()
randomUniformProcess_ Double
min Double
max
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- distributed uniformly, when processing every input element.
newPreemptibleRandomUniformIntActivity :: MonadDES m
                                          => Bool
                                          -- ^ whether the activity process can be preempted
                                          -> Int
                                          -- ^ the minimum time interval
                                          -> Int
                                          -- ^ the maximum time interval
                                          -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomUniformIntActivity #-}
newPreemptibleRandomUniformIntActivity :: Bool -> Int -> Int -> Simulation m (Activity m () a a)
newPreemptibleRandomUniformIntActivity Bool
preemptible Int
min Int
max =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Int -> Int -> Process m ()
forall (m :: * -> *). MonadDES m => Int -> Int -> Process m ()
randomUniformIntProcess_ Int
min Int
max
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- having the triangular distribution, when processing every input element.
newPreemptibleRandomTriangularActivity :: MonadDES m
                                          => Bool
                                          -- ^ whether the activity process can be preempted
                                          -> Double
                                          -- ^ the minimum time interval
                                          -> Double
                                          -- ^ the median of the time interval
                                          -> Double
                                          -- ^ the maximum time interval
                                          -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomTriangularActivity #-}
newPreemptibleRandomTriangularActivity :: Bool
-> Double -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomTriangularActivity Bool
preemptible Double
min Double
median Double
max =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Double -> Double -> Process m ()
forall (m :: * -> *).
MonadDES m =>
Double -> Double -> Double -> Process m ()
randomTriangularProcess_ Double
min Double
median Double
max
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- distributed normally, when processing every input element.
newPreemptibleRandomNormalActivity :: MonadDES m
                                      => Bool
                                      -- ^ whether the activity process can be preempted
                                      -> Double
                                      -- ^ the mean time interval
                                      -> Double
                                      -- ^ the time interval deviation
                                      -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomNormalActivity #-}
newPreemptibleRandomNormalActivity :: Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomNormalActivity Bool
preemptible Double
mu Double
nu =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Double -> Process m ()
forall (m :: * -> *).
MonadDES m =>
Double -> Double -> Process m ()
randomNormalProcess_ Double
mu Double
nu
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- having the lognormal distribution, when processing every input element.
newPreemptibleRandomLogNormalActivity :: MonadDES m
                                         => Bool
                                         -- ^ whether the activity process can be preempted
                                         -> Double
                                         -- ^ the mean of a normal distribution which
                                         -- this distribution is derived from
                                         -> Double
                                         -- ^ the deviation of a normal distribution which
                                         -- this distribution is derived from
                                         -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomLogNormalActivity #-}
newPreemptibleRandomLogNormalActivity :: Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomLogNormalActivity Bool
preemptible Double
mu Double
nu =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Double -> Process m ()
forall (m :: * -> *).
MonadDES m =>
Double -> Double -> Process m ()
randomLogNormalProcess_ Double
mu Double
nu
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
         
-- | Create a new activity that holds the process for a random time interval
-- distributed exponentially with the specified mean (the reciprocal of the rate),
-- when processing every input element.
newPreemptibleRandomExponentialActivity :: MonadDES m
                                           => Bool
                                           -- ^ whether the activity process can be preempted
                                           -> Double
                                           -- ^ the mean time interval (the reciprocal of the rate)
                                           -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomExponentialActivity #-}
newPreemptibleRandomExponentialActivity :: Bool -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomExponentialActivity Bool
preemptible Double
mu =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Process m ()
forall (m :: * -> *). MonadDES m => Double -> Process m ()
randomExponentialProcess_ Double
mu
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
         
-- | Create a new activity that holds the process for a random time interval
-- having the Erlang distribution with the specified scale (the reciprocal of the rate)
-- and shape parameters, when processing every input element.
newPreemptibleRandomErlangActivity :: MonadDES m
                                      => Bool
                                      -- ^ whether the activity process can be preempted
                                      -> Double
                                      -- ^ the scale (the reciprocal of the rate)
                                      -> Int
                                      -- ^ the shape
                                      -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomErlangActivity #-}
newPreemptibleRandomErlangActivity :: Bool -> Double -> Int -> Simulation m (Activity m () a a)
newPreemptibleRandomErlangActivity Bool
preemptible Double
beta Int
m =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Int -> Process m ()
forall (m :: * -> *). MonadDES m => Double -> Int -> Process m ()
randomErlangProcess_ Double
beta Int
m
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- having the Poisson distribution with the specified mean, when processing
-- every input element.
newPreemptibleRandomPoissonActivity :: MonadDES m
                                       => Bool
                                       -- ^ whether the activity process can be preempted
                                       -> Double
                                       -- ^ the mean time interval
                                       -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomPoissonActivity #-}
newPreemptibleRandomPoissonActivity :: Bool -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomPoissonActivity Bool
preemptible Double
mu =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Process m ()
forall (m :: * -> *). MonadDES m => Double -> Process m ()
randomPoissonProcess_ Double
mu
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- having the binomial distribution with the specified probability and trials,
-- when processing every input element.
newPreemptibleRandomBinomialActivity :: MonadDES m
                                        => Bool
                                        -- ^ whether the activity process can be preempted
                                        -> Double
                                        -- ^ the probability
                                        -> Int
                                        -- ^ the number of trials
                                        -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomBinomialActivity #-}
newPreemptibleRandomBinomialActivity :: Bool -> Double -> Int -> Simulation m (Activity m () a a)
newPreemptibleRandomBinomialActivity Bool
preemptible Double
prob Int
trials =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Int -> Process m ()
forall (m :: * -> *). MonadDES m => Double -> Int -> Process m ()
randomBinomialProcess_ Double
prob Int
trials
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- having the Gamma distribution with the specified shape and scale,
-- when processing every input element.
newPreemptibleRandomGammaActivity :: MonadDES m
                                     => Bool
                                     -- ^ whether the activity process can be preempted
                                     -> Double
                                     -- ^ the shape
                                     -> Double
                                     -- ^ the scale
                                     -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomGammaActivity #-}
newPreemptibleRandomGammaActivity :: Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomGammaActivity Bool
preemptible Double
kappa Double
theta =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Double -> Process m ()
forall (m :: * -> *).
MonadDES m =>
Double -> Double -> Process m ()
randomGammaProcess_ Double
kappa Double
theta
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- having the Beta distribution with the specified shape parameters (alpha and beta),
-- when processing every input element.
newPreemptibleRandomBetaActivity :: MonadDES m
                                    => Bool
                                    -- ^ whether the activity process can be preempted
                                    -> Double
                                    -- ^ shape (alpha)
                                    -> Double
                                    -- ^ shape (beta)
                                    -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomBetaActivity #-}
newPreemptibleRandomBetaActivity :: Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomBetaActivity Bool
preemptible Double
alpha Double
beta =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Double -> Process m ()
forall (m :: * -> *).
MonadDES m =>
Double -> Double -> Process m ()
randomBetaProcess_ Double
alpha Double
beta
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- having the Weibull distribution with the specified shape and scale,
-- when processing every input element.
newPreemptibleRandomWeibullActivity :: MonadDES m
                                       => Bool
                                       -- ^ whether the activity process can be preempted
                                       -> Double
                                       -- ^ shape
                                       -> Double
                                       -- ^ scale
                                       -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomWeibullActivity #-}
newPreemptibleRandomWeibullActivity :: Bool -> Double -> Double -> Simulation m (Activity m () a a)
newPreemptibleRandomWeibullActivity Bool
preemptible Double
alpha Double
beta =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do Double -> Double -> Process m ()
forall (m :: * -> *).
MonadDES m =>
Double -> Double -> Process m ()
randomWeibullProcess_ Double
alpha Double
beta
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a

-- | Create a new activity that holds the process for a random time interval
-- having the specified discrete distribution, when processing every input element.
newPreemptibleRandomDiscreteActivity :: MonadDES m
                                        => Bool
                                        -- ^ whether the activity process can be preempted
                                        -> DiscretePDF Double
                                        -- ^ the discrete probability density function
                                        -> Simulation m (Activity m () a a)
{-# INLINABLE newPreemptibleRandomDiscreteActivity #-}
newPreemptibleRandomDiscreteActivity :: Bool -> DiscretePDF Double -> Simulation m (Activity m () a a)
newPreemptibleRandomDiscreteActivity Bool
preemptible DiscretePDF Double
dpdf =
  Bool -> (a -> Process m a) -> Simulation m (Activity m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Activity m () a b)
newPreemptibleActivity Bool
preemptible ((a -> Process m a) -> Simulation m (Activity m () a a))
-> (a -> Process m a) -> Simulation m (Activity m () a a)
forall a b. (a -> b) -> a -> b
$ \a
a ->
  do DiscretePDF Double -> Process m ()
forall (m :: * -> *).
MonadDES m =>
DiscretePDF Double -> Process m ()
randomDiscreteProcess_ DiscretePDF Double
dpdf
     a -> Process m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a