IOE 202: lectures 11 and 12 outline Announcements Last time... Queueing models intro Performance characteristics of a queueing system Steady state analysis of an M/M/1 queueing system Other queueing systems, including M/M/s and M/M/s/s Cost analysis of queueing systems IOE 202: Operations Modeling, Fall 2009 Page 1 Last time: characterizing behavior of uncertain continuous quantities Characterization through range of possible values and probability density function over that range Probability of taking on a particular value is 0 Probability of taking on a value in a given range equals to the integral of the density function over this range. Examples of 3 important distributions of continuous r.v. s: Uniform (U(a, b)) everything between a and b equally likely Normal (N(µ, σ)) known quantilies in terms of standard deviations Exponential (Exponential with rate λ) memoryless! IOE 202: Operations Modeling, Fall 2009 Page 2
Queues and queueing models Waiting in line: in a bank, a store, toll booth, traffic light Submitting jobs to a server, or to a printer, or to a repair shop One purpose of building queueing models is to analyze an existing system to quantify its performance characteristics (such as the average waiting time, average number of customers in line, what fraction of the servers are busy, etc.) Another purpose is to explore how the system can be made better Analysis of queueing systems sometimes can be performed analytically; sometimes, simulation analysis is needed. In the forthcoming lectures, we will mostly focus on the systems for which analytical results are available; however, they are too complicated to be derived from first principles, so a lot of formulas will be given, not derived... IOE 202: Operations Modeling, Fall 2009 Page 3 A very simple queueing system Jobs are submitted to the computer server every 15 seconds. It takes the server exactly 13 seconds to process each job; jobs are executed in order of submission, one at a time. 1. How long does a job wait to start? 2. At any given time, how many jobs are waiting in the queue? 3. What fraction of the time is the server busy? 4. The activity monitor displays IDs of the next 8 jobs to be processed (after the current job is completed). What fraction of the time is there room on this list? 5. Assuming the number of jobs submitted to the server is not going to change in the near future, is it worthwhile to replace it with a faster server? 6. What if the server is slower than usual, and so takes 14 seconds to complete each job? IOE 202: Operations Modeling, Fall 2009 Page 4
A more complicated queueing system Jobs are submitted to the computer server, on average, every 15 seconds; theinterarrivaltimesareexponentially distributed. The time the server spends on each job is exponentially distributed, with the mean of 13 seconds. 1. How long does a job wait to start? 2. At any given time, how many jobs are waiting in the queue? 3. What fraction of the time is the server busy? 4. The activity monitor displays IDs of the next 8 jobs to be processed. What fraction of the time is there room on this list? 5. Assuming the number of jobs submitted to the server is not going to change in the near future, is it worthwhile to replace it with another server? 6. What if the server is slower than usual, and so takes on average 14 seconds to complete each job? IOE 202: Operations Modeling, Fall 2009 Page 5 Spreadsheet simulation model for the server problem Recall: an exponentially distributed random variable with rate α has mean 1 α For job k =1, 2, 3, 4,..., let us denote by... T (k) the interarrival time, i.e., the time between arrivals of (k 1)st and kth jobs, exponentials with parameter λ =1/15 S(k) the time the job takes to execute, exponentials with parameter µ = 1/13 Note: W (k) =W q (k)+s(k), where W q (k) timethekth job spends waiting W (k) total time the kth job spends in the system Also note: W q (k) =max(0, W (k 1) T (k)). To see why this is true: (k 1)st job spends a total of W (k 1) sec in the system The kth job arrives T (k) secafterthe(k 1)st job does If W (k 1) T (k) sec,kth job does not have to wait at all If W (k 1) > T (k) sec,kth job has to wait W (k 1) T (k) secinthequeue IOE 202: Operations Modeling, Fall 2009 Page 6
Impact of uncertainty on the queue Uncertainty/variability in Times between arrivals of successive jobs, and Service times required by the jobs has a profound effect on the performance of the queueing system, seen through Variability of waiting times and total times spend in the system by each job Fluctuation of the length of the queue and overall number of jobs in the system over time We observed in the simulation of the computer server that, over a long observation period, the system shows a long-run behavioral pattern (e.g., every once in a while, the queue empties, etc.) IOE 202: Operations Modeling, Fall 2009 Page 7 Short-run vs. steady-state (long-run) behavior Example: line at Quiznos starting at noon For the next 15 or 30 minutes short-run After 2 PM steady state To distinguish, consider whether initial conditions affect the average behavior. If no significant effect is observed, steady-state performance is being observed. Suppose one day a group of 15 visiting HS students is taken to buy lunch at Quiznos at 11:50 On that day, the average queue length between noon at 12:30 is much larger than on a typical day Average queue length between noon at 6 PM is about the same as on a typical day Requirements for a system to reach steady state: Parameters of the system remain constant System is stable, i.e., on average, the servers are fast enough to keep up with arrivals. IOE 202: Operations Modeling, Fall 2009 Page 8
Average performance measures The performance of a queueing system in steady state can be summarized through averages. For instance, one could ask On average, how long is the line at Quiznos in the afternoon? On average, how often are the cashiers at Quiznos doing nothing, because there are no customers? On average, how long would I have to wait in line if I go to Quiznos in the afternoon? IOE 202: Operations Modeling, Fall 2009 Page 9 Performance measures for a stable system in steady state: Time averages L Q, the average/expected number of jobs in the queue L Sys, the average/expected number of jobs in the system L Serv, the average/expected number of jobs in service P(busy), probability/fraction of time that the server is busy, etc. To estimate these from empirical observations, check the system at many points in time, record the observed data at each point in time (e.g., how many jobs are in the queue, or whether or not the server busy), and take the average these numbers. I.e., you are computing the average over time. IOE 202: Operations Modeling, Fall 2009 Page 10
Performance measures for a stable system in steady state: Job averages W Q, the average/expected time a job waits in the queue W Sys, the average/expected time a job spends in the system W Serv, the average/expected time a customer spends in service, etc. To estimate these from empirical observations, observe many jobs, record the observed data for each job (e.g., time in the queue), and average these numbers. I.e., you are computing the average over jobs. IOE 202: Operations Modeling, Fall 2009 Page 11 The basic single-server model, a.k.a. the M/M/1 model The first M: interarrival times is exponentially distributed, hence the arrival process is memoryless Arrival rate denoted by λ (that is, 1/λ is the avg. time between arrivals) The second M: service times are exponentially distributed, hence memoryless Service rate is denoted by µ (that is, on average, it takes 1/µ units of time to perform a job) The 1 indicates that there is a single server. ρ = λ µ is the server utilization for M/M/1 queue. If ρ > 1, the arrivals are more frequent than the service completions (i.e., the departures), and the queue will get more and more full. Hence, for an M/M/1 queueing system to be stable in the long run it is necessary (and sufficient) that ρ < 1. IOE 202: Operations Modeling, Fall 2009 Page 12
Intuition behind steady-state analysis of M/M/1 queue At any point in time, the number of customers in the system, n, completely characterizes what s going on! (Exponential service and interarrival times are crucial.) Hence, we refer to n as the state of the system. With the system in steady state, let P n denote the probability that there are n customers in the system. In other words, P n is the fraction of time, over a long horizon, the system spends in state n. When the system is in state n, thenexttimethesystemwill change state, it will transition either into state n + 1, or, if n > 0, into n 1. IOE 202: Operations Modeling, Fall 2009 Page 13 State transition diagram for an M/M/1 queue In steady state, the net flux across the line separating state n 1 and state n is equal to zero, i.e., λp 0 = µp 1, λp 1 = µp 2,, λp n = µp n+1, From probability laws: P n =1 n=0 Solving the above system of equations, we obtain: P n =(1 ρ)ρ n, n =0, 1, 2,... IOE 202: Operations Modeling, Fall 2009 Page 14
Steady state analysis of an M/M/1 queue I Assume ρ = λ µ < 1. Solving the above equations, we obtain: P n =(1 ρ)ρ n, n =0, 1, 2,... L Sys = n=0 np n = ρ 1 ρ L Q = n=1 (n 1)P n = ρ2 1 ρ L Serv =0 P 0 +1 (1 P 0 )=ρ IOE 202: Operations Modeling, Fall 2009 Page 15 Little s Formula(s) and other relationships Holds for all queues in steady state, not just M/M/1 Consider any queueing system. We have: L Sys = L Q + L Serv, W Sys = W Q + W Serv, Little s law: If arrival rate to a queueing system is λ, andthe system is in steady state, then L Sys = λw Sys, L Q = λw Q, L Serv = λw Serv Reasoning: Consider a long period of time T. During this period of time, we expect about λt customers to arrive, each waiting in the queue for an average time W Q. Hence, the average number of customer-minutes spent in line is λtw Q. On the other hand, the average number of customer-minutes spent in the queue can be also computed as TL Q. IOE 202: Operations Modeling, Fall 2009 Page 16
Steady state analysis of an M/M/1 queue II Notice: L Sys L Serv = ρ 1 ρ ρ2 1 ρ = ρ = L Serv Also, using Little s law: W Sys = L Sys λ = 1 µ λ, W Q = L Q λ = λ µ(µ λ) IOE 202: Operations Modeling, Fall 2009 Page 17 Back to our computer server... Suppose the interarrival and service times are exponential, with λ =1/15 jobs per second (or 4 jobs per minute), and µ =1/13 jobs per second (or 4.62 jobs per minute). Note: ρ = 13 15 < 1 How long does a job wait to start (on average)? How many jobs, on average, are waiting in the queue, at any given time? What fraction of the time is the server busy? IOE 202: Operations Modeling, Fall 2009 Page 18
Computer server example continued... The activity monitor displays IDs of the next 8 jobs to be processed. What fraction of the time is there room on this list? There is no room on the activity monitor when there are 9 or more jobs in the system the probability of this happening is P 9 + P 10 + P 11 + =(1 ρ)ρ 9 +(1 ρ)ρ 10 +(1 ρ)ρ 11 + =(1 ρ)ρ 9 (1 + ρ + ρ 2 + ) = ρ 9 Thus, there is room on the monitor 1 Prob(n 9) = 1 ρ 9 fraction of the time IOE 202: Operations Modeling, Fall 2009 Page 19 Computer server example continued... What if the server is slower than usual, and so takes an average of 14 seconds to complete each job? Determine the values of λ, µ, and ρ. Answer same questions for the new values 1/µ =13 sec 1/µ =14 sec W Q 84.5 sec L Q 5.633 jobs 1 P 0 0.867 1 Prob(n 9) 0.724 IOE 202: Operations Modeling, Fall 2009 Page 20
System performance vs. server utilization Recall: L Q = λw Q = λ λ µ(µ λ) = ρ2 (1 ρ) )$!./01230456060470839:42;424<68=9>?84?<4;01/01469>7>@29>?84?<4284ABAB)4;C;90D )*$ )+! )!$, - E + BF) G (!, - &$ %! #$ *! )$!!"#!"$!"%!"&!"'!"( ) IOE 202: Operations Modeling, Fall 2009 Page 21 When is an M/M/1 model of a queueing system appropriate? Customers arrive one at a time Inter-arrival times are uncertain, with average time 1/λ between arrivals independent of each other and can be modeled as exponential random variables with rate λ All customers join the line and wait for service Any number of waiting customers can be accommodated Customers form one line and are served FCFS There is one server, serving one customer at a time Service times of customers are uncertain, with average 1/µ independent of each other and can be modeled as exponential random variables with rate µ IOE 202: Operations Modeling, Fall 2009 Page 22
Other types of queueing systems (would require different models!) Arrivals and customer behavior: Timing of arrivals: inter-arrival times may not fit exponential distribution Customers may be arriving in batches Some arriving customers may balk and not join the queue, while some customers may renege System may be able to accommodate only a limited number of waiting customers Service: Service times may not fit exponential distribution Queue discipline There may be multiple servers Order of serving customers may be Shortest processing time first (SPT), based on priority level Also, if there are several servers, do customers form one line, or multiple lines? (Supermarket vs. airline check-in counter) IOE 202: Operations Modeling, Fall 2009 Page 23 The basic multiple-server model, a.k.a. M/M/s model Arrivals and waiting the same as in M/M/1: The first M: inter-arrival times are exponentially distributed with rate λ The second M: service time of each customer on either server is exponentially distributed with rate µ The s indicates that there are s servers. The servers are identical and work in parallel; first customer in line goes to the next available server ρ = λ sµ is the server utilization. Ifρ > 1, the arrivals are more frequent than the service completions (i.e., the departures), and the queue will get more and more full. Hence, for an M/M/s queueing system to be stable it is necessary (and sufficient) that ρ < 1. Formulae for many output measures for an M/M/s queue in steady state are available; see handout and the file MMS TEMPLATE.XLS (make sure to enable macros). IOE 202: Operations Modeling, Fall 2009 Page 24
Example: a dual processor? IOE s computer system manager has been receiving complaints from students and faculty using the departmental server. They claim it frequently takes too long to run a computer job! Currently, the server functions as an M/M/1 queue with λ = 1 15 and µ = 1 13 jobs per second. The system manager has limited funds for upgrading the system. He identified the only option: exchange the current server for one with a dual processor, which would increase computer operating costs by $200 per hour. Average job completion time on either of the two processors is 20 seconds, and each processor can work on one job independently. System manager (who has an MSE from IOE!) estimated that user s time is worth $0.02 per second of waiting for a job to complete. Should he change computers? What if this estimate is inaccurate? IOE 202: Operations Modeling, Fall 2009 Page 25 ρ One processor or two? λ = 1 15 M/M/1 with µ = 1 13 M/M/2 with µ = 1 20 W Sys W Q L Sys L Q IOE 202: Operations Modeling, Fall 2009 Page 26
One processor or two? Continued Formula for computing total cost (per unit of time): Total cost with the old server: Total cost with the new server: Sensitivity analysis w.r.t. value of user s time: IOE 202: Operations Modeling, Fall 2009 Page 27 No waiting room, a.k.a. M/M/s/s queueing model This model represents a system with exponential inter-arrival and service times, s identical servers, and no waiting room. The fourth parameter indicates how many customers can be in the system; since it is equal to the number of servers, there is no waiting room. In previous models, the number of customers was not limited, so the fourth parameter was omitted. Technically, they were M/M/1/ and M/M/s/ models. More generally, one may consider an M/M/s/K system, e.g., acallcenterwiths operators and K trunk lines, so that up to K s customers can be put on hold simultaneously. IOE 202: Operations Modeling, Fall 2009 Page 28
State transition diagram for an M/M/s/s queue Let P n =probability that there are n customers in the system. Notice: the system is always stable, because its size is limited! In steady state, the net flux across the line separating state n 1 and state n is equal to zero. Equations: λp 0 = µp 1, λp 1 =2µP 2, λp 2 =3µP 3,, λp s 1 = sµp s, s P n =1 n=0 IOE 202: Operations Modeling, Fall 2009 Page 29 Formulae for an M/M/s/s system in steady state Solving above system of equations, P n = λn n!µ n P 0, n =0, 1,...,s, where P 0 = 1+ s n=1 1 λ n n!µ n. For example, if s = 3, λ =1andµ = 2, then we can calculate P 0 = 1+ 1 1! 2 + 1 2! 2 2 + 1 1 3! 2 3 = 48 79 =0.608, P 1 = 1 2 P 0 =0.304, P 2 = 1 2! 2 2 P 0 =0.076, P 3 = 1 3! 2 3 P 0 =0.013 IOE 202: Operations Modeling, Fall 2009 Page 30
M/M/s/s formulae continued In the above example, approximately 61% of the time, there is noone in the system, 30% of the time there is 1 customer, 8% of the time there are 2 customers, and only 1% of the time there are 3 customers in the system. We can now figure out the measures of system performance such as Mean number of customers in the system L Sys = s n=1 np n = 39 79 Mean number of customers in the line L Q =0 Probability that an arriving customer will find a full system (and thus will be lost) = P 3 =1.3%. IOE 202: Operations Modeling, Fall 2009 Page 31 Example: how many servers to install? A startup company is trying to decide how many satellite phone channels (or lines) to lease. It costs $144 to lease a line for each day of operation. Calls arrive at a rate of 600 per hour, and if an arriving call finds that all lines are busy, the caller hangs up and doesn t try again. On average, a call lasts 4 minutes, and calls are billed at $1 each. How many lines should be leased to maximize profits? IOE 202: Operations Modeling, Fall 2009 Page 32
Decision variable: Formulating as a decision problem Appropriate model for the system: Costs incurred by the system: Revenues collected by the system: IOE 202: Operations Modeling, Fall 2009 Page 33 Solution of the decision problem Model: M/M/s/s queue Decision variable: s > 0 Inputs: λ = 10 calls per minute, µ =0.25 calls per minute Profit: 10(1 P s ) 0.1s per minute. Using a spreadsheet, we calculate P s and the corresponding profit for a variety of values of s. Profit is maximized at s = 45, and is equal to $4.96 per minute. IOE 202: Operations Modeling, Fall 2009 Page 34