Stochastic Simulation Discrete simulation/event-by-event Bo Friis - - PowerPoint PPT Presentation

stochastic simulation discrete simulation event by event
SMART_READER_LITE
LIVE PREVIEW

Stochastic Simulation Discrete simulation/event-by-event Bo Friis - - PowerPoint PPT Presentation

Stochastic Simulation Discrete simulation/event-by-event Bo Friis Nielsen Institute of Mathematical Modelling Technical University of Denmark 2800 Kgs. Lyngby Denmark Email: bfni@dtu.dk Discrete event simulation Discrete event


slide-1
SLIDE 1

Stochastic Simulation Discrete simulation/event-by-event

Bo Friis Nielsen

Institute of Mathematical Modelling Technical University of Denmark 2800 Kgs. Lyngby – Denmark Email: bfni@dtu.dk

slide-2
SLIDE 2

02443 – lecture 5 2

DTU

Discrete event simulation Discrete event simulation

  • Continuous but asynchronous time
  • Systems with discrete state-variables

⋄ Inventory systems ⋄ Communication systems ⋄ Traffic systems - (simple models)

  • even-by-event principle
slide-3
SLIDE 3

02443 – lecture 5 3

DTU

Elements of a discrete simulation language/program Elements of a discrete simulation language/program

  • Real time clock
  • State variables
  • Event list(s)
  • Statistics
slide-4
SLIDE 4

02443 – lecture 5 4

DTU

The event-by-event principle The event-by-event principle

  • Advance clock to next event to occur
  • Invoke relevant event handling routine

⋄ collect statistics ⋄ Update system variables

  • Generate and schedule future events - insert in event list(s)
  • return to top
slide-5
SLIDE 5

02443 – lecture 5 5

DTU

Analysing steady-state behaviour Analysing steady-state behaviour

  • Burn-in/initialisation period

⋄ Typically this has to be determined experimentally

  • Confidence intervals/variance estimated from sub-samples
slide-6
SLIDE 6

02443 – lecture 5 6

DTU

Queueing systems Queueing systems

  • Arrival process
  • Service time distribution(s)
  • Service unit(s)
  • Priorities
  • Queueing discipline
slide-7
SLIDE 7

02443 – lecture 5 7

DTU Buffer S(t) A(t)

  • A(t) - Arrival process
  • S(t) - Service process (service time distribution)
  • Finite or infinite waiting room
  • One or many serververs
  • Kendall notation: A(t)/S(t)/N/K

⋄ N - number of servers ⋄ K - room in system (sometime K only relates to waiting room)

slide-8
SLIDE 8

02443 – lecture 5 8

DTU

Performance measures Performance measures

  • Waiting time distribution

⋄ Mean ⋄ Variance ⋄ Quantiles

  • Blocking probabilities
  • Utilisation of equipment (servers)
  • Queue length distribution
slide-9
SLIDE 9

02443 – lecture 5 9

DTU

N(t) X X X X X X S = X + ..... + X

1 n n 1 2 3 4 5 6

* * * * *

slide-10
SLIDE 10

02443 – lecture 5 10

DTU

Poisson process Poisson process

  • Independently exponentially distributed intervals

P(Xi ≤ t) = 1 − e−λt

  • Poisson distributed number of events in an interval. Number of

events in non-overlapping intervals independent N(t) ∼ P(λt) ⇔ P(N(t) = n) = (λt)n n! e−λt

  • If the intervals Xi are independently but generally distributed we

call the process a renewal process

slide-11
SLIDE 11

02443 – lecture 5 11

DTU

Sub-samples - precision of estimate Sub-samples - precision of estimate

  • We need sub-samples in order to investigate the precision of the

estimate.

  • The sub-samples should be independent if possible
  • For independent subsamples the standard deviation of our

estimate will be proportional to √n

−1

slide-12
SLIDE 12

02443 – lecture 5 12

DTU

Confidence limits based on sub-samples Confidence limits based on sub-samples

  • We want to estimate some quantity θ
  • We obtain n different (independent) estimates ˆ

θi.

  • The central limit theorem motivates us to construct the

following confidence interval: ¯ θ = n

i=1 ˆ

θi n S2

θ =

1 n − 1 n

  • i=1

ˆ θ2

i − n¯

θ2

  • ¯

θ + Sθ √nt α

2 (n − 1); ¯

θ + Sθ √nt1− α

2 (n − 1)

slide-13
SLIDE 13

02443 – lecture 5 13

DTU

Confidence limits based on sub-samples - based on normal distribution Confidence limits based on sub-samples - based on normal distribution

  • ¯

θ + Sθ √nu α

2 ; ¯

θ + Sθ √nu1− α

2

slide-14
SLIDE 14

02443 – lecture 5 14

DTU

General statistical analysis General statistical analysis

  • More generally we can apply any statistical technique
  • In the planning phase - experimental design
  • In the analysis phase

⋄ Analysis of variance ⋄ Time-series analysis ⋄ . . .

slide-15
SLIDE 15

02443 – lecture 5 15

DTU

Rødby Puttgarden Simulation study Rødby Puttgarden Simulation study

  • Access to harbour facilities
  • A number of rules regarding

⋄ The harbour channel ⋄ The ferry berths

  • Data for

⋄ Sailing times ⋄ unload/load times

slide-16
SLIDE 16

02443 – lecture 5 16

DTU

The system events The system events

  • arrive harbour;
  • depart channel
  • loaded
  • ready sail
  • arrive channel
  • arrive berth
slide-17
SLIDE 17

02443 – lecture 5 17

DTU

Global (ressource) variables Global (ressource) variables

short channel[2],berth[2][4];

slide-18
SLIDE 18

02443 – lecture 5 18

DTU

Ferry data structures Ferry data structures

class ferry_type { public: short type; short id; short status; short event; short harbour; short berth; time_type event_time; time_type scheduled_time; ferry_type * previous; ferry_type * next; };

slide-19
SLIDE 19

02443 – lecture 5 19

DTU

Main programme - initialisation Main programme - initialisation

void main() { ferry_type * ferry; time.minutes=0; time.hours=0; event_list = 0; Initialization(); Print_ferries(event_list);

slide-20
SLIDE 20

Main programme simulation loop Main programme simulation loop

while (time.hours<100) { ferry = event_list; time = ferry->event_time; event_list = event_list->next; if (event_list != 0) event_list->previous =0; switch(ferry->event) { case arrive_harbour : Arrive_harbour(ferry); break; case depart_channel : Depart_channel(ferry); break; case loaded : Loaded(ferry); break; case ready_sail : Ready_sail(ferry); break; case arrive_channel : Arrive_channel(ferry); break; case arrive_berth : Arrive_berth(ferry); break; default : break; } /* End switch */ } /* End main loop */ Print_statistics();

slide-21
SLIDE 21

02443 – lecture 5 21

DTU

Sample event procedure Sample event procedure

void Arrive_harbour(ferry_type * ferry) { if ((Request_channel(ferry)>0) && (Request_berth(ferry)>0)) { ferry->event = arrive_channel; ferry->event_time = time; Insert_in_event_list(ferry); } else Wait_for_arrive(ferry); }

slide-22
SLIDE 22

02443 – lecture 5 22

DTU

Another event procedure Another event procedure

void Depart_channel(ferry_type * ferry) { channel[ferry->harbour] = vacant; ferry->event = arrive_harbour; ferry->event_time = time + Sailing_time(ferry); Check_waiting_ferries(ferry->harbour); ferry->harbour = New_harbour(ferry->harbour); Insert_in_event_list(ferry); }

slide-23
SLIDE 23

02443 – lecture 5 23

DTU

Exercise 4 Exercise 4

  • Write a discrete event simulation program for a blocking system,

i.e. a system with n service units and no waiting room.

  • The arrival process is modelled as a Poisson process.
  • Choose first the service time distribution as exponential.
  • Record the fraction of blocked customers, and a confidence

interval for this fraction..

  • The programme should take the offered traffic and the number
  • f service units as input parameters.

Example: n = 10, mean service time = 8 time units, mean time between customers = 1 time unit (corresponding to an offered traffic of 8 erlang), 10 x 10.000 customers.

slide-24
SLIDE 24

Exercise 4 - continued Exercise 4 - continued

  • In the above example substitute the arrival process with a

renewal process with 1) Erlang distributed inter arrival times 2) hyper exponential inter arrival times. The Erlang distribution should have a mean of 1, the parameters for the hyper exponential distribution should be p1 = 0.8, λ1 = 0.8333, p2 = 0.2, λ2 = 5.0.

  • Finally experiment with different service time distributions.

Suggestions are constant service timeand Pareto distributed service times,for Pareto will k = 1.05 and k = 2.05 be interesting choices. It is recommended that the service time distribution has the same mean (8).

  • Make the experiment with a distribution of (your own) choice.

Remember that the distribution should take only non-negative values.

slide-25
SLIDE 25

02443 – lecture 5 25

DTU

Exercise 4 - exact solution Exercise 4 - exact solution

  • With arrival intensity λ and mean service time s
  • Define A = λs
  • Erlangs B-formula

B = P(n) =

An n!

n

i=0 Ai i!

  • Valid for all service time distributions
  • But arrival process has to be a Poisson process