-- |
-- Module     : Simulation.Aivika.Trans.Server.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 servers that
-- hold the current process for the corresponding random time
-- interval, when processing every input element.
--

module Simulation.Aivika.Trans.Server.Random
       (newRandomUniformServer,
        newRandomUniformIntServer,
        newRandomTriangularServer,
        newRandomNormalServer,
        newRandomLogNormalServer,
        newRandomExponentialServer,
        newRandomErlangServer,
        newRandomPoissonServer,
        newRandomBinomialServer,
        newRandomGammaServer,
        newRandomBetaServer,
        newRandomWeibullServer,
        newRandomDiscreteServer,
        newPreemptibleRandomUniformServer,
        newPreemptibleRandomUniformIntServer,
        newPreemptibleRandomTriangularServer,
        newPreemptibleRandomNormalServer,
        newPreemptibleRandomLogNormalServer,
        newPreemptibleRandomExponentialServer,
        newPreemptibleRandomErlangServer,
        newPreemptibleRandomPoissonServer,
        newPreemptibleRandomBinomialServer,
        newPreemptibleRandomGammaServer,
        newPreemptibleRandomBetaServer,
        newPreemptibleRandomWeibullServer,
        newPreemptibleRandomDiscreteServer) 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.Server

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

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

-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomTriangularServer :: MonadDES m
                             => Double
                             -- ^ the minimum time interval
                             -> Double
                             -- ^ the median of the time interval
                             -> Double
                             -- ^ the maximum time interval
                             -> Simulation m (Server m () a a)
{-# INLINABLE newRandomTriangularServer #-}
newRandomTriangularServer :: Double -> Double -> Double -> Simulation m (Server m () a a)
newRandomTriangularServer =
  Bool
-> Double -> Double -> Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool
-> Double -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomTriangularServer Bool
False

-- | Create a new server that holds the process for a random time interval
-- distributed normally, when processing every input element.
--
-- By default, it is assumed that the server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomNormalServer :: MonadDES m
                         => Double
                         -- ^ the mean time interval
                         -> Double
                         -- ^ the time interval deviation
                         -> Simulation m (Server m () a a)
{-# INLINABLE newRandomNormalServer #-}
newRandomNormalServer :: Double -> Double -> Simulation m (Server m () a a)
newRandomNormalServer =
  Bool -> Double -> Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomNormalServer Bool
False
         
-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomLogNormalServer :: 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 (Server m () a a)
{-# INLINABLE newRandomLogNormalServer #-}
newRandomLogNormalServer :: Double -> Double -> Simulation m (Server m () a a)
newRandomLogNormalServer =
  Bool -> Double -> Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomLogNormalServer Bool
False
         
-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomExponentialServer :: MonadDES m
                              => Double
                              -- ^ the mean time interval (the reciprocal of the rate)
                              -> Simulation m (Server m () a a)
{-# INLINABLE newRandomExponentialServer #-}
newRandomExponentialServer :: Double -> Simulation m (Server m () a a)
newRandomExponentialServer =
  Bool -> Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomExponentialServer Bool
False
         
-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomErlangServer :: MonadDES m
                         => Double
                         -- ^ the scale (the reciprocal of the rate)
                         -> Int
                         -- ^ the shape
                         -> Simulation m (Server m () a a)
{-# INLINABLE newRandomErlangServer #-}
newRandomErlangServer :: Double -> Int -> Simulation m (Server m () a a)
newRandomErlangServer =
  Bool -> Double -> Int -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Int -> Simulation m (Server m () a a)
newPreemptibleRandomErlangServer Bool
False

-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomPoissonServer :: MonadDES m
                          => Double
                          -- ^ the mean time interval
                          -> Simulation m (Server m () a a)
{-# INLINABLE newRandomPoissonServer #-}
newRandomPoissonServer :: Double -> Simulation m (Server m () a a)
newRandomPoissonServer =
  Bool -> Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomPoissonServer Bool
False

-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomBinomialServer :: MonadDES m
                           => Double
                           -- ^ the probability
                           -> Int
                           -- ^ the number of trials
                           -> Simulation m (Server m () a a)
{-# INLINABLE newRandomBinomialServer #-}
newRandomBinomialServer :: Double -> Int -> Simulation m (Server m () a a)
newRandomBinomialServer =
  Bool -> Double -> Int -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Int -> Simulation m (Server m () a a)
newPreemptibleRandomBinomialServer Bool
False

-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomGammaServer :: MonadDES m
                        => Double
                        -- ^ the shape
                        -> Double
                        -- ^ the scale (a reciprocal of the rate)
                        -> Simulation m (Server m () a a)
{-# INLINABLE newRandomGammaServer #-}
newRandomGammaServer :: Double -> Double -> Simulation m (Server m () a a)
newRandomGammaServer =
  Bool -> Double -> Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomGammaServer Bool
False

-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomBetaServer :: MonadDES m
                       => Double
                       -- ^ shape (alpha)
                       -> Double
                       -- ^ shape (beta)
                       -> Simulation m (Server m () a a)
{-# INLINABLE newRandomBetaServer #-}
newRandomBetaServer :: Double -> Double -> Simulation m (Server m () a a)
newRandomBetaServer =
  Bool -> Double -> Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomBetaServer Bool
False

-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomWeibullServer :: MonadDES m
                          => Double
                          -- ^ shape
                          -> Double
                          -- ^ scale
                          -> Simulation m (Server m () a a)
{-# INLINABLE newRandomWeibullServer #-}
newRandomWeibullServer :: Double -> Double -> Simulation m (Server m () a a)
newRandomWeibullServer =
  Bool -> Double -> Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomWeibullServer Bool
False

-- | Create a new server 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 server process cannot be preempted,
-- because the handling of possible task preemption is rather costly
-- operation.
newRandomDiscreteServer :: MonadDES m
                           => DiscretePDF Double
                           -- ^ the discrete probability density function
                           -> Simulation m (Server m () a a)
{-# INLINABLE newRandomDiscreteServer #-}
newRandomDiscreteServer :: DiscretePDF Double -> Simulation m (Server m () a a)
newRandomDiscreteServer =
  Bool -> DiscretePDF Double -> Simulation m (Server m () a a)
forall (m :: * -> *) a.
MonadDES m =>
Bool -> DiscretePDF Double -> Simulation m (Server m () a a)
newPreemptibleRandomDiscreteServer Bool
False

-- | Create a new server that holds the process for a random time interval
-- distributed uniformly, when processing every input element.
newPreemptibleRandomUniformServer :: MonadDES m
                                     => Bool
                                     -- ^ whether the server process can be preempted
                                     -> Double
                                     -- ^ the minimum time interval
                                     -> Double
                                     -- ^ the maximum time interval
                                     -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomUniformServer #-}
newPreemptibleRandomUniformServer :: Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomUniformServer Bool
preemptible Double
min Double
max =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- distributed uniformly, when processing every input element.
newPreemptibleRandomUniformIntServer :: MonadDES m
                                        => Bool
                                        -- ^ whether the server process can be preempted
                                        -> Int
                                        -- ^ the minimum time interval
                                        -> Int
                                        -- ^ the maximum time interval
                                        -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomUniformIntServer #-}
newPreemptibleRandomUniformIntServer :: Bool -> Int -> Int -> Simulation m (Server m () a a)
newPreemptibleRandomUniformIntServer Bool
preemptible Int
min Int
max =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- having the triangular distribution, when processing every input element.
newPreemptibleRandomTriangularServer :: MonadDES m
                                        => Bool
                                        -- ^ whether the server process can be preempted
                                        -> Double
                                        -- ^ the minimum time interval
                                        -> Double
                                        -- ^ the median of the time interval
                                        -> Double
                                        -- ^ the maximum time interval
                                        -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomTriangularServer #-}
newPreemptibleRandomTriangularServer :: Bool
-> Double -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomTriangularServer Bool
preemptible Double
min Double
median Double
max =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- distributed normally, when processing every input element.
newPreemptibleRandomNormalServer :: MonadDES m
                                    => Bool
                                    -- ^ whether the server process can be preempted
                                    -> Double
                                    -- ^ the mean time interval
                                    -> Double
                                    -- ^ the time interval deviation
                                    -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomNormalServer #-}
newPreemptibleRandomNormalServer :: Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomNormalServer Bool
preemptible Double
mu Double
nu =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- having the lognormal distribution, when processing every input element.
newPreemptibleRandomLogNormalServer :: MonadDES m
                                       => Bool
                                       -- ^ whether the server 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 (Server m () a a)
{-# INLINABLE newPreemptibleRandomLogNormalServer #-}
newPreemptibleRandomLogNormalServer :: Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomLogNormalServer Bool
preemptible Double
mu Double
nu =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server 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.
newPreemptibleRandomExponentialServer :: MonadDES m
                                         => Bool
                                         -- ^ whether the server process can be preempted
                                         -> Double
                                         -- ^ the mean time interval (the reciprocal of the rate)
                                         -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomExponentialServer #-}
newPreemptibleRandomExponentialServer :: Bool -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomExponentialServer Bool
preemptible Double
mu =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server 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.
newPreemptibleRandomErlangServer :: MonadDES m
                                    => Bool
                                    -- ^ whether the server process can be preempted
                                    -> Double
                                    -- ^ the scale (the reciprocal of the rate)
                                    -> Int
                                    -- ^ the shape
                                    -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomErlangServer #-}
newPreemptibleRandomErlangServer :: Bool -> Double -> Int -> Simulation m (Server m () a a)
newPreemptibleRandomErlangServer Bool
preemptible Double
beta Int
m =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- having the Poisson distribution with the specified mean, when processing
-- every input element.
newPreemptibleRandomPoissonServer :: MonadDES m
                                     => Bool
                                     -- ^ whether the server process can be preempted
                                     -> Double
                                     -- ^ the mean time interval
                                     -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomPoissonServer #-}
newPreemptibleRandomPoissonServer :: Bool -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomPoissonServer Bool
preemptible Double
mu =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- having the binomial distribution with the specified probability and trials,
-- when processing every input element.
newPreemptibleRandomBinomialServer :: MonadDES m
                                      => Bool
                                      -- ^ whether the server process can be preempted
                                      -> Double
                                      -- ^ the probability
                                      -> Int
                                      -- ^ the number of trials
                                      -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomBinomialServer #-}
newPreemptibleRandomBinomialServer :: Bool -> Double -> Int -> Simulation m (Server m () a a)
newPreemptibleRandomBinomialServer Bool
preemptible Double
prob Int
trials =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- having the Gamma distribution with the specified shape and scale,
-- when processing every input element.
newPreemptibleRandomGammaServer :: MonadDES m
                                   => Bool
                                   -- ^ whether the server process can be preempted
                                   -> Double
                                   -- ^ the shape
                                   -> Double
                                   -- ^ the scale (a reciprocal of the rate)
                                   -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomGammaServer #-}
newPreemptibleRandomGammaServer :: Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomGammaServer Bool
preemptible Double
kappa Double
theta =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server 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.
newPreemptibleRandomBetaServer :: MonadDES m
                                  => Bool
                                  -- ^ whether the server process can be preempted
                                  -> Double
                                  -- ^ shape (alpha)
                                  -> Double
                                  -- ^ shape (beta)
                                  -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomBetaServer #-}
newPreemptibleRandomBetaServer :: Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomBetaServer Bool
preemptible Double
alpha Double
beta =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- having the Weibull distribution with the specified shape and scale,
-- when processing every input element.
newPreemptibleRandomWeibullServer :: MonadDES m
                                     => Bool
                                     -- ^ whether the server process can be preempted
                                     -> Double
                                     -- ^ shape
                                     -> Double
                                     -- ^ scale
                                     -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomWeibullServer #-}
newPreemptibleRandomWeibullServer :: Bool -> Double -> Double -> Simulation m (Server m () a a)
newPreemptibleRandomWeibullServer Bool
preemptible Double
alpha Double
beta =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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 server that holds the process for a random time interval
-- having the specified discrete distribution, when processing every input element.
newPreemptibleRandomDiscreteServer :: MonadDES m
                                      => Bool
                                      -- ^ whether the server process can be preempted
                                      -> DiscretePDF Double
                                      -- ^ the discrete probability density function
                                      -> Simulation m (Server m () a a)
{-# INLINABLE newPreemptibleRandomDiscreteServer #-}
newPreemptibleRandomDiscreteServer :: Bool -> DiscretePDF Double -> Simulation m (Server m () a a)
newPreemptibleRandomDiscreteServer Bool
preemptible DiscretePDF Double
dpdf =
  Bool -> (a -> Process m a) -> Simulation m (Server m () a a)
forall (m :: * -> *) a b.
MonadDES m =>
Bool -> (a -> Process m b) -> Simulation m (Server m () a b)
newPreemptibleServer Bool
preemptible ((a -> Process m a) -> Simulation m (Server m () a a))
-> (a -> Process m a) -> Simulation m (Server 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