Presentation is loading. Please wait.

Presentation is loading. Please wait.

NETW 707 Modeling and Simulation Amr El Mougy Maggie Mashaly.

Similar presentations


Presentation on theme: "NETW 707 Modeling and Simulation Amr El Mougy Maggie Mashaly."— Presentation transcript:

1 NETW 707 Modeling and Simulation Amr El Mougy Maggie Mashaly

2 Lecture (4) The Event Scheduling/ Time Advance Algorithm

3 The Future Event List (FEL)  FEL: contains all the notices for events scheduled to occur at a future time  At any given time (t), the FEL contains all previously scheduled future events and their associated event times, e.g.: t 1, t 2, t 3, …, etc. See Fig.  The FEL is ordered by event time, i.e. events are arranged chronologically so that the event time satisfies t ≤ t 1 ≤ t 2 ≤ … ≤ t n  At time (t), i.e. CLOCK = t, the event associated with t 1 is called the imminent event. That is, the event that will occur CLOCKSystem State Entities and Attributes Set 1Set 2…..FEL Cumulative Statistics and Counters t(x, y, z,…) (3, t 1 ) – type 3 event to occur at t 1 (1, t 2 ) – type 1 event to occur at t 2.

4 Advancing Simulation Time and Updating System Image CLOCKSystem StateEntities and AttributesSet 1Set 2…..FEL Cumulative Statistics and Counters t(5, 1, 6) (3, t 1 ) – type 3 event to occur at t 1 (1, t 2 ) – type 1 event to occur at t 2 (1, t 3 ) – type 1 event to occur at t 3. (2, t n ) – type 2 event to occur at t n Event scheduling/time advance algorithm Step 1. Remove the event notice for the imminent event (event 3, time t 1 ) from the FEL Step 2. Advance CLOCK to imminent event time (i.e. advance CLOCK from t to t 1 ) Step 3. Execute imminent event; update system state; change entity attributes; and set membership as needed Step 4. Generate future events (if necessary) and place their event notices on the FEL, ranked by event time, e.g. event 4 to occur at time t *, where t 1 < t * < t 1 Step 5. Update cumulative statistics and counters  Old snapshot at time t

5 Advancing Simulation Time and Updating System Image  New snapshot at time t 1 CLOCKSystem StateEntities and AttributesSet 1Set 2…..FEL Cumulative Statistics and Counters t(5, 1, 5) (1, t 2 ) – type 1 event to occur at t 2 (4, t * ) – type 4 event to occur at t * (1, t 3 ) – type 1 event to occur at t 3. (2, t n ) – type 2 event to occur at t n

6 Generation of External Arrival Stream by Bootsrapping 123nn+1 3.7 4.1 7.4 t t*t* …. CLOCK = a*a* Between successive arrival events, other types of events may occur, causing system state to change 0 Arrival Time Arrival Time At simulated time t, assumed to be the instant of the n th arrival, generate interarrival time a *, compute t * = t + a * and schedule future arrival on FEL to occur at future time t *

7 Stopping a Simulation  At time 0, schedule a stop simulation event at a specified future time T E. The simulation will run over the time interval [0, T E ] -Example: Simulate a shop for 8 hours  Run length T E is determined by the simulation itself. T E is the time of occurrence of some event E. - Example: T E = time of the 100 th service completion

8 Example: Checkout Counter  Grocery store with one checkout counter. The stopping time is set to 60 minutes  Model Components: System State Entities Events Event Notices Activities Delay LQ(t): number of customers waiting in line at time t LS(t): number being served (0 or 1) at t Servers and customers Arrivals (A) Departures (D) Stopping (E) (A, t): Arrival event to occur at future time t (D, t): Departure event to occur at future time t (E, 60): Stopping event to occur at future time 60 Inter-arrival time Service time Time the customer spends in waiting

9 Execution of the Arrival Event Arrival event occurs at CLOCK = t Set LS(t) = 1 Increment LQ(t) by 1 LS(t) = 1? Generate service time s*; Schedule new departure event at t + s* Generate service time s*; Schedule new departure event at t + s* Generate interarrival time a*; schedule next arrival event at t + a* Generate interarrival time a*; schedule next arrival event at t + a* Collect statistics Return control to time-advance routine to continue simulation Yes No Step 3 Step 4 Step 5

10 Execution of the Departure Event Departure event occurs at CLOCK = t Set LS(t) = 0 Decrement LQ(t) by 1 LQ(t) > 0? Generate service time s*; Schedule new departure event at t + s* Generate service time s*; Schedule new departure event at t + s* Collect statistics Return control to time-advance routine to continue simulation Yes No Step 3 Step 4 Step 5

11 Evolution of the Event List B = Total server busy time MQ = maximum queue length

12 Experiment Modification  Redesign the simulation to calculate the mean response time and mean proportion of customers who spend 5 or more minutes in the system  Hints: Response time is the length of time the customer spends in the system To calculate the response time for an individual customer, it is necessary to know the arrival and departure times of that customer Therefore, a customer entity with arrival time as an attribute will be added to the list of model components Event notices on the FEL will be expanded to indicate which is affected

13 Additional Model Components System State Entities Events Event Notices Activities Cumul- ative Stats LQ(t): number of customers waiting in line at time t LS(t): number being served (0 or 1) at t Servers and customers (C i, t): customer i who arrived at time t Arrivals (A) Departures (D) Stopping (E) (A, t): Arrival event to occur at future time t (D, t): Departure event to occur at future time t (A, t, C i ): Arrival of customer (C i ) to occur at future time t (D, t, C j ): Departure of customer (C j ) to occur at future time t (E, 60): Stopping event to occur at future time 60 Inter-arrival time Service time Time the customer spends in waiting S: set of customer response times for all customers who have departed by the current time F: total number of customers who have spent more than 5 minutes in the system N D : total number of departures up to the current time

14 New Simulation Table


Download ppt "NETW 707 Modeling and Simulation Amr El Mougy Maggie Mashaly."

Similar presentations


Ads by Google