Download presentation
Presentation is loading. Please wait.
Published byElinor Parrish Modified over 9 years ago
1
1 Outline simulating GI/G/1 queues M/M/1 queues theoretical results of queueing systems an inventory system simulation program with an event calendar hand simulation
2
2 To Simulate an GI/G/1 Queue definition of variables definition of variables definition of events definition of events pseudo code pseudo code flow chart of program flow chart of program NKL TaTa TsTs TNOW TMAX distribution of inter-arrival times distribution of service times
3
3 Flow Chart for Simulating an GI/G/1 Queue N = L = K = T = 0; T a = random inter- arrival time; T s = infinity Yes ouput L/T now and L/K L = L + (T s - T now )N; T now = T s ; N = N - 1 L = L + (T a - T now )N; T now = T a ; N = N + 1; K = K +1; T a = T now + random inter-arrival time T s = T now + random service time T now T max No next event service N = 0 T s = T now + random service time No Yes T s = infinity arrival N = 1 No
4
4 To Simulate an GI/G/1 Queue definition of variables definition of events pseudo code flow chart of program Java program Java program
5
5 Variations of GI/G/1 Queues M/M/1-based queue standard: Java programJava program with queue limit: Java programJava program
6
6 Terms Associated with a Customer for customer i arrival time, t ai time to start service, t si time to leave system, t di time in queue, D i = t si – t ai service time, S i = t di – t si time in system, W i = t di – t ai other names of time in queue = waiting time in queue = delay time other names of time in system = waiting time in system = total time in system
7
7 Machine (Server) Queue (FIFO) Theoretical Result: Conservation of Time n n-1n-2... nn-1... n n n-1 n-2n-3... for each customer, his time in system = time in queue + service time ave. time in system = ave. time in queue + E(service time) tag nth customer
8
8 Sample-Path Results of a Queueing System state: N(t), number of customers in system N(t)N(t) t 6 10131723260 0 4 3 2 1 average # of customers up to t = 26:
9
9 Sample-Path Results of a Queueing System total length of rectangular boxes of the same color = waiting time of the corresponding customer in system average # in system = (arrival rate) (average waiting time)
10
10 Theoretical Result: Little ’ s Formula very general result for any system: L = w L = average # of customers in system = arrival rate of customers w = average time in system
11
11 Theoretical Result: Little ’ s Formula GI/G/1 queue the whole system average # in system = (arrival rate) (average time in system) the waiting queue as the system average # in queue = (arrival rate) (average time in queue) the server as the system utilization of server = (arrival rate) E(service time)
12
12 An Inventory System Day n demand of the Day n D n ~ Geo(0.1) at the beginning of Day n: update inventory if ordered quantity arrives lost sales, no back order $0.1 per unit on hand at the beginning of a day after receiving any outstanding order (Q, s) policy: order Q items at the end of a day if inventory on hand s at most one outstanding order leadtime of orders: equally likely to be 0 to 4 days (i.e., the ordered quantity can possibly arrive the next day) ordering cost: $20 per order penalty: $1 per piece lost
13
13 Inventory System inventory system inventory system definition of variables definition of variables definition of events definition of events pseudo code pseudo code flow chart flow chart Java program Java program
14
14 Simulating Complex Systems simple system (up to now) chess piece, machine, GI/G/1 queue, inventory system tailor-made programs for these problems complex problems generic program structure event scheduled by an event calendar
15
15 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 need to keep track of the timing of events
16
16 Conceptual Structure of an Event Calendar event: (time, type, tasks to do) event calendar: a link list with scheduled future 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)
17
17 Event Calendar of a Simulation Program Event. Cal. TNOW = 0: 1 24.3type 4 tasks to do 2 35.6type 1 tasks to do 3 41.3type 2 tasks to do 4 5000END End simulation
18
18 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation 24.3type 4 tasks to do 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation Event Calendar of a Simulation Program Event. Cal. move time to TNOW = 24.3 1 2 3 4 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation suppose that no new event is created by a type 4 event execute first event and update event calendar 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation TNOW = 0:
19
19 24.3type 4 tasks to do 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation Event Calendar of a Simulation Program Event. Cal. move time to TNOW = 24.3 1 2 3 4 suppose that a new event is created by an type 4 event at 39.1 execute first event and update event calendar TNOW = 0: 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation 39.1type 4 tasks to do 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation 39.1type 4 tasks to do 35.6type 1 tasks to do 41.3type 2 tasks to do 5000END End simulation 39.1type 4 tasks to do
20
20 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
21
21 A Crude Pseudo-Code of GI/G/1 Queue 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
22
22 An GI/G/1 Queue with the Event Calendar inter-arrival times ~ exp of mean 10 service times ~ exp of mean 5 Java Program Java Program
23
23 Simulation 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 busy time of station)
24
24 Input Data Initially (time 0) empty and idle Part NumberArrival TimeInterarrival TimeService Time 10.001.732.90 21.731.351.76 33.080.713.39 43.790.624.52 54.4114.284.46 618.690.704.36 719.3915.522.07 834.913.153.36 938.061.762.37 1039.821.005.38 11 40.82...... Stop when 20 minutes of (simulated) time have passed
25
25 hand simulation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.