320 likes | 449 Views
Outline. performance measures for a single-server station discrete-event simulation hand simulation process-oriented simulation approach. Machine (Server). 6. 5. out going. incoming. 1. 2. 2. 4. 3. 3. A Single-Server Station. single-server stations … performance measures
E N D
Outline • performance measures for a single-server station • discrete-event simulation • hand simulation • process-oriented simulation approach
Machine (Server) 6 5 out going incoming 1 2 2 4 3 3 A Single-Server Station • single-server stations … • performance measures • two types of averages: customer and time Queue (FIFO)
average waiting time in queue = maximum waiting time in queue, WQ* = Performance Measures Related to Waiting Time in Queue • Nbeno. of customers who have ever left the queue and got (at least some) service • WQibe the time in queue of the ith customer
average time in system = maximum time in system, TS* = Performance Measures Related to Total Time in System • P no. of customers who have completed his service • TSi= time in system of customer i
time-average number in queue = maximum number waiting in queue, Q* = Performance Measures Related to Number in Queue • Q(t) be the # of customers in queue at t if we simulate only 20 time units
again only for simulating for 20 time units utilization = Performance Measures Related to Utilization of Server
An GI/GI/1 Queue • the simplest single-server station • independent service and arrival processes • inter-arrival times of customers, Tn, i.i.d • service times of customers, Sn, i.i.d • FCFS discipline • infinite buffer
N(t) t The State and the Sample Path of an GI/G/1 Queue • state: N(t), number of customers in system
Simulating an GI/GI/1 Queue by Hand • simulate the system for 20 time units to get • total # of customers served (in the time horizon) • average and maximum waiting time in queue • time-average and maximum number in queue • average and maximum total time in system • utilization (proportion of time busy)
Input Data • Initially (time 0) empty and idle • Part Number Arrival Time Interarrival Time Service Time 1 0.00 1.73 2.90 2 1.73 1.35 1.76 3 3.08 0.71 3.39 4 3.79 0.62 4.52 5 4.41 14.28 4.46 6 18.69 0.70 4.36 7 19.39 15.52 2.07 8 34.91 3.15 3.36 9 38.06 1.76 2.37 10 39.82 1.00 5.38 11 40.82 . . . . . . • Stop when 20 minutes of (simulated) time have passed
Performance Measures • simulate 20 time units • performance measures • average waiting time in queue • time-average number in queue • utilization of drill press • results?
To Simulate the Sample Path of an GI/G/1 Queue • state: N(t), number of customers in system • events • state changes • arrivals and departures of customers N(t) t
“location”: state The Discrete-event Simulation Approach • after defining the states and events, the key is to generate the “locations of points” N(t) t How to do that?
N(t) T3 T2 S2 t T1 S3 S1 The Sample Path of an GI/G/1 Queue • Sn= the service time of the the nth customer • Tn= the inter-arrival time between the (n-1)st and nth customers; T0 = 0 • possible to deduce Sn and Tn from the sample path?
An Equivalent Representation of the Sample Path • {Sn} and {Tn} sample path? • not necessary, if both {Sn} & {Tn} are discrete • yes otherwise • {Sn} & {Tn}: always gives a sample path • generate each Sn and Tn when necessary
T1 S1 To Simulate the Sample Path of an GI/G/1 Queue location of the first point: trivial location of the second point: depending on T1 and S1 suppose T1 < S1 location of the second and third points: trivial location of the fourth point: depending on T2 and S1-T1 N(t) t
To Simulate an GI/GI/1 Queue by a Computer Program • variables • system or simulation variables: TNOW, TTERM • state of the machine • performance variable • events: other than initialization and termination • an arrival: update performance measures • a departure: update performance measures • general flow of the program • initialization: initialize variables; set first event, etc. • if not stopping yet, • check next event, execute tasks for the event • termination: execute all house keeping tasks
To Simulate an GI/G/1 Queue • definition of variables • definition of events • flow chart of program • program: Java
Yes TnowTmax No ouput L/Tnow and L/K arrival service next event Yes N = 0 No N = 1 No Yes Flow Chart for Simulating an GI/G/1 Queue N = L = K = 0; Ta = random inter-arrival time; Ts = infinity L = L + (Ta - Tnow)N; Tnow = Ta; N = N + 1; K = K +1; Ta = Tnow + random inter-arrival time L = L + (Ts - Tnow)N; Tnow = Ts; N = N - 1 Ts = infinity Ts = Tnow + random service time Ts = Tnow + random service time
Conceptual Structure of an Event Calendar • event: (time, type, tasks to do) • event calendar: a link list with scheduledfuture events in ascending order of time • example • four events scheduled at epoch 0 • event 1: (24.3, type = 4, tasks to do) • event 2: (35.6, type = 1, tasks to do) • event 3: (41.3, type = 2, tasks to do) • event 4: (5000, type = END, tasks to do = end program)
tasks to do 24.3 type 4 Event. Cal. End simulation 5000 END tasks to do 35.6 type 1 tasks to do 41.3 type 2 Event Calendar of a Simulation Program TNOW = 0: 1 2 3 4
tasks to do 24.3 type 4 Event. Cal. End simulation End simulation End simulation End simulation End simulation 5000 5000 5000 5000 5000 END END END END END tasks to do tasks to do tasks to do tasks to do tasks to do 35.6 35.6 35.6 35.6 35.6 type 1 type 1 type 1 type 1 type 1 tasks to do tasks to do tasks to do tasks to do tasks to do 41.3 41.3 41.3 41.3 41.3 type 2 type 2 type 2 type 2 type 2 Event Calendar of a Simulation Program suppose that no new event is created by a type 4 event TNOW = 0: move time to TNOW = 24.3 execute first event and update event calendar 1 2 3 4
tasks to do tasks to do tasks to do tasks to do 39.1 39.1 39.1 24.3 type 4 type 4 type 4 type 4 Event. Cal. End simulation End simulation End simulation End simulation 5000 5000 5000 5000 END END END END tasks to do tasks to do tasks to do tasks to do 35.6 35.6 35.6 35.6 type 1 type 1 type 1 type 1 tasks to do tasks to do tasks to do tasks to do 41.3 41.3 41.3 41.3 type 2 type 2 type 2 type 2 Event Calendar of a Simulation Program suppose that a new event is created by an type 4 event at 39.1 TNOW = 0: move time to TNOW = 24.3 execute first event and update event calendar 1 2 3 4
Operations of the Event Calendar • delete an event that has (just) occurred • after completing all tasks at TNOW, remove the first event in the event calendar • insert a new event • get the event time of the new event • check where to insert the event • move backward one rank for events occurring after the new event • insert the new event Describe concept only; actual implementation depends on the data structure used
A Crude Pseudo-Code of GI/G/1Queue with Event Calendar • 1 initialization • set TNOW = 0; initialize variables; set termination event; set initial events • 2 get next event type • 3 while { next event != termination } { • get next event time and next event details • set TNOW to next event time • update the Event Calendar • execute next event, including updating variables and possibly adding new events to Event Calendar • get next event type • } • 4 execute the termination Event
Generic Program Structure for Complex Systems • Initialization Event while (not stopping (e.g., TNOW < TTERM)) { switch (Next Event Type) { case 1: tasks of type 1 event; break; .. .. .. .. case n: tasks of type n event; break; } } Termination Event keep track of the timing of events by the Event Calendar
Process-Oriented World View non-procedural code defining processes of all types of entities possible to have artificial entities for logic flow possibly to have multiple copies of entities at any time Machine (Server) 6 5 out going incoming 1 2 2 4 3 3 Queue (FIFO) Simulation with Arena, 5th ed. Chapter 2 – Fundamental Simulation Concepts Slide 30 of 57
Process-Oriented World View in Arena common world view adopted by simulation software event-oriented programs underneath commonest world view of Arena, with everything executed in SIMAN simulation language underneath Simulation with Arena, 5th ed. Chapter 2 – Fundamental Simulation Concepts Slide 31 of 57
entities attributes global variables Arena built-in user-defined resources queues statistical accumulators events simulation clock starting and stopping Pieces of a Simulation Model