Single Station Queuing System The MM1 System Q

  • Slides: 34
Download presentation
Single Station Queuing System -The M/M/1 System- Q 36954485 王俊彥 http: //myweb. ncku. edu.

Single Station Queuing System -The M/M/1 System- Q 36954485 王俊彥 http: //myweb. ncku. edu. tw/~q 3695448/article. htm 1

Outline n Kendall’s notation 5: 00 q n M/M/1 system 10: 00 q q

Outline n Kendall’s notation 5: 00 q n M/M/1 system 10: 00 q q q n Introduction Parameters setting Performance measures Simulation modeling 15: 00 q q q n Introduction Intuitive explanation C/C++ code Result References 5: 00 2

Kendall’s notation (A/B/m/K – Z) A/B/m/k–Z … servers Queueing Arrival discipline 1 process queue

Kendall’s notation (A/B/m/K – Z) A/B/m/k–Z … servers Queueing Arrival discipline 1 process queue Departing jobs m A Arrival Process B Service Process m Number of Servers k maximum # of customers in the system Z Queueing Discipline Explanation FCFS First-come-first-serviced M Exponential Distribution (memoryless) LCFS Last-come-first-served Ek Erlang Distribution with k phases RR Round-robin Hk Hyper. Exponential with k phases PS Processor sharing D Deterministic Distribution (constant) … Page 211 in textbook G General Distribution 3

Examples of Kendall’s notation n M / m / K -FCFS q n This

Examples of Kendall’s notation n M / m / K -FCFS q n 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 4

Performance measure n A queueing model represents a dynamic system, the performance measures vary

Performance measure n A queueing model represents a dynamic system, the performance measures vary with time. n Normally, however, we are content with results in steadystate (statistical equilibrium). q q q All transient behavior has ended The system has settled down The values of the performance measures are independent of time 5

Performance measure (cont. ) 6

Performance measure (cont. ) 6

Performance measure (cont. ) SYSTEM QUEUE servers SERVICE 1 … Arrival process queue Departing

Performance measure (cont. ) SYSTEM QUEUE servers SERVICE 1 … Arrival process queue Departing jobs m 7

M/M/1 performance measure n Recall that in this case, the arrival process is Poisson,

M/M/1 performance measure n Recall that in this case, the arrival process is Poisson, the service times are exponentially distributed, and there is a single server. n The system can be modeled as a birth-death process with birth rate (arrival rate) λ and death rate (service rate) μ. n The birth-death process is in the CH. 3 (eq. 3. 12) 8

Our simulation n For expository convenience, we assume that interarrival and service time of

Our simulation n 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 , …. q q S 1=2. 0 , S 2=0. 7 , S 3=0. 2 , S 4=1. 1 , S 5=3. 7 , S 6=0. 6 , …. q Unit-less 0. 4 1. 2 0. 5 1. 7 0. 2 1. 6 Time (unit) 0 0. 4 1. 6 2. 1 3. 8 4. 0 5. 6 10

Exponential random variable int main( ) // Example in C { double u=0, r=0;

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. 2 fn", r); return 0; } 11

Q(t) and B(t) Q(t) 3 2 1 0 0. 4 1. 6 2. 1

Q(t) and B(t) Q(t) 3 2 1 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 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 arrivals B(t) 1 0 12

Three quantities 13

Three quantities 13

Arrive state Depart state 14

Arrive state Depart state 14

Intuitive explanation : t=0 Initialization Time=0 n n n System state A D 0

Intuitive explanation : t=0 Initialization Time=0 n n n System state A D 0 0 Server status Number in queue Time Of last event Time Of arrival clock 0 0 Number delayed Total delay 0. 4 ∞ Event list 0 0 Area Under Q(t) Under B(t) 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. 15

Intuitive explanation : t=0. 4 Initialization Time=0. 4 n n n System state A

Intuitive explanation : t=0. 4 Initialization Time=0. 4 n n n System state A D 0. 4 1 0 0. 4 Server status Number in queue Time Of last event Time Of arrival clock 1 0 Number delayed Total delay 1. 6 2. 4 Event list 0 0 Area Under Q(t) Under B(t) Number delayed Server status Event list □ ○ 16

Intuitive explanation : t=1. 6 Initialization Time=1. 6 System state 1. 6 n n

Intuitive explanation : t=1. 6 Initialization Time=1. 6 System state 1. 6 n n n 0. 4 1 1 1. 6 Server status Number in queue Time Of last event Time Of arrival A D clock 1 0 Number delayed Total delay 2. 1 2. 4 Event list 0 1. 2 Area Under Q(t) Under B(t) Area under B(t) Number in queue Time of arrival 17

Intuitive explanation : t=2. 1 Initialization Time=2. 1 System state 0. 4 1 2

Intuitive explanation : t=2. 1 Initialization Time=2. 1 System state 0. 4 1 2 1. 6 Server status Number in queue 2. 1 n 1. 6 2. 1 Time Of arrival A D 2. 1 clock 2. 1 Time Of last event 1 0 Number delayed Total delay 3. 8 2. 4 Event list 0. 5 1. 7 Area Under Q(t) Under B(t) Area under Q(t) 18

Intuitive explanation : t=2. 4 Initialization Time=2. 4 System state 2. 4 2. 1

Intuitive explanation : t=2. 4 Initialization Time=2. 4 System state 2. 4 2. 1 n n 1. 6 1 1 2. 4 2. 1 Server status Number in queue Time Of last event Time Of arrival clock 2 0. 8 Number delayed Total delay A D 3. 8 3. 1 Event list 1. 1 2. 0 Area Under Q(t) Under B(t) Number delayed Total delay 19

