5.6 \(N\)-policies for the \(M/G/1\) Queue
Ex 2.2.6 motivates the study of the \(M/G/1\) queue under an \(N\)-policy. We use the renewal-reward theorem to derive the time-average cost for this system by focusing on the average cost and duration of cycles that start and stop each time a job arrives at an empty system. As corollaries we obtain the EPQ formula of Section 4.3 and the PK formula of Section 5.4.
The expected cycle duration is what we first need. For this, we consider the expected time \(T(q)\) to clear the system when the server starts working on the first of \(q\) jobs present. We present three different ideas to obtain \(T(q)\).
The first heuristic idea is this. We know that jobs arrive at a rate \(\lambda\) and are served at a rate \(1/\E S = \mu>\lambda\). Clearly, the net `drain rate' of the queue is \(\mu-\lambda\); hence we guess that1 By analogy: when you have a `queue' of \(q\) km to cycle, and your speed is \(v\) km/h, then it takes \(q/v\) hours to complete the trip.
\begin{equation*} T(q)= \frac{q}{\mu-\lambda} = \frac{\E{S} }{1-\lambda \E{S}} q = \frac{\E{S}}{1-\rho}q. \tag{5.6.1} \end{equation*}Clearly, this reasoning completely ignores the stochasticity in arrival times and services: we cannot guarantee that the result is correct. For the second idea, consider a regular2 That is, not controlled by an \(N\)-policy. \(M/G/1\) queue. When a job arrives to an empty system, it takes a busy time3 Recall the explanation that led to Eq. (4.1.3). \(\E \U\) to service this job and all the jobs that arrive during the service of this first job. In other words, it takes \(\E\U\) time on average to move from \(1\) job in the system to \(0\) jobs, i.e., one job less. But then, when there are \(q\) jobs in the system, it must take \(T(q) = q\E\U\) units of time to move from state \(q\) to state \(0\). By Ex 4.3.7, \(\E\U=\E S/(1-\rho)\), so we again obtain Eq. (5.6.1). The third idea is the most powerful. Write \(Y\) for the number of jobs that arrive during a service time. Then \(T(q)\) satisfies the relation
\begin{equation*} T(q) = \E S + \E{T(q+Y-1)},\quad q\geq 1, \tag{5.6.2} \end{equation*}because first the job in service must leave, and then, when \(Y=k\), it takes \(T(q+k-1)\) to clear the system. To solve this equation, we substitute the guess \(T(q) = aq+b\) and solve for \(a\) and \(b\). It is clear4 If the system is empty, no time is needed to clear it. that \(T(0)=0\), hence \(b=0\). Substituting \(a q\) into Eq. (5.6.2) gives \(a q =\E S + aq + a\E Y - a\). Noting5 Poisson arrivals \(\implies\) \(\E{Y|S=s} = \lambda s\) \(\implies\) \(\E{Y|S} = \lambda S\) \(\implies\) \(\E Y = \E{\E{Y|S}} = \lambda \E S\). that \(\E Y = \lambda \E S\), and solving for \(a\) we find Eq. (5.6.1). We note that the solution of Eq. (5.6.2) is unique once \(T(0)\) is fixed.
For the expected cycle duration \(C(N)\) as a function of \(N\), observe that, right after the server switches off, we need \(N\) independent inter-arrival times to reach level \(N\). As this takes \(N/\lambda\) in expectation, and then the system needs \(T(N)\) to become empty again, \(C(N) = N/\lambda + T(N)\).
For the cycle cost, we proceed as follows. First, consider the expected cost \(U(q)\) of waiting that accrues while one job is served and \(q-1\) jobs are in queue.6 Thus, there are \(q\) jobs in the system. When the service starts, the waiting cost for these \(q\) jobs is \(h q \E{S}\).7 That is, \(h\) times the area of the rectangle with base \(\E{S}\) and height \(q\). Next, arrivals during the service of the job also contribute to the cost of waiting. The expected time these arrivals spend in the system equals \(\E{\int_0^{S} N(s) \d s}\), where \(N(s)\sim \Pois{\lambda s}\). Conditional on \(S=t\), \(\E{\int_0^{S} N(s) \d s |S=t} = \int_{0}^{t} \E{N(s)} \d s = \int_{0}^{t} \lambda s \d s = \lambda t^2/2\), hence \(\E{\int_0^{S} N(s) \d s|S} = \lambda S^{2}/2\), hence \(\E{\int_0^{S} N(s) \d s} = \lambda \E{S^{2}/2}\). Combining both cost terms, the total cost of waiting during the service of the job is
\begin{equation*} U(q) = h q \E S + \frac 12 \lambda h \E{S^2}. \end{equation*}Let \(V(q)\) be the expected queueing costs to clear the system just after a service starts and \(q\) jobs are in the system. By analogy with Eq. (5.6.2), \(V(q)\) must be the solution of
\begin{equation*} V(q) = U(q) + \E{V(q+Y-1)}, \quad q\geq 1. \tag{5.6.3} \end{equation*}As \(U(q)\) has a term linear in \(q\) and a constant term, we substitute a quadratic form \(V(q) = aq^2 + bq+c\) instead of a linear relation, assemble terms with the same power in \(q\), and solve for \(a, b\) and \(c\). Of course, \(c = 0\) since \(V(0)=0\). For \(a\) and \(b\) we need some work to arrive at8 See Ex 5.6.11--Opt 5.6.12.
\begin{align*} V(q) = \frac{h}{2}\frac{\E S}{1-\rho} q^2 + h \frac{ 1+ \rho C_s^2}2 \frac{\E S}{(1-\rho)^2} q. \end{align*}For the cost during the build-up of the queue, we again use a recursive procedure. Write \(W(q)\) for the accumulated queueing cost9 Here \(W\) is not the waiting time in queue. from the moment the server becomes idle up to the arrival time of the \(q\)th job (the job that sees \(q-1\) jobs in the system upon arrival). Then,10 See Ex 5.6.8.
\begin{equation*} W(q) = W(q-1) + h\frac{q-1}{\lambda} \implies W(q) = h \frac{q(q-1)}{2\lambda}. \end{equation*}By combining all the above cost factors and using the renewal reward theorem, we find for the long-run average cost11 Opt 5.6.13.
\begin{equation*} \frac{W(N) + K + V(N)}{C(N)} = h \frac{1+ C_s^2}2 \frac{\rho^2}{1-\rho} + h \rho + h \frac{N-1}2 + K \frac{\lambda(1-\rho)}N. \tag{5.6.4} \end{equation*}It is easy to retrieve the Pollaczek-Khinchine formula from this. The LHS in Eq. (5.6.4) is the average cost per unit time. Since in the \(M/G/1\) queue, each waiting customer pays \(h=1\) per unit time, the LHS corresponds to \(\E \L\). For the RHS, in the \(M/G/1\) queue, the setup cost \(K=0\), hence it is optimal to take \(N=1\). Consequently, just the first two terms of the RHS of Eq. (5.6.4) remain. The first term is \(\E\QQ = \lambda \E \W\), where \(\E \W\) is given by the PK formula. The second is \(\rho = \E{\Ls}\). But \(\E \L = \E\QQ + \E\Ls\), i.e., the LHS and RHS are equal.
A second interesting result is the EPQ formula for a production-inventory system with Poisson arrivals and no backlogging.12 This is more general than Eq. (4.3.1) because demand can arrive as a Poisson process. Although in its present form, backlogging is now not allowed, this is simple to include. The optimal production quantity can be found by taking the derivative of Eq. (5.6.4) with respect to \(N\), just as if it is a continuous variable. Setting the derivative to zero and solving for \(N\) results in, up to rounding,
\begin{equation*} N^* = \sqrt{\frac{2\lambda(1-\rho)K}{h}}. \end{equation*}A machine can be turned on and off. If the queue length reaches \(N\), the machine is turned on, and if the system becomes empty, the machine switches off. Let \(I_k=1\) if the machine is on in period \(k\) and \(I_k=0\) if it is off, let \(L_k\) be the number of jobs in the system at the end of period \(k\). Claim: the next recursions model this queueing system.
\begin{align*} I_{k+1} &= \begin{cases} 1 & \text{ if } L_{k} \geq N,\\ I_k & \text{ if } 0< L_{k} <N,\\ 0 & \text{ if } L_{k} =0,\\ \end{cases}\\ I_{k+1} &= \1{L_k\geq N} + I_k \1{0<L_k<N}, \\ d_k &=\min\{L_{k-1}, c_k\}, \\ L_k &= L_{k-1} - (1-I_k) d_k + a_k. \end{align*}Assume that \(I_0 =0\) at time \(0\).
Solution
Solution, for real
False. It should be this: \(d_k =I_k \min\{L_{k-1}, c_k\}\), \(L_k = L_{k-1} - d_k + a_k\).
We have an \(M/G/1\) queue controlled by an \(N\)-policy, \(\lambda=1\) and \(S_i\equiv 0.5\). Claim: the expected time to clear this queue after reaching \(N\) jobs is the same for a \(D/D/1\) queue with the same arrival and service rates.
Solution
Solution, for real
True.
Claim: For the \(M/G/1\) queue under an \(N\)-policy, the expected time to clear the system starting from \(q\) jobs is \(T(q) = q \E S / (1-\rho)\).
Solution
Solution, for real
True. This follows from the fact that the net drain rate is \(\mu - \lambda\), and can be verified by substituting \(T(q) = aq\) into the recursion Eq. (5.6.2).
Claim: For the \(M/G/1\) queue under an \(N\)-policy, the optimal \(N^*\) does not depend on the service time distribution, only on \(\rho\).
Solution
Solution, for real
False. The optimal \(N^*\) depends on \(\lambda\), \(\rho\), \(K\), and \(h\), but \(\rho = \lambda \E S\) itself depends on the mean service time. However, \(N^*\) does not depend on higher moments of the service time such as \(C_s^2\).
Claim: For the \(M/G/1\) queue under an \(N\)-policy, setting \(N=1\) and \(K=0\) recovers the Pollaczek-Khinchine formula for \(\E\W\).
Solution
Solution, for real
True. With \(N=1\) the server never switches off, and with \(K=0\) there is no setup cost, so the \(N\)-policy reduces to the standard \(M/G/1\) queue.
Explain intuitively that the system is rate-stable for any \(N\).
Solution
Solution, for real
When we switch on the server, the queue drains at a rate \(\mu-\lambda>0\), with \(\mu=1/\E S\). Consequently, no matter how large \(N\), \(T(N)<\infty\). Whenever the system is empty, the stochastic process restarts. As such cycles start over and over again, the queue length cannot `escape to infinity'.
Why doesn't the utilization \(\rho\) depend on \(N\)?
Hint
Use the argumentation that leads to Eq. (4.3.2).
Solution
Solution, for real
The total number \(A(t)\) of jobs that arrive during \([0,t]\) does not depend on \(N\). Thus, in Eq. (4.3.2), \(\sum_{k=1}^{A(t)}S_k\) does not depend on \(N\). Now use rate-stability.
Explain and solve the recursion for \(W(q)\).
Hint
Use that \(\sum_{n=0}^N \alpha^n = \frac{1-\alpha^{N+1}}{1-\alpha}\).
Solution
Solution, for real
The cost up to the \(q\)th job is the cost \(W(q-1)\) up to the arrival of job \(q-1\) plus the cost while there are \(q-1\) jobs in the system. The time between the arrival of job \(q-1\) and \(q\) is \(1/\lambda\). When there are \(q-1\) jobs in the system, \(h(q-1)/\lambda\) is the expected cost between the arrivals of job \(q-1\) and job \(q\). And thus, \(W(q) = h\lambda^{-1}\sum_{i=1}^q (i-1)\).
Use the memoryless property for the \(M/M/1\) queue to show that
\begin{equation*} T(q) = \frac{1}{\lambda+\mu} + \frac{\lambda}{\lambda+\mu} T(q+1) + \frac{\mu}{\lambda+\mu} T(q-1). \tag{5.6.5} \end{equation*}Solution
Solution, for real
Consider an arbitrary moment in time at which \(q>0\) and the server is busy. Now, either of two events happens first: a new job enters the system, or the job in service leaves. The probability that an arrival occurs first is \(\alpha=\lambda/(\lambda+\mu)\),13 See Ex 1.2.11. the probability of a departure to occur first is \(\beta=1-\alpha = \mu/(\lambda+\mu)\). In addition, the expected time for an arrival or a departure, whichever is first, is \(1/(\mu+\lambda)\).14 See Ex 1.2.9. In other words, the system stays in state \(q\) for an expected time \(1/(\lambda+\mu)\) until an arrival or departure occurs. Then, it moves to state \(q+1\) or \(q-1\), and from there it takes \(T(q+1)\) or \(T(q-1)\) until the system is empty. This reasoning depends crucially on the memoryless property.
Show that for the \(M/M/1\) queue, \(V(q)\) satisfies a relation of the form:
\begin{equation*} V(q) = h\frac{q}{\lambda + \mu} + \frac{\lambda}{\lambda+\mu} V(q+1) + \frac{\mu}{\lambda+\mu} V(q-1). \tag{5.6.6} \end{equation*}Solution
Solution, for real
Note that the queueing cost is \(hq\) per unit time when there are \(q\) jobs in the system; it costs \(hq/(\lambda+\mu)\) until an arrival or departure occurs. For the rest, we follow the reasoning by which we derive the recursion for \(T(q)\) for the \(M/M/1\) queue.
Simplify \(a q^2 +b q = a\E{(q+Y-1)^2} + b\E{q+Y-1}+ U(q)\), where \(U(q) = h q \E S + \frac 12 \lambda h \E{S^2}\), by assembling powers in \(q\) to obtain:
\begin{align*} a &= \frac h 2 \frac{\E S}{1-\E Y} = \frac{h}{2} \frac{\E S}{1- \rho}, \\ b(1-\E Y) &= a(\E{Y^2} - 2 \E Y + 1) + \frac 12 h \lambda \E{S^2}. \end{align*}Hint
Solution
Solution, for real
In the hint, the first equation is superfluous. In the second, \(bq\) cancels on both sides, by which we find \(a\). The third now follows.
Derive the expression for \(V(q)\) using the previous exercises.
Solution
Solution, for real
For \(b\), using the expressions for \(\E Y\) and \(\E{Y^2}\),
\begin{align*} b(1-\E Y) &= a(\E{Y^2} - 2 \E Y + 1) + \frac 12 h \lambda \E{S^2} \\ &= \frac{h \E S}{2(1-\E Y)} (\E{Y^2} - 2 \E Y + 1) + \frac 12 h \lambda \E{S^2} \\ &= \frac{h \E S}{2(1-\lambda \E S)} \left(\lambda^2 \E{S^2} + \lambda \E S - 2 \lambda \E S + 1 + \lambda \E{S^2}\frac{1-\lambda \E S}{\E S}\right) \\ &= \frac{h \E S}{2(1-\lambda \E S)} \left(\lambda^2 \E{S^2} - \lambda \E S + 1 + \frac{\lambda \E{S^2}}{\E S} - \lambda^2 \E{S^2}\right) \\ &= \frac{h \E S}{2(1-\lambda \E S)} \left(1+ \frac{\lambda \E{S^2}}{\E S } - \lambda \E S \right) \\ &= \frac{h \E S}{2(1-\lambda \E S)} \left( 1+ \frac{\lambda \E{S^2}}{\E S } - \lambda \frac{(\E S)^2}{\E S}\right) \\ &= \frac{h \E S}{2(1-\lambda \E S)} \left( 1+ \lambda \frac{\V{S}}{\E S }\right)\\ &= \frac{h \E S}{2(1-\lambda \E S)} \left( 1+ \lambda \frac{\V{S}}{(\E S)^2 } \E S\right)\\ &= \frac{h \E S}{2(1-\lambda \E S)} \left( 1+ \rho C_s^2\right). \end{align*}Divide now both sides by \(1-\E Y\).
Derive Eq. (5.6.4).
Solution
Solution, for real
Note first that \(C(N) = N(1/\lambda + \E S / (1-\rho)) = N/(\lambda(1-\rho))\). Then,
\begin{align*} \frac{V(N) + K + W(N)}{C(N)} &= \left(aN^2 + bN + K + h N(N-1)/2 \lambda\right) \frac{\lambda(1-\rho)}N \\ &= \frac h 2 \rho N + \frac h 2 \frac \rho{1-\rho} (1+\rho C_s^2) + \frac h 2 (N-1)(1-\rho) + K \frac{\lambda(1-\rho)}N \\ &= \frac h 2 \frac \rho{1-\rho} (1+\rho C_s^2) + \frac h 2 (N-1 + \rho) + K \frac{\lambda(1-\rho)}N \\ &= \frac h 2 \frac \rho{1-\rho} (\rho + \rho C_s^2 + 1 - \rho) + \frac h 2 (N-1 + \rho) + K \frac{\lambda(1-\rho)}N \\ &= \frac h 2 \frac{\rho^2}{1-\rho} (1+ C_s^2) +\frac h 2 \rho + \frac h 2 (N-1 + \rho) + K \frac{\lambda(1-\rho)}N \\ &= \frac h 2 \frac{\rho^2}{1-\rho} (1+ C_s^2) + h \rho + h \frac{N-1}2 + K \frac{\lambda(1-\rho)}N. \end{align*}