Package cs2030.simulator
Class RandomGenerator
- java.lang.Object
-
- cs2030.simulator.RandomGenerator
-
public class RandomGenerator extends java.lang.Object
Encapsulates multiple streams of pseudo-random numbers specifically for use with the shop simulator. the RandomGenerator is initialized with a seed, the arrival rate (lambda) and the service rate (mu). There are two streams of random numbers here, one for inter arrival time, and the other for service time.
-
-
Field Summary
Fields Modifier and Type Field Description private double
customerArrivalRate
The customer arrival rate (lambda).private double
customerServiceRate
The customer service rate (mu).private java.util.Random
rngArrival
Random number stream for arrival rate.private java.util.Random
rngCustomerType
Random number stream for customer type.private java.util.Random
rngRest
Random number stream for probability of resting.private java.util.Random
rngRestPeriod
Random number stream for resting period.private java.util.Random
rngService
Random number stream for service rate.private java.util.Random
rngTimeoutPeriod
Random number stream for timeout period.private double
serverRestingRate
The server resting rate (rho).
-
Constructor Summary
Constructors Constructor Description RandomGenerator(int seed, double lambda, double mu, double rho)
Create a new RandomGenerator object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) double
genCustomerType()
Generate a random number between 0 and 1 to determine the type of customer.(package private) double
genInterArrivalTime()
Generate random inter-arrival time.(package private) double
genRandomRest()
Generate a random number between 0 and 1 to compare to a server's probability of taking a rest.(package private) double
genRestPeriod()
Generate random resting period for server.(package private) double
genServiceTime()
Generate random service time.
-
-
-
Field Detail
-
rngArrival
private final java.util.Random rngArrival
Random number stream for arrival rate.
-
rngService
private final java.util.Random rngService
Random number stream for service rate.
-
rngRest
private final java.util.Random rngRest
Random number stream for probability of resting.
-
rngRestPeriod
private final java.util.Random rngRestPeriod
Random number stream for resting period.
-
rngTimeoutPeriod
private final java.util.Random rngTimeoutPeriod
Random number stream for timeout period.
-
rngCustomerType
private final java.util.Random rngCustomerType
Random number stream for customer type.
-
customerArrivalRate
private final double customerArrivalRate
The customer arrival rate (lambda).
-
customerServiceRate
private final double customerServiceRate
The customer service rate (mu).
-
serverRestingRate
private final double serverRestingRate
The server resting rate (rho).
-
-
Method Detail
-
genInterArrivalTime
double genInterArrivalTime()
Generate random inter-arrival time. The inter-arrival time is modelled as an exponential random variable, characterised by a single parameter -- arrival rate.- Returns:
- inter-arrival time for next event.
-
genServiceTime
double genServiceTime()
Generate random service time. The service time is modelled as an exponential random variable, characterised by a single parameter - service rate.- Returns:
- service time for event.
-
genRandomRest
double genRandomRest()
Generate a random number between 0 and 1 to compare to a server's probability of taking a rest. The random number generated is used to determine whether the server takes rest after serving a customer.- Returns:
- a random number between 0 and 1.
-
genRestPeriod
double genRestPeriod()
Generate random resting period for server. The resting period is modelled as an exponential random variable, characterised by a single parameter - resting rate.- Returns:
- resting period for server.
-
genCustomerType
double genCustomerType()
Generate a random number between 0 and 1 to determine the type of customer.- Returns:
- a random number uniformed drawn from 0 to 1.
-
-