5.6 \(N\)-policies for the \(M/G/1\) Queue

Exercise 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 the system becomes empty. As corollaries we obtain the EPQ formula of Section 4.3 and the PK formula of Section 5.4.

The expected cycle duration consists of an off period, during which the server is off, followed by a drain period, during which the server is on and drains the queue. The off period starts when the server switches off, and it ends when \(\L(t)\) hits level \(N.\) For this to happen, we need \(N\) independent inter-arrival times to reach level \(N,\) which takes \(\tau_+(N) = N/\lambda\) in expectation. When the \(N\)th job arrives, the server switches on and works until the system is empty; this is the drain period. Its expected length is \(\tau_-(N)\) To derive an expression for this, we consider the expected time \(\tau_-(q)\) to clear the system when the server starts working on the first of \(q\) jobs present. We present three different ideas to obtain this.

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 that1By 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*} \tau_-(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 regular2That is, not controlled by an \(N\)-policy. \(M/G/1\) queue. When a job arrives to an empty system, it takes a busy period3Recall the explanation that led to (4.1.3). of expected length \(\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 \(\tau_-(q) = q\E\U\) units of time to move from state \(q\) to state \(0.\) By Exercise 7, \(\E\U=\E S/(1-\rho),\) so we again obtain (5.6.1). The third idea is the most powerful. Write \(Y\) for the number of jobs that arrive during a service time. Then \(\tau_-(q)\) satisfies the relation

\begin{equation*} \tau_-(q) = \begin{cases} \E S + \E{\tau_-(q+Y-1)}, & \quad q > 0, \\ 0, & \quad q = 0, \end{cases} \tag{5.6.2} \end{equation*}

because first the job in service must leave, and then, when \(Y=k,\) it takes \(\tau_-(q+k-1)\) to clear the system. When \(q=0,\) the system is empty, so no time is needed. To solve this equation, we substitute the guess \(\tau_-(q) = aq+b\) and solve for \(a\) and \(b.\) Since \(\tau_-(0)=0,\) \(b=0.\) Substituting \(a q\) into (5.6.2) gives \(a q =\E S + aq + a\E Y - a.\) Noting4Poisson 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 (5.6.1). The expected clearing time is the smallest nonnegative solution of (5.6.2); the busy-period argument above identifies it as \(\tau_-(q)=q\E S/(1-\rho).\)

Hence, the expected cycle duration is \(\tau_+(N) + \tau_-(N).\)

For the cycle cost, we proceed as follows. During the off period, write \(V_+(q)\) for the accumulated holding cost 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), where \(h\) is the holding cost per job in the system per unit time. Then,5See Exercise 8.

\begin{equation*} V_+(q) = \begin{cases} V_+(q-1) + h\dfrac{q-1}{\lambda}, & \quad q > 0, \\ 0, & \quad q = 0, \end{cases} \end{equation*}

hence \(V_+(q) = h\,q(q-1)/(2\lambda).\)

For the drain period, we first consider the expected holding cost \(R(q)\) that accrues while one job is served and \(q-1\) jobs are in queue.6Thus, there are \(q\) jobs in the system. When the service starts, the holding cost for these \(q\) jobs is \(h q \E{S}.\)7That 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 holding cost. The expected time these arrivals spend in the system equals \(\E{\int_0^{S} A(s) \d s},\) where \(A(s)\sim \Pois{\lambda s}\) is the number of arrivals in \([0,s].\) Conditional on \(S=t,\) \(\E{\int_0^{S} A(s) \d s |S=t} = \int_{0}^{t} \E{A(s)} \d s = \int_{0}^{t} \lambda s \d s = \lambda t^2/2,\) hence \(\E{\int_0^{S} A(s) \d s|S} = \lambda S^{2}/2,\) hence \(\E{\int_0^{S} A(s) \d s} = \lambda \E{S^{2}/2}.\) Combining both cost terms, the total holding cost during the service of the job is

\begin{equation*} R(q) = h q \E S + \frac 12 \lambda h \E{S^2}. \end{equation*}

Let \(V_-(q)\) be the expected holding cost to clear the system just after a service starts and \(q\) jobs are in the system. By analogy with (5.6.2), \(V_-(q)\) must be the solution of

\begin{equation*} V_-(q) = \begin{cases} R(q) + \E{V_-(q+Y-1)}, & \quad q > 0, \\ 0, & \quad q = 0. \end{cases} \tag{5.6.3} \end{equation*}

In the terms of Section 5.9, \(\E S\) and \(R(q)\) are the running costs of \(\tau_-\) and \(V_-,\) \(0\) is their stopping cost, and \(\set{0}\) is the hitting set. As \(R(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.\) Since \(V_-(0)=0,\) \(c=0.\) For \(a\) and \(b\) we need some work to arrive at8See Exercise 11--Exercise 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*}

By combining all the above cost factors and using the renewal-reward theorem, we find for the long-run average cost9Exercise 13.

\begin{equation*} C(N) = \frac{V_+(N) + K + V_-(N)}{\tau_+(N) + \tau_-(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*}

where \(K\) is the cost to switch on the server.

It is easy to retrieve the Pollaczek-Khinchine formula from this. The LHS in (5.6.4) is the average cost per unit time. With \(h=1,\) each job in the system pays \(1\) per unit time, so the LHS equals \(\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 (5.6.4) remain. The first term is \(\E\Lq = \lambda \E \W,\) where \(\E \W\) is given by the PK formula. The second is \(\rho = \E{\Ls}.\) But \(\E \L = \E\Lq + \E\Ls,\) i.e., the LHS and RHS are equal.

The optimal switch-on threshold can be found by taking the derivative of (5.6.4) with respect to \(N,\) treating it as a continuous variable. The continuous minimizer is \(\sqrt{2\lambda(1-\rho)K/h}.\) For the integer threshold, and \(K>0,\) compare the costs at \(\lfloor\sqrt{2\lambda(1-\rho)K/h}\rfloor\) and \(\lceil\sqrt{2\lambda(1-\rho)K/h}\rceil.\) When \(K=0,\) it is evident that \(N^*=1.\)10Why is this evident?

This result also gives a connection with the EPQ inventory model in (4.3.1). If backlogging is not allowed, we take \(b\to\infty\) in that result and set the demand rate \(d=\lambda\) and the production rate \(r=\mu.\) Then the produce-up-to level \(S\) in the inventory setting takes the role of \(N,\) and then

\begin{align*} s^* & = 0, & S^* & = \sqrt{\frac{2K\lambda(1-\rho)}h}. \end{align*}

In the queue, \(N\) triggers service of accumulated jobs; in the inventory system, \(S\) is the stock level at which production stops.

TF 1.

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

Did you actually try? Write your solution down first for comparison.

Show the solution

False. It should be this: \(d_k =I_k \Min{L_{k-1}, c_k},\) \(L_k = L_{k-1} - d_k + a_k.\)

TF 2.

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

Did you actually try? Write your solution down first for comparison.

Show the solution

2627: Taken out; the answer is wrong in the pdf file on brightspace. TODO.

20261119: the next answer is correct: False: for \(N=1,\) the \(D/D/1\) queue empties after \(0.5\) time units, before the next arrival, whereas the expected clearing time of the \(M/D/1\) queue is \(\tau_-(1) = 0.5/(1-0.5)=1.\)

TF 3.

Claim: For the \(M/G/1\) queue under an \(N\)-policy, the expected time to clear the system starting from \(q\) jobs is \(\tau_-(q) = q \E S / (1-\rho).\)

Solution

Did you actually try? Write your solution down first for comparison.

Show the solution

True. The busy-period argument gives \(\tau_-(q) = q\E\U = q\E S/(1-\rho),\) and substituting \(\tau_-(q) = aq\) into (5.6.2) gives the same. The drain-rate argument only suggests this result.

TF 4.

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

Did you actually try? Write your solution down first for comparison.

Show the solution

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.\)

TF 5.

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

Did you actually try? Write your solution down first for comparison.

Show the solution

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.

Exercise 6.

Explain intuitively that the system is rate-stable for any \(N.\)

Solution

Did you actually try? Write your solution down first for comparison.

Show the solution

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,\) \(\tau_-(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’.

Exercise 7.

Why doesn’t the utilization \(\rho\) depend on \(N\)?

Hint

Use the argumentation that leads to (4.3.2).

Solution

Did you actually try? Write your solution down first for comparison.

Show the solution

The total number \(A(t)\) of jobs that arrive during \([0,t]\) does not depend on \(N.\) Thus, in (4.3.2), \(\sum_{k=1}^{A(t)}S_k\) does not depend on \(N.\) Now use rate-stability.

Exercise 8.

Explain and solve the recursion for \(V_+(q).\)

Hint

Use that \(\sum_{n=0}^N \alpha^n = \frac{1-\alpha^{N+1}}{1-\alpha}.\)

Solution

Did you actually try? Write your solution down first for comparison.

Show the solution

The cost up to the \(q\)th job is the cost \(V_+(q-1)\) up to the arrival of job \(q-1\) plus the cost while there are \(q-1\) jobs in the system. The expected 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, \(V_+(q) = h\lambda^{-1}\sum_{i=1}^q (i-1).\)

Exercise 9.

Use the memoryless property for the \(M/M/1\) queue to show that

\begin{equation*} \tau_-(q) = \frac{1}{\lambda+\mu} + \frac{\lambda}{\lambda+\mu} \tau_-(q+1) + \frac{\mu}{\lambda+\mu} \tau_-(q-1). \tag{5.6.5} \end{equation*}
Solution

Did you actually try? Write your solution down first for comparison.

Show the solution

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),\)11See Exercise 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).\)12See Exercise 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 \(\tau_-(q+1)\) or \(\tau_-(q-1)\) until the system is empty. This reasoning depends crucially on the memoryless property.

Exercise 10.

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

Did you actually try? Write your solution down first for comparison.

Show the solution

Note that the holding 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 \(\tau_-(q)\) for the \(M/M/1\) queue.

Exercise 11.

Simplify \(a q^2 +b q = a\E{(q+Y-1)^2} + b\E{q+Y-1}+ R(q),\) where \(R(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 \begin{align*} a q^2 & = a q^2, \\ b q & = 2a q \E Y - 2a q + b q + h q \E S, \\ 0 & = a \E{Y^2} - 2a \E Y + a + b \E Y - b + \frac 12 \lambda h \E{S^2}. \end{align*}
Solution

Did you actually try? Write your solution down first for comparison.

Show the solution

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.

Opt 12.

Derive the expression for \(V_-(q)\) using the previous exercises.

Solution

Did you actually try? Write your solution down first for comparison.

Show the solution

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)} \rb{\lambda^2 \E{S^2} + \lambda \E S - 2 \lambda \E S + 1 + \lambda \E{S^2}\frac{1-\lambda \E S}{\E S}} \\ &= \frac{h \E S}{2(1-\lambda \E S)} \rb{\lambda^2 \E{S^2} - \lambda \E S + 1 + \frac{\lambda \E{S^2}}{\E S} - \lambda^2 \E{S^2}} \\ &= \frac{h \E S}{2(1-\lambda \E S)} \rb{1+ \frac{\lambda \E{S^2}}{\E S } - \lambda \E S } \\ &= \frac{h \E S}{2(1-\lambda \E S)} \rb{ 1+ \frac{\lambda \E{S^2}}{\E S } - \lambda \frac{(\E S)^2}{\E S}} \\ &= \frac{h \E S}{2(1-\lambda \E S)} \rb{ 1+ \lambda \frac{\V{S}}{\E S }}\\ &= \frac{h \E S}{2(1-\lambda \E S)} \rb{ 1+ \lambda \frac{\V{S}}{(\E S)^2 } \E S}\\ &= \frac{h \E S}{2(1-\lambda \E S)} \rb{ 1+ \rho C_s^2}. \end{align*}

Divide now both sides by \(1-\E Y.\)

Opt 13.

Derive (5.6.4).

Solution

Did you actually try? Write your solution down first for comparison.

Show the solution

Note first that \(\tau_+(N) + \tau_-(N) = N(1/\lambda + \E S / (1-\rho)) = N/(\lambda(1-\rho)).\) Then,

\begin{align*} C(N) = \frac{V_+(N) + K + V_-(N)}{\tau_+(N) + \tau_-(N)} &= \rb{h N(N-1)/(2\lambda) + K + aN^2 + bN} \frac{\lambda(1-\rho)}N \\ &= \frac h 2 (N-1)(1-\rho) + K \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 \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*}