Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simulation. Example: A Bank Simulator We are given: –The number of tellers –The arrival time of each customer –The amount of time each customer requires.

Similar presentations


Presentation on theme: "Simulation. Example: A Bank Simulator We are given: –The number of tellers –The arrival time of each customer –The amount of time each customer requires."— Presentation transcript:

1 Simulation

2 Example: A Bank Simulator We are given: –The number of tellers –The arrival time of each customer –The amount of time each customer requires for service Goal: design a simulator that will tell us how long each customer waits in line

3 More specifically… numTellers 3 customer 1: arrival 35 service 62 customer 2: arrival 39 service 57 customer 3: arrival 78 service 124 customer 4: arrival 79 service 32 customer 1 does not wait in line, is serviced by teller 1, and leaves the bank at time 97 customer 2 does not wait in line, is serviced by teller 2, and leaves the bank at time 96 customer 3 does not wait in line, is serviced by teller 3, and leaves the bank at time 202 customer 4 waits in line for 17, is serviced by teller 2, and leaves the bank at time 128

4 Event Simulation Discrete time-driven simulation –Start a simulation clock at 0 ticks –At each iteration, advance the clock by 1 tick and process any events that happen at that time Problem?

5 Event Simulation Discrete time-driven simulation –Start a simulation clock at 0 ticks –At each iteration, advance the clock by 1 tick and process any events that happen at that time Problem? –Running time is based on number of ticks, not number of events –Unlikely that there will be an event at every tick

6 Event Simulation Event-driven simulation –Start a simulation clock at 0 ticks –At each iteration, advance the clock to time of next event –How many events in our example? Design of simulator?

7 Simulator Design - Incomplete while there are still events to be processed determine next event (arrival or departure) current time = event time if arrival if teller is free record 0 wait time and schedule departure for arrival+service else insert into wait queue else (departure) record departure time if wait queue is not empty remove customer with smallest arrival time record wait time as (current time - arrival time) schedule departure for current time+service

8 Alternatives Use some probability distribution to determine arrival and service times –Example: generate a random number to indicate amount of time a customer’s request will take to service


Download ppt "Simulation. Example: A Bank Simulator We are given: –The number of tellers –The arrival time of each customer –The amount of time each customer requires."

Similar presentations


Ads by Google