90 likes | 259 Views
WOOD 492 MODELLING FOR DECISION SUPPORT. Lecture 25 Simulation. Review. Simulation: used to imitate the real system using computer software, helpful when system is too complex or has many stochastic elements
E N D
WOOD 492 MODELLING FOR DECISION SUPPORT Lecture 25 Simulation
Review • Simulation: used to imitate the real system using computer software, helpful when system is too complex or has many stochastic elements • Discrete event simulation: if the state of the system changes at random points in time as a result of various events • Different probability distributions are used for different purposes Wood 492 - Saba Vahid
Distributions • Various probability distributions are used for different random events • Poisson : distribution of number of arrivals per unit of time • Exponential : distribution of time between successive events (arrivals, serving customers,…) • Uniform: for random number generation • Normal : for some physical phenomenon's, normally used to represent the distributions of the means of observations from other distributions • Binomial: coin flip • … Wood 492 - Saba Vahid
Cumulative Distribution Function (CDF) Highlighted area: P(x<=t) • CDF is calculated using the area under the probability density graph (PDF): • Assume x is a random variable and t is a possible value for x. If we show the PDF of x with f(x) and the CDF with F(x): =(the area under f(x) up to point t) f(x) t x F(x) 1.0 P(x<=t) t x Wood 492 - Saba Vahid
Example 16 – A discrete event simulation • Simulate a queuing system : • One server • Customers arrive according to a Poisson distribution (mean arrival rate λ = 3 per hour) • Service rate changes according to a Poisson distribution (mean service rate μ = 5 customers per hour) Wood 492 - Saba Vahid
Probability reminder • When the arrival rate α(number of arrivals per unit of time t) follows a Poissondistribution with the mean of αt, it means that inter-arrival times (the time between each consecutive pair of arrival) follow an exponential distribution with the mean of 1/α • If x belongs to an Exponential distribution with the mean 1/α: • Therefore, if customers arrive with the mean rate of 3 per hour, the inter-arrival time has an exponential distribution with the mean of 1/3 hour (on average one arrival happens every 1/3 hour) So, for example, the probability of an arrival happening in the first hour (time of event, x, is less than or equal to 1 hour, t) Wood 492 - Saba Vahid
Example 16 – Queuing system • State of the system at each time t • N(t) = number of customers in the queue at time t • Random events in the simulation: • Arrival of customers (mean inter arrival times are 1/3 hour) • Serving the customers (mean service times are 1/5 hour) • System transition formula: • Arrival: reset N(t) to N(t)+1 • Serve customer: reset N(t) to N(t)-1 • How to change the simulation clock (2 ways): • Fixed-time increment • Next-event increment Wood 492 - Saba Vahid
Fixed-time increment for Example 16 • Two steps: • Advance the clock by a small fixed amount (e.g: 0.1 hour) • Update N(t) based on the events that have occurred (arrivals and serving customers) Example: let’s move the clock from t=0 to t=0.1 hr N(0)=0 Probability of an arrival happening in the first 0.1 hr is: Probability of a departure happening in the first 0.1 hr is: How to use these probabilities? Wood 492 - Saba Vahid
Using random numbers to generate events • To see if the events should occur or not, we use a random number generator to generate a uniform random number between [0,1] (e.g. in Excel there is a RAND() function that does this) • If the random number is less than the calculated probability (in previous slide) we accept the event, if not we reject it. • let’s assume we’ve generated a random number for the arrival of customers with Rand() function, random_A=0.1351 Random_A < 0.259 so we accept the arrival We must generate a new random number for each case, so let’s assume random_D=0.5622 Random_D >= 0.393 so we reject the departure N(1) = N(0)+ 1 (arrival) – 0 (departure) = 0+1=1 Example 16 Wood 492 - Saba Vahid