WOOD 492 MODELLING FOR DECISION SUPPORT

9
WOOD 492 MODELLING FOR DECISION SUPPORT Lecture 25 Simulation

description

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 - PowerPoint PPT Presentation

Transcript of WOOD 492 MODELLING FOR DECISION SUPPORT

Page 1: WOOD 492  MODELLING FOR DECISION SUPPORT

WOOD 492 MODELLING FOR DECISION SUPPORT

Lecture 25

Simulation

Page 2: WOOD 492  MODELLING FOR DECISION SUPPORT

Wood 492 - Saba Vahid 2

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

Nov 5, 2012

Page 3: WOOD 492  MODELLING FOR DECISION SUPPORT

Wood 492 - Saba Vahid 3

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

• …

Nov 5, 2012

Page 4: WOOD 492  MODELLING FOR DECISION SUPPORT

Wood 492 - Saba Vahid 4

Cumulative Distribution Function (CDF)

• 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)

Nov 5, 2012

f(x)

F(x)

x

x

1.0

t

t

Highlighted area: P(x<=t)

P(x<=t)

Page 5: WOOD 492  MODELLING FOR DECISION SUPPORT

Wood 492 - Saba Vahid 5

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)

Nov 5, 2012

InputSource Queue Server

ServedCustomers

Arrival rate (Inter-arrival Time)

Service Rate(Service times)

Page 6: WOOD 492  MODELLING FOR DECISION SUPPORT

Wood 492 - Saba Vahid 6

Probability reminder

1. When the arrival rate α (number of arrivals per unit of time t) follows a Poisson distribution 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/α

2. If x belongs to an Exponential distribution with the mean 1/α:

3. 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)

Nov 5, 2012

Page 7: WOOD 492  MODELLING FOR DECISION SUPPORT

Wood 492 - Saba Vahid 7

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):1. Fixed-time increment

2. Next-event increment

Nov 5, 2012

Page 8: WOOD 492  MODELLING FOR DECISION SUPPORT

Wood 492 - Saba Vahid 8

Fixed-time increment for Example 16

• Two steps:

1. Advance the clock by a small fixed amount (e.g: 0.1 hour)

2. 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?

Nov 5, 2012

Page 9: WOOD 492  MODELLING FOR DECISION SUPPORT

Wood 492 - Saba Vahid 9

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

Nov 5, 2012

Example 16