Download presentation
Presentation is loading. Please wait.
1
1 Single Station Queuing System Single Station Queuing System - The M/M/1 System- Q36954485 王俊彥 http://myweb.ncku.edu.tw/~q3695448/article.htm
2
2 Outline Kendall’s notation 5:00 Introduction M/M/1 system 10:00 Introduction Parameters setting Performance measures Simulation modeling 15:00 Intuitive explanation C/C++ code Result References 5:00
3
3 Kendall ’ s notation (A/B/m/K – Z) A / B / m / k – Z A Arrival Process B Service Process m Number of Servers k maximum # of customers in the system Z Queueing Discipline Explanation M Exponential Distribution (memoryless) EkEk Erlang Distribution with k phases HkHk HyperExponential with k phases D Deterministic Distribution (constant) G General Distribution 1 m … Arrival process queue servers Departing jobs Queueing discipline Queueing Discipline FCFS First-come-first-serviced LCFS Last-come-first-served RR Round-robin PS Processor sharing … Page 211 in textbook
4
4 Examples of Kendall ’ s notation M / M / m / K -FCFS This would describe a queueing system with an exponential distribution for the interarrival times of customers and the service times of customers, m servers, a maximum of K customers in the queueing system at once, and First-come-first-served for queueing discipline. To practice : M/G/5/K-LCFS
5
5 Performance measure A queueing model represents a dynamic system, the performance measures vary with time. Normally, however, we are content with results in steady-state (statistical equilibrium). All transient behavior has ended The system has settled down The values of the performance measures are independent of time
6
6 Performance measure (cont.)
7
7 1 m … Arrival process queue servers Departing jobs QUEUESERVICE SYSTEM
8
8 M/M/1 performance measure Recall that in this case, the arrival process is Poisson, the service times are exponentially distributed, and there is a single server. The system can be modeled as a birth-death process with birth rate (arrival rate) λ and death rate (service rate) μ. The birth-death process is in the CH.3 (eq. 3.12)
9
9 M/M/1 performance measure (cont.) p214 ρ=(1/2), 把它看成進入率與 輸出率都相同,卻有 2 個 servers 。所以有 jobs 在佇 列的機會不高。 server 比較忙, 在整個系統 排隊的人就多。 server 比較閒, 在整個系統 排隊的人就少。
10
10 Our simulation For expository convenience, we assume that interarrival and service time of customers are below : A 1 =0.4, A 2 =1.2, A 3 =0.5, A 4 =1.7, A 5 =0.2, A 6 =1.6, A 7 =0.2, A 8 =1.4, A 9 =1.9, …. S 1 =2.0, S 2 =0.7, S 3 =0.2, S 4 =1.1, S 5 =3.7, S 6 =0.6, …. Unit-less Time (unit) 0.4 1.2 0.5 1.7 0.2 1.6 0 0.4 1.6 2.1 3.8 4.0 5.6
11
11 Exponential random variable int main( ) // Example in C { double u=0, r=0; int mean=2; srand(time(NULL)); u=(double)(1+rand()%100)/(double)100; r=-mean*log(u); printf("r=%2.2f\n", r); return 0; }
12
12 Q(t) and B(t) 0 0.4 1.6 2.1 2.4 3.1 3.3 3.8 4.0 4.9 5.6 5.8 7.2 8.6 arrivals departures 0 0.4 1.6 2.1 2.4 3.1 3.3 3.8 4.0 4.9 5.6 5.8 7.2 8.6 1 2 3 Q(t) B(t) 1 0
13
13 Three quantities
14
14 Depart state Arrive state
15
15 Intuitive explanation : t=0 t=0 : initialization Our modeling assumption was initially the system is empty of customs and the server is idle (idle=0 & busy=1). And number of customs in queue is 0. The event list give the times of next occurrence in A and departure time in D. Initialization Time=0 000 0 0000 System state Server status Number in queue Time Of arrival Time Of last event 0.4 ∞ clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD
16
16 Intuitive explanation : t=0.4 Number delayed Server status Event list □ ○ Initialization Time=0.4 1 00.4 1 000 System state Server status Number in queue Time Of arrival Time Of last event 1.6 2.4 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 0.4
17
17 Intuitive explanation : t=1.6 Area under B(t) Number in queue Time of arrival Initialization Time=1.6 1 1 1.6 100 1.2 System state Server status Number in queue Time Of arrival Time Of last event 2.1 2.4 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 0.4 1.6
18
18 Intuitive explanation : t=2.1 Area under Q(t) 0.4 Initialization Time=2.1 12 1.6 2.1 10 0.5 1.7 System state Server status Number in queue Time Of arrival Time Of last event 3.8 2.4 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 1.6 2.1
19
19 Intuitive explanation : t=2.4 Number delayed Total delay Initialization Time=2.4 11 2.1 2.4 20.8 1.12.0 System state Server status Number in queue Time Of arrival Time Of last event 3.8 3.1 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 1.6 2.1
20
20 Intuitive explanation : t=3.1 & t=3.3 Initialization Time=3.1 103.1 31.8 2.7 System state Server status Number in queue Time Of arrival Time Of last event 3.8 3.3 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD Initialization Time=3.3 003.3 31.8 2.9 System state Server status Number in queue Time Of arrival Time Of last event 0.4 ∞ clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 2.1
21
21 Intuitive explanation : t=3.8 & t=4.0 Initialization Time=3.8 103.8 41.8 2.9 System state Server status Number in queue Time Of arrival Time Of last event 4.0 4.9 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD Initialization Time=4.0 11 4.0 41.8 3.1 System state Server status Number in queue Time Of arrival Time Of last event 5.6 4.9 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 3.8 4.0
22
22 Intuitive explanation : t=4.9 & t=5.6 Initialization Time=4.9 104.9 52.7 4.0 System state Server status Number in queue Time Of arrival Time Of last event 5.6 8.6 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD Initialization Time=5.6 11 5.6 52.7 4.7 System state Server status Number in queue Time Of arrival Time Of last event 5.8 8.6 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 4.0 5.6
23
23 Intuitive explanation : t=5.8 & t=7.2 Initialization Time=5.8 12 5.6 5.8 52.72.94.9 System state Server status Number in queue Time Of arrival Time Of last event 7.2 8.6 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD Initialization Time=7.2 13 5.6 5.8 7.2 52.75.76.3 System state Server status Number in queue Time Of arrival Time Of last event 9.1 8.6 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 4.0 5.6 5.8 4.0 5.6 5.8 7.2
24
24 Intuitive explanation : t=8.6 Initialization Time=8.6 12 5.8 7.2 8.6 65.79.97.7 System state Server status Number in queue Time Of arrival Time Of last event 9.1 9.2 clockEvent list Number delayed Total delay Area Under Q(t) Area Under B(t) ADAD 5.6 5.8 7.2
25
25 C/C++ code – include & parameters #include #include "lcgrand.h" /* Header file for random-number generator. */ #define Q_LIMIT 100 /* Limit on queue length. */ #define BUSY 1 /* Mnemonics for server's being busy */ #define IDLE 0 /* and idle. */ int next_event_type, num_custs_delayed, num_delays_required, num_events, num_in_q, server_status; float area_num_in_q, area_server_status, mean_interarrival, mean_service, sim_time, time_arrival[Q_LIMIT + 1], time_last_event, time_next_event[3], total_of_delays; FILE *infile, *outfile; void initialize(void); void timing(void); void arrive(void); void depart(void); void report(void); void update_time_avg_stats(void); float expon(float mean);
26
26 C/C++ code – main function main() /* Main function. */ { infile = fopen("mm1.in", "r"); outfile = fopen("mm1.out", "w"); num_events = 2; initialize( ); while (num_custs_delayed < num_delays_required) { timing( ); update_time_avg_stats( ); switch (next_event_type) { case 1: arrive( ); break; case 2: depart( ); break; } report( ); fclose(infile); fclose(outfile); return 0; }
27
27 C/C++ code – initialize function void initialize(void) /* Initialization function. */ { sim_time = 0.0; server_status = IDLE; num_in_q = 0; time_last_event = 0.0; /* Initialize the statistical counters. */ num_custs_delayed = 0; total_of_delays = 0.0; area_num_in_q = 0.0; area_server_status = 0.0; /* Initialize event list. Since no customers are present, the departure (service completion) event is eliminated from consideration. */ time_next_event[1] = sim_time + expon(mean_interarrival); time_next_event[2] = 1.0e+30; }
28
28 C/C++ code – timing function void timing(void) /* Timing function. */ { int i; float min_time_next_event = 1.0e+29; next_event_type = 0; for (i = 1; i <= num_events; ++i) if (time_next_event[i] < min_time_next_event) { min_time_next_event = time_next_event[i]; next_event_type = i; } if (next_event_type == 0) { fprintf(outfile, "\nEvent list empty at time %f", sim_time); exit(1); } sim_time = min_time_next_event; }
29
29 C/C++ code – arrive function void arrive(void) /* Arrival event function. */ { float delay; time_next_event[1] = sim_time + expon(mean_interarrival); if (server_status == BUSY) { ++num_in_q; if (num_in_q > Q_LIMIT) { fprintf(outfile, "\nOverflow of the array time_arrival at"); fprintf(outfile, " time %f", sim_time); exit(2); } time_arrival[num_in_q] = sim_time; } else { delay = 0.0; total_of_delays += delay; ++num_custs_delayed; server_status = BUSY; time_next_event[2] = sim_time + expon(mean_service); }
30
30 C/C++ code – depart function void depart(void) /* Departure event function. */ { int i; float delay; if (num_in_q == 0) { server_status = IDLE; time_next_event[2] = 1.0e+30; } else { --num_in_q; delay = sim_time - time_arrival[1]; total_of_delays += delay; ++num_custs_delayed; time_next_event[2] = sim_time + expon(mean_service); for (i = 1; i <= num_in_q; ++i) time_arrival[i] = time_arrival[i + 1]; }
31
31 Depart state Arrive state
32
32 C/C++ code – update_time_avg_state & expon function void update_time_avg_stats(void) { float time_since_last_event; time_since_last_event = sim_time - time_last_event; time_last_event = sim_time; area_num_in_q += num_in_q * time_since_last_event; area_server_status += server_status * time_since_last_event; } float expon(float mean) /* Exponential variate generation function. */ { /* Return an exponential random variate with mean "mean". */ float u; u=rand (1); return -mean * log(u); }
33
33 References Java http://www.nirarebakun.com/queue/emati.html C/C++ & FORTRAN http://www.mhhe.com/engcs/industrial/lawkelton/index.mhtml
34
34 Q&A http://myweb.ncku.edu.tw/~q3695448/article.htm
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.