Why Wait?!? Bryan Gorney Joe Walker Dave Mertz Josh Staidl Matt Boche Purpose: To minimize costs of businesses with waiting lines, taking into consideration the cost of servers and the long-run loss of revenue by making customers wait too long. Outline: I. Rudiments of Queuing Theory a. 1 Customer, 1 Server b. Many Customer, No Server c. Many Customers, 1 Server II. Concept of a Stationary Distribution III. Traffic Intensity a. Average Queue Length b. Little’s Principle c. Average Waiting Time IV. Store Profit Maximization 1 Customer, 1 Server • • • • N(t) = number of individuals at checkout counter at time t. N(t) has only two possible values of 0 or 1. “being served” corresponds to N(t) = 1. “finished being served” corresponds to N(t) = 0. To obtain the time-dependent transition probabilities for this Markov chain, let Xt = ( ) p(t) q(t) be the time-dependent distribution vector for the states “being served” and “finished being served”. That is, p(t) = P[N(t) = 1] and q(t) = P[N(t) = 0] • q(t) = 1 – p(t) • lim p(t) = 0 t ∞ lim Xt = t ∞ () 0 1 State diagram µ∆t 1 0 1 − µ∆t P[service is completed in ∆t] = µ∆t P[service is not completed in ∆t] = 1 – µ∆t 1 The transition matrix for each ∆t time step is given by A= ( 1 – µ∆t 0 µ∆t 1 ) Thus, Xt+∆t = AXt which in matrix form gives: ( p(t + ∆t) q(t + ∆t) )=( 1 – µ∆t 0 µ∆t )( ) 1 p(t) q(t) Performing matrix multiplication yields: p(t + ∆t) = (1 – µ∆t)p(t) Rearranging so difference quotient is on the left-hand side: p(t + ∆t) – p(t) ∆t = -µp(t) By letting ∆t go to zero, the difference quotient becomes a derivative, and p’(t) = lim ∆t 0 p(t + ∆t) – p(t) ∆t = -µp(t) This is the exponential differential equation with solution: p(t) = P[N(t) = 1] = p0e-µt Since we assumed that there is an individual initially being served, N(0) = 1. This implies that p(0) = 1 which gives p0 = 1. Finally we have: p(t) = P[N(t) = 1] = e-µt Since q(t) = 1 – p(t), the probability of completing the service is: q(t) = 1 – e-µt • Next let T denote the time at which service is completed. It is considered to be the time until transition from one state to another. • T is a continuous random variable with range 0 < T < ∞. • P[T > t] = P[N(t) = 1]. • P[T < t] = 1 – e-µt (complement). • Left-hand side = cumulative distribution function of the continuous random variable T. • Right-hand side = exponential distribution. P[T > s + t given T > s] = P[T > t] (Memoryless property) for all s,t > 0. Density function is the derivative of the cumulative distribution which is: f(t) = d P[T < t] = µe-µt, 0 < t < ∞. dt 1 E(T) = tf(t)dt = tµe-µtdt = µ 0 0 ∞ ∞ 1 Thus the average value of T is µ . We interpret the service rate µ as: µ= 1 Mean Time Until Transition Many Customers, No Server Let N(t) be a time dependent function that denotes the number of customer arrivals in a given interval [0,t], and assume the following: 1. The probability that an arrival occurs in a short interval [t, t+∆t] is proportional to the length of the interval ∆t. In symbols: P[ N(t+∆t) - N(t) = 1] = λ∆t for some constant λ >0. 2. The Memoryless Property: The probability that an arrival occurs in [t, t+∆t] does not depend on the time of previous arrivals: P[ N(t+∆t) – N(t) = n | N(s) = m ] = P[ N(t+∆t) – N(t) = n] for all 0 ≤ s ≤ t. 3. Occurrences of arrivals in non-overlapping intervals are independent. 4. The Probability of two or more arrivals in [t, t+∆t] is negligible. Assume Pn(t) = P[N(t) = n] N(t) has possible values 0,1,2,… since it is possible to have any number of customers in line. Considering a time step of size ∆t, N(t) forms a Markov Chain, with a transition matrix of: A= ( ) 1-λ∆t 0 0 0... λ∆t 1-λ∆t 0 0... 0 λ∆t 1- λ∆t 0 . . . State Diagram of Transition Matrix λ∆t 1-λ∆t λ∆t 1-λ∆t λ∆t 1-λ∆t Xt+∆t = AXt is the state equation for each time step size ∆t, where: Xt = ( ) P0(t) P1(t) : Pn(t) : After Matrix Multiplication: we have the following system of equations: P0(t+∆t) = (1-λ∆t)P0(t) P1(t+∆t) = λ∆tP0(t)+(1-λ∆t)P1(t) Pn(t+∆t) = λ∆tPn-1(t)+(1-λ∆t)Pn(t) These equations can then be rearranged to make difference quotients. Letting ∆t go to zero we obtain a system of differential equations. For n ≥ 1, Pn’(t) = Pn(t+ ∆t) – Pn(t) lim∆t→0 ∆t = λ[Pn-1(t) – Pn(t)], and for n = 0, P0’(t) = -λP0(t) This equation is the exponential differential equation with initial condition that there are no arrivals (P0(0) = 1). This gives: P0(t) = e-λt Similarly, letting n=1, P1’(t) = λ[P0(t)- P1(t)] = λ[e-λt - P1(t)] This is a first-order linear differential equation which can be solved by multiplying by the integrating factor eλt. d [eλtP (t)] =λ so that λt e P1(t) = λt+c 1 dt The initial condition P0(0) =1 implies Pn(0) = 0 for all n ≥ 1, thus: P1(t) = λte-λt It can be shown by induction that the system of differential equations has solution: Pn(t) = e-λt(λt)n n! for t≥0, n = 0,1,2,… •Known as a homogeneous Poisson process with rate λ. (λ does not depend on time variable t) •Mean is λt (λt customers during time interval of length t) Ex. λ= 2 customers/minute, t =5 minutes λt = 5*2 = 10 customers over 5 minutes Many Customers, 1 Server • Let N(t) = number of individuals at checkout counter at time t. • N(t) = any of the integer values 0, 1, 2, … at time t. • Probability of arrival in ∆t is λ∆t. • Probability of departure in ∆t is µ∆t. • Three mutually exclusive events: I. Exactly one arrival in (t,t + ∆t) II. Exactly one departure in (t,t + ∆t) III. No arrivals or departures in (t,t + ∆t). λ∆t 0 1 – λ∆t λ∆t 1 λ∆t 2 µ∆t µ∆t µ∆t 1 – λ∆t - µ∆t 1 – λ∆t - µ∆t • The time step for this Markov chain is ∆t and the transition matrix is: 1-λ∆t A= µ∆t λ∆t 1 – µ∆t – λ∆t 0 .. . λ∆t .. . 0 0 0 … µ∆t 0 0 … 1 – µ∆t – λ∆t µ∆t 0 … .. .. .. . . . • Let Pn(t) = P[N(t) = n] be the probability that there are n customers in the queue at time t. Thus letting P0(t) P1(t) Xt = .. . Pn(t) .. . • We obtain the equation Xt + ∆t = AXt for the single-server queue. • The state equation gives the following (infinite) system of equations for the singleserver queue: P0(t + ∆t) = (1 – λ∆t)P0(t) + µ∆tP2(t) P1(t + ∆t) = (1 – λ∆t - µ∆t)P1(t) + λ∆tP0(t) + µ∆tP2(t) .. . Pn(t + ∆t) = (1 – λ∆t - µ∆t)Pn(t) + λ∆tP0 - 1(t) + µ∆tPn + 1(t) .. . System of differential equations by letting ∆t go to zero; more specifically, for n > 1, Pn(t + ∆t) – Pn(t) P’n(t) = lim ∆t 0 ∆t = -(λ + µ)Pn(t) + λPn – 1(t) + µPn – 1(t) And, P0’(t) = -λP0(t) + µP1(t). Many classical methods are available for the solving the system: Pn’(t) = -(λ + µ)Pn(t) + λPn – 1(t) + µPn – 1(t) P0’(t) = -λP0(t) + µP1(t) However, they involve ideas beyond the scope of our analysis instead, we will be using the system of equations to obtain steady-state (time-independent) behavior. Stationary Distribution Looking for whether the system of time-dependent probabilities settles down and displays no more “transient” behavior - analogous to finding the fixed points for deterministic systems. In this case, the fixed points will be “stationary” distributions. The system of differential equations: Pn’(t) = -(λ + µ)Pn(t) + λPn – 1(t) + µPn – 1(t) P0’(t) = -λP0(t) + µP1(t) has a fixed point or stationary distribution provided its rates of change are zero, that is: Pn’(t) = 0 for n ≥ 0. lim Pn’(t) = 0 for n ≥ 0, is equivalent to assuming that t ∞ lim Pn(t) = Pn exists, where Pn does not depend upon t. t ∞ Applying Pn’(t) = 0 to the system of equations, we obtain: 1.) 0 = -λP0 + µP1 and 2.) 0 = -(λ + µ)Pn + λPn-1 + µPn+l, for n > 1. Solving for P1, using equation 1: P1 = (λ / µ) P0 Solving for P2, using P1 and equation 2: P2 = (λ / µ)2 P0 Continuing on, using induction, shows: Pn = (λ / µ)n P0 Queue size must be a non-negative integer, hence, P0 + P1 + P2 + … = 1 So, P0 + (λ/µ)P0 + (λ/µ)2P0+ … = 1 Which is, P0 ∞ n=0 (λ/µ)n = 1. This sums to 1/(1-(λ/µ)) provided that (λ/µ) < 1, which is the condition for the stationary distribution. Using this sum, P0 = 1 – (λ/µ), so the stationary distribution for the single-server queue is: Pn = (λ/µ)n(1-(λ/µ)) Traffic Intensity • Average Queue Length • Little’s Principle • Average Waiting Time Average Queue Length Let = ( / ). (called the traffic intensity of the queue) By assumption, < 1, as < . Using in: Pn = ( / )n (1 – ( / )), Pn = n (1 – ). Obtaining the average number Na of customers in the queue: ∞ Na = E(N) = n=0 ∞ nPn = n=0 n( n(1 – )) ∞ ∞ = (1 – ) n = 0 n ∞ d = (1 – ) d n=0 n = (1 – ) n n=0 n d = (1 – ) d n-1 ∞ n n=0 d (1 / (1 – )) = (1 – ) d = (1 – ) (1 – )-2 = -1 Na = -1 Average Number of Customers in Queue 10 9 Number of Customers 8 7 6 5 4 3 2 1 0 0 0.2 0.4 0.6 Traffic Intensity (p) 0.8 0.9 1 Average Waiting Time Little’s Principle – the average number of customers in a queueing system is equal to the average arrival rate of customers to that system times the average time spent in that system. Na = Ta Ta = Na / = ( / ((1 – ) ) = (( / ) / ((1 – ( / )) )) = (1 / ) / (1 – ( / )) = (1 / ) / (1 – ) = 1/( - ) Ta = 1/ ( – ) Average Waiting Time 12 Units of Time 10 8 6 4 2 0 0 0.2 0.4 0.6 Traffic Intensity 0.8 0.9 1 Model Formulation of Store Profit Maximization C( ), which is the Customer Attrition Function, models the loss of profit per day and is given below: C( ) = { 0 for ≤ Ta0 ATa0 for ≥ Ta0 Ta0 represents the threshold where customers stop returning to the store due to long waiting times. Graph of Customer Attrition Function C( ) 0 C( ) = C(1/( - )) for one server C( ) = C(1/(σ - )) for σ servers This models the loss of profit due to customers having to wait in lines Customer waiting costs plus employee costs J(σ) = C(1/(σ - )) +K σ 1≤σ<∞ σ = # number of employees (checkers) K = cost associated with retaining those employees Conclusion The object of the manager is to minimize J(σ) by finding the number of employees that eliminates the attrition factor by decreasing costs. References A Course in Mathematical Modeling, by Douglas Mooney and Randall Swift Dr. Steve Deckelman