Intuitive explanation : t=3. 1 & t=3. 3 Initialization Time=3. 1 2. 1 System

Intuitive explanation : t=3. 1 & t=3. 3 Initialization Time=3. 1 2. 1 System state 3. 1 1 0 3. 1 Server status Number in queue Time Of last event Initialization Time=3. 3 Time Of arrival clock 3 1. 8 Number delayed Total delay System state 3. 3 0 0 3. 3 Server status Number in queue Time Of last event Time Of arrival A D clock 3 1. 8 Number delayed Total delay 3. 8 3. 3 Event list 1. 8 2. 7 Area Under Q(t) Under B(t) A D 0. 4 ∞ Event list 1. 8 2. 9 Area Under Q(t) Under B(t) 20

Intuitive explanation : t=3. 8 & t=4. 0 Initialization Time=3. 8 System state 3.

Intuitive explanation : t=3. 8 & t=4. 0 Initialization Time=3. 8 System state 3. 8 1 0 3. 8 Server status Number in queue Time Of last event Initialization Time=4. 0 Time Of arrival clock 4 1. 8 Number delayed Total delay System state 4. 0 3. 8 1 1 4. 0 Server status Number in queue Time Of last event Time Of arrival A D clock 4 1. 8 Number delayed Total delay 4. 0 4. 9 Event list 1. 8 2. 9 Area Under Q(t) Under B(t) A D 5. 6 4. 9 Event list 1. 8 3. 1 Area Under Q(t) Under B(t) 21

Intuitive explanation : t=4. 9 & t=5. 6 Initialization Time=4. 9 4. 0 System

Intuitive explanation : t=4. 9 & t=5. 6 Initialization Time=4. 9 4. 0 System state 4. 9 1 0 4. 9 Server status Number in queue Time Of last event Initialization Time=5. 6 Time Of arrival clock 5 2. 7 Number delayed Total delay System state 5. 6 4. 0 1 1 5. 6 Server status Number in queue Time Of last event Time Of arrival A D clock 5 2. 7 Number delayed Total delay 5. 6 8. 6 Event list 2. 7 4. 0 Area Under Q(t) Under B(t) A D 5. 8 8. 6 Event list 2. 7 4. 7 Area Under Q(t) Under B(t) 22

Intuitive explanation : t=5. 8 & t=7. 2 Initialization Time=5. 8 System state 4.

Intuitive explanation : t=5. 8 & t=7. 2 Initialization Time=5. 8 System state 4. 0 1 2 5. 6 Server status Number in queue 5. 8 Initialization Time=7. 2 4. 0 5. 6 5. 8 7. 2 5. 6 5. 8 Time Of arrival 5. 8 clock 5. 8 Time Of last event 5 2. 7 Number delayed Total delay System state 1 3 Server status Number in queue 5. 6 5. 8 7. 2 Time Of arrival 7. 2 clock 7. 2 Time Of last event A D 5 2. 7 Number delayed Total delay 7. 2 8. 6 Event list 2. 9 4. 9 Area Under Q(t) Under B(t) A D 9. 1 8. 6 Event list 5. 7 6. 3 Area Under Q(t) Under B(t) 23

Intuitive explanation : t=8. 6 Initialization Time=8. 6 System state 5. 6 1 2

Intuitive explanation : t=8. 6 Initialization Time=8. 6 System state 5. 6 1 2 5. 8 Server status Number in queue 7. 2 5. 8 7. 2 Time Of arrival 8. 6 clock 8. 6 Time Of last event 6 5. 7 Number delayed Total delay A D 9. 1 9. 2 Event list 9. 9 7. 7 Area Under Q(t) Under B(t) 24

C/C++ code – include & parameters #include <stdio. h> #include <math. h> #include "lcgrand.

C/C++ code – include & parameters #include <stdio. h> #include <math. h> #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); 25

C/C++ code – main function main() /* Main function. */ { infile = fopen("mm

C/C++ code – main function main() /* Main function. */ { infile = fopen("mm 1. in", "r"); outfile = fopen("mm 1. 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; } 26

C/C++ code – initialize function void initialize(void) /* Initialization function. */ { sim_time =

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. 0 e+30; } 27

C/C++ code – timing function void timing(void) /* Timing function. */ { int i;

C/C++ code – timing function void timing(void) /* Timing function. */ { int i; float min_time_next_event = 1. 0 e+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, "n. Event list empty at time %f", sim_time); exit(1); } sim_time = min_time_next_event; } 28

C/C++ code – arrive function void arrive(void) /* Arrival event function. */ { float

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, "n. Overflow 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); } } 29

C/C++ code – depart function void depart(void) /* Departure event function. */ { int

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. 0 e+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]; } } 30

Arrive state Depart state 31

Arrive state Depart state 31

C/C++ code – update_time_avg_state & expon function void update_time_avg_stats(void) { float time_since_last_event; time_since_last_event =

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); } 32

References n Java q http: //www. nirarebakun. com/queue/emati. html q n C/C++ & FORTRAN

References n Java q http: //www. nirarebakun. com/queue/emati. html q n C/C++ & FORTRAN q http: //www. mhhe. com/engcs/industrial/lawkelton/index. mhtml 33

Q&A http: //myweb. ncku. edu. tw/~q 3695448/article. htm 34

Q&A http: //myweb. ncku. edu. tw/~q 3695448/article. htm 34