14 Designing a Simulation - Camera Store Example PDF

Title 14 Designing a Simulation - Camera Store Example
Author Haiqing Gong
Course Intermediate Microeconomics SFW
Institution University of Guelph
Pages 31
File Size 2 MB
File Type PDF
Total Downloads 25
Total Views 143

Summary

Mersenne Twister...


Description

Event-Driven Simulation Designing the Discrete Event Simulator Using a more complex example

Design an event-driven model !

Basic Flow of the system ! ! !

!

a customer can browse the store and choose display items or go to a 3-server service-desk for more expensive items after which the customer will check out at a single cashier station

Constraints ! !

!

!

The customer only goes to the service desk once or not at all. The customer may choose only display items, or choose display items before and/or after they go to the service-desk. If a customer selects any item, the customer must check out at the cashier station however, customers may leave the store without purchasing any items

Design an event-driven model A Calling Population (IA)

Internal to event

Steller Q1

STteller

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Design an event-driven model !

Typical Mistake: ! !

Take above design and code it as a single system Not using events !

!

usually bypasses FEL, states, etc.

Will work ... however ! ! !

Not flexible: each system must be built from scratch Not efficient: speed is important ... despite us using R :-) Abandons our progression of simulators "

!

Monte Carlo → Discrete State → Discrete Events

Will not get you any marks for your assignments :-(

What is an event? !

Simulation based on clients being served by servers

!

However serving done behind the scenes ! !

!

between events similar to figure-ground illusions

When server is finished (service time over) event is triggered (next event flag in the FEL) !

!

Think of the event flag from the FEL, “server finishing” or “customer departing” (same thing), as starting the event Think of the event as what happens to the customer and the server after the server finished serving the customer off stage

Depart from Te

nt

A Calling Population (IA)

Internal to event

Steller Q1

STteller

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A Calling Population (IA)

Internal to event

Steller Q1

STteller

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A Ca Popula s ts

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A Calling Population (IA)

Internal to event

Steller Q1

STteller

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A

Internal to event

Calling Population (I Q1

STteller

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A Calling Population (IA)

Internal to event

Steller Q1

STteller

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A Calling Population (I

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A

Internal to event

Calling Population (I

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A

Internal to event

Calling Population (I

Decide to go to cashier

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A

Internal to event

Calling Population (I

State Generates new events

STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A

Internal to event

Calling Population (I

State Generates new events

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te

nt

A

Internal to event

Calling Population (I

State Generates new events

C1 STself1

C3 Scashier

Exit

STcash

Q2 C4

STself2

Depart from Te

nt

A Calling Population (IA)

Internal to event

Steller Q1

STteller

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

What is an event? !

When an event actually runs !

!

When you write an event routine !

!

you must code all paths and all decision points

Paths always start from ! !

!

only one path is traversed

a server arrival points

Paths always end at ! !

a server/server-queue a system exit

What is an event? !

There are 3 broad categories of events ! ! !

!

Departure Events !

!

Arrivals Departures End Already examined

End Events ! !

Stops the simulation No processing is done !

Although can have a “clean-up” routine called

What is an event? !

Arrival Events !

Problem ! !

Simulation based on Client-Server model Events triggered by a server finishing "

!

releases the client to go to the next stage of the system

So where do the customers come from?

What is an event? !

Arrival Events !

Solution !

Customers come from outside the system "

!

Really a “departure event” from outside the system "

!

Arrival event so don’t “see” the server

No need for extra “arrival” events for each subsystem within the system "

The “departure event “ from the previous server subystem is sufficient

What is an event? !

Arrival Events !

Implementation details ! ! !

Always first schedule the next arrival (place it in the FEL) No server to consider, only the customer’s paths Otherwise works the same as departure routines

Events, States and Clocks !

Event Update Routines ! !

change state variables schedules new events in the FEL !

!

does not advance the clock !

!

more than one new event can be scheduled (enqueued) during an event routine never dequeues the FEL

Time only advances !

between events ! !

!

between arrivals when service is being done (between the start of a service and the end of the service)

occurs when simulator dequeues the FEL

Design an event-driven model A Calling Population (IA)

LSteller LQ1

STteller

Internal to event State Generates new events

STteller STteller

C1 STself1

C2 LScashier

Exit

STcash

C3 LQ2 C4

STself2

Design an event-driven model Event Types D1 = depart from Steller D2 = depart from Sself1 D3 = depart from Sself2 D4 = depart from Scash A = arrivals E = end

System State Variables LS1 = [int] number of busy tellers; max = 3 LQ1 = tellers queue [int] LS2 = [int] number of customers self serving; no max LS3 = [int] number of customers self serving; no max LS4 = [int] cashier busy; max = 1 LQ2 = cashier queue [int]

Event (Time) Random Variables Internal Random Variables IA  = [double] inter-arrival time C1,3 = [bool] choice to serve self STteller = [double] teller service time C2= [bool] choice to talk to a teller STself1 = [double] self service time C4 = [bool] choice to buy something STself2 = [double] self service time STcash = [double] cashier service time

Design an event-driven model Event Types A = arrivals D1 = depart from Steller D2 = depart from Sself1 D3 = depart from Sself2 D4 = depart from Scash E = end

Event (Time) Random Variables IA  = inter-arrival time [double] STteller = teller service time [double] STself,i = self service time [double] i = 1,2 STcash  = cashier service time [double]

System State Variables Q1 = tellers queue [int]

LS1  Q2 

= number of busy tellers [int] = cashier queue [int]

LS2 

= cashier busy [bool]

Internal Random Variables C1,3 = choice to serve self [bool] C2= choice to talk to a teller [bool] C4 = choice to buy something [bool]

Depart from Te

nt

A Calling Population (IA)

Internal to event

Steller Q1

STteller

State Generates new events

STteller STteller

C1 C2

STself1 Scashier Exit

STcash

C3 Q2 C4

STself2

Depart from Te A Ca Popula

nt

departTeller.event...


Similar Free PDFs