Appendix B — Calculus and Optimization Background

NoteLearning objectives

After reading this chapter you should be able to:

  • find the minimum of a cost function of one variable, and confirm it is a minimum
  • explain what convexity is and why it turns a stationary point into a minimum
  • minimize a cost function of two variables by solving its partial derivatives
  • optimize over whole numbers by first differences, and say when the rule fails
  • differentiate an integral whose limit is the decision
  • form a Lagrangian, solve it, and read the multiplier as a price
  • solve an equation by bisection or by fixed-point iteration, and know what each guarantees
  • recognize a dynamic program and the principle of optimality behind it
  • sum a finite geometric series

Every model in this book chooses a decision to make a cost as small as possible. The decision may be a real number, such as an order quantity, or a whole number, such as a reorder point. It may be one quantity or several, and it may be free or held to a limit. This appendix collects the mathematics those choices use, in the order the chapters meet it, and works each piece on an item the book already uses.

It is a reference, not a course. The reader who wants the full development should refer to a calculus text for the first four sections and to Zipkin (2000) for their use in inventory theory. What is here is enough to follow every derivation in the book step by step, and each section says where in the book its result is used.

B.1 One Variable

B.1.1 The Stationary Point

Let \(C(Q)\) represent a cost that depends on one decision \(Q\), and suppose \(C\) can be differentiated. Its derivative \(dC/dQ\) is the rate at which the cost changes as \(Q\) increases. Where the derivative is negative, increasing \(Q\) lowers the cost; where it is positive, increasing \(Q\) raises it. Thus, at an interior minimum the derivative is zero, because otherwise a small move one way or the other would lower the cost. A value of \(Q\) at which the derivative is zero is a stationary point.

The derivatives this book needs come from three rules. The power rule gives \(d(Q^{n})/dQ = nQ^{n-1}\) for any power \(n\), including the negative power in \(k\lambda/Q = k\lambda Q^{-1}\). The derivative of a constant is zero. The derivative of a sum is the sum of the derivatives.

For example, the cost rate of the classical economic order quantity, Equation 3.16, is

\[ \begin{aligned} \mathit{TC}(Q) &= \frac{k\lambda}{Q} + c\lambda + \frac{hQ}{2} &&\text{the EOQ cost rate}\\ \frac{d\,\mathit{TC}}{dQ} &= -\frac{k\lambda}{Q^{2}} + 0 + \frac{h}{2} &&\text{power rule, term by term}\\ 0 &= -\frac{k\lambda}{Q^{2}} + \frac{h}{2} &&\text{a stationary point}\\ \frac{k\lambda}{Q^{2}} &= \frac{h}{2} &&\text{move the negative term across}\\ Q^{2} &= \frac{2k\lambda}{h} &&\text{multiply by } 2Q^{2}/h\\ Q^{*} &= \sqrt{\frac{2k\lambda}{h}} &&\text{the positive root, since } Q > 0 \end{aligned} \]

which is Equation 3.17. On the item of Example 3.2, with \(k = \$800\), \(\lambda = 220\) units a year and \(h = \$216\) per unit per year, \(Q^{*} = \sqrt{352{,}000/216} = 40.37\) units.

B.1.2 Is It a Minimum?

A zero derivative marks a minimum, a maximum, or a flat point, and the derivative alone cannot say which. The second derivative \(d^{2}C/dQ^{2}\) can. It is the rate at which the slope itself changes. If it is positive at the stationary point, the slope is rising there, passing from negative to positive, and the point is a minimum.

On the economic order quantity,

\[ \begin{aligned} \frac{d\,\mathit{TC}}{dQ} &= -k\lambda Q^{-2} + \frac{h}{2} &&\text{the first derivative}\\ \frac{d^{2}\,\mathit{TC}}{dQ^{2}} &= 2k\lambda Q^{-3} = \frac{2k\lambda}{Q^{3}} &&\text{power rule again; } h/2 \text{ is constant} \end{aligned} \]

and at \(Q^{*} = 40.37\) on Example 3.2 this is \(2(800)(220)/(40.37)^{3} = 352{,}000/65{,}786 = 5.35\), which is positive. Thus, 40.37 units is a minimum and not a maximum.

B.1.3 Convexity

The check in Section B.1.2 was made at one point. A stronger property makes it unnecessary. A function is convex if the straight line joining any two points on its graph lies on or above the graph. For a function that can be differentiated twice, that is the same as a second derivative that is never negative.

Two facts make convexity the most useful property in this book.

  1. A stationary point of a convex function is its minimum. The slope of a convex function never decreases, so once it reaches zero it cannot turn negative again. Every point to the left has a negative slope and every point to the right a positive one. In other words, there is no other valley to find.
  2. A sum of convex functions is convex. The second derivative of a sum is the sum of the second derivatives, and a sum of numbers that are never negative is never negative.

The economic order quantity has both. Its second derivative \(2k\lambda/Q^{3}\) is positive for every \(Q > 0\), so \(\mathit{TC}\) is convex on the whole range, and \(Q^{*}\) is the minimum without any further check. The production model of Section 3.5.2 has the same shape with \(h(1-\lambda/p)\) in place of \(h\), so it is convex too. Fact 2 is what Section 4.2.1 uses: a sum of economic order quantity costs, one per item, is convex, so each item can be optimized alone when no constraint couples them.

B.1.4 The Boundary

A decision is often limited, for example to \(Q \ge 0\) or to a backorder level that cannot be negative. If the stationary point of a convex function lies outside the allowed range, the minimum over the range is at the boundary nearest to it. That is, the function falls all the way to the edge and is still falling there.

Section 3.4 meets this case. When the shortage price \(\pi\) is large, Equation 3.11 returns a negative backorder level, which is not allowed. The cost is convex in \(\hat{B}\) (Section B.2 shows its second derivative is positive), so the best allowed value is the boundary \(\hat{B} = 0\), where the model reduces to the production quantity of Equation 3.14.

The general recipe, which every continuous optimization in the book follows, is:

  1. write the cost as a function of the decision;
  2. differentiate it and set the derivative to zero;
  3. solve for the decision;
  4. confirm a minimum by the second derivative, or by convexity;
  5. check that the answer is allowed, and if it is not, move to the boundary.

B.2 Two Variables

B.2.1 Partial Derivatives

Let \(C(Q, B)\) represent a cost that depends on two decisions. The partial derivative \(\partial C/\partial Q\) is the derivative with respect to \(Q\) with \(B\) held fixed, and \(\partial C/\partial B\) the derivative with respect to \(B\) with \(Q\) held fixed. At an interior minimum both are zero, because a small move in either direction alone must not lower the cost. Thus, a two-variable problem gives two equations, and its stationary point is their common solution.

B.2.2 The General Lot Sizing Model

We derive Equation 3.10 and Equation 3.11 this way. Let \(a\) represent the factor \(1 - \lambda/p\). Dropping the purchase term \(c\lambda\), which depends on neither decision, the relevant part of Equation 3.9 is

\[ C(Q, \hat{B}) = \frac{k\lambda}{Q} + \frac{h(Qa - \hat{B})^{2} + b\hat{B}^{2} + 2\pi\lambda\hat{B}}{2Qa} \]

The partial derivative in \(\hat{B}\). Only the numerator of the second term contains \(\hat{B}\), and the denominator \(2Qa\) is a constant when \(Q\) is held fixed:

\[ \begin{aligned} \frac{\partial C}{\partial \hat{B}} &= \frac{-2h(Qa - \hat{B}) + 2b\hat{B} + 2\pi\lambda}{2Qa} &&\text{chain rule on } (Qa - \hat{B})^{2}\\ 0 &= -hQa + h\hat{B} + b\hat{B} + \pi\lambda &&\text{set to zero; multiply by } Qa\\ \hat{B}^{*}(Q) &= \frac{hQa - \pi\lambda}{h + b} &&\text{collect the } \hat{B} \text{ terms} \end{aligned} \]

which is Equation 3.11 once \(Q\) is known. Its second derivative in \(\hat{B}\) is \((h + b)/(Qa)\), which is positive, so for each \(Q\) this is the best backorder level.

Substitute it back. Rather than solve the second partial derivative with both unknowns in it, we put the best \(\hat{B}\) for each \(Q\) into the cost and are left with one variable. With \(\hat{B}^{*}(Q)\), the two pieces of the numerator are

\[ Qa - \hat{B}^{*} = \frac{bQa + \pi\lambda}{h+b}, \qquad \hat{B}^{*} = \frac{hQa - \pi\lambda}{h+b} \]

and expanding the numerator and collecting terms,

\[ \begin{aligned} h(Qa - \hat{B}^{*})^{2} + b\hat{B}^{*2} &= \frac{h(bQa + \pi\lambda)^{2} + b(hQa - \pi\lambda)^{2}}{(h+b)^{2}} &&\text{substitute}\\ &= \frac{hb(h+b)Q^{2}a^{2} + (h+b)\pi^{2}\lambda^{2}}{(h+b)^{2}} &&\text{the } Qa\pi\lambda \text{ terms cancel}\\ &= \frac{hbQ^{2}a^{2} + \pi^{2}\lambda^{2}}{h+b} &&\text{divide out } h+b\\ 2\pi\lambda\hat{B}^{*} &= \frac{2\pi\lambda hQa - 2\pi^{2}\lambda^{2}}{h+b} &&\text{the stockout term} \end{aligned} \]

The numerator is the sum of the last two lines, \((hbQ^{2}a^{2} + 2\pi\lambda hQa - \pi^{2}\lambda^{2})/(h+b)\), and dividing it by \(2Qa\) gives the cost of one variable,

\[ C(Q) = \frac{k\lambda}{Q} + \frac{hb}{h+b}\cdot\frac{Qa}{2} + \frac{\pi\lambda h}{h+b} - \frac{\pi^{2}\lambda^{2}}{2Qa(h+b)} \]

The derivative in \(Q\). The third term is a constant. Differentiating the others,

\[ \begin{aligned} \frac{dC}{dQ} &= -\frac{k\lambda}{Q^{2}} + \frac{hba}{2(h+b)} + \frac{\pi^{2}\lambda^{2}}{2Q^{2}a(h+b)} &&\text{power rule, term by term}\\ 0 &= -\left[k\lambda - \frac{\pi^{2}\lambda^{2}}{2a(h+b)}\right]\frac{1}{Q^{2}} + \frac{hba}{2(h+b)} &&\text{set to zero}\\ Q^{2} &= \frac{2(h+b)}{hba}\left[k\lambda - \frac{\pi^{2}\lambda^{2}}{2a(h+b)}\right] &&\text{solve for } Q^{2}\\ Q^{*2} &= \frac{h+b}{b}\left[\frac{2k\lambda}{ha} - \frac{\pi^{2}\lambda^{2}}{h(h+b)a^{2}}\right] &&\text{factor out } (h+b)/b \end{aligned} \]

and taking the positive root with \(a = 1 - \lambda/p\) is Equation 3.10.

Is it a minimum? The second derivative of \(C(Q)\) is \((2/Q^{3})[k\lambda - \pi^{2}\lambda^{2}/(2a(h+b))]\). That is positive exactly when the bracket is positive, which is exactly when \(Q^{*2}\) is positive and the root exists. Thus, whenever Equation 3.10 returns a number, it is a minimum, and when it does not, the minimum is on the boundary of Section B.1.4.

A numerical instance. Section 3.4 uses \(\lambda = 100\), \(p = 250\), \(k = 20\), \(h = 4\) and \(b = 6\). With \(\pi = 0\), \(a = 0.6\) and

\[ \begin{aligned} Q^{*} &= \sqrt{\frac{10}{6}}\sqrt{\frac{2(20)(100)}{4(0.6)}} = (1.2910)(40.8248) = 52.70 \text{ units}\\ \hat{B}^{*} &= \frac{4(52.70)(0.6)}{10} = 12.65 \text{ units} \end{aligned} \]

With \(\pi = 1\) the bracket shrinks, \(Q^{*} = 40.25\), and \(\hat{B}^{*} = [4(40.25)(0.6) - 100]/10 = -0.34\), which is negative. That is the case Section 3.4 describes: the best allowed backorder level is zero.

B.3 Optimizing Over Whole Numbers

B.3.1 First Differences

A reorder point, a base-stock level and a number of spares are whole numbers, and a derivative does not exist on whole numbers. Its replacement is the difference between neighbors. Let \(C(x)\) represent a cost at the whole number \(x\), and let

\[ \Delta C(x) = C(x+1) - C(x) \tag{B.1}\]

represent its first difference, the change in cost from one more unit. Where \(\Delta C(x)\) is negative, one more unit lowers the cost, and where it is positive, one more unit raises it.

B.3.2 Discrete Convexity and the Rule

A function of whole numbers is discretely convex if its first differences never decrease: \(\Delta C(x) \le \Delta C(x+1)\) for every \(x\). This is the whole-number form of a second derivative that is never negative.

For a discretely convex cost, the minimum is at

\[ x^{*} = \min\{x : \Delta C(x) \ge 0\} \tag{B.2}\]

the smallest whole number at which one more unit stops lowering the cost. The argument is the same as in Section B.1.3. The differences never decrease, so once one is zero or positive, every later one is too, and no larger \(x\) can be cheaper. Every earlier difference is negative, so no smaller \(x\) can be cheaper either.

For example, the base-stock cost of the transformer, Table 8.10, has \(C(10) = \$5{,}218.57\), \(C(11) = \$4{,}859.83\) and \(C(12) = \$5{,}057.03\). Thus, \(\Delta C(10) = 4{,}859.83 - 5{,}218.57 = -358.74\), which is negative, and \(\Delta C(11) = 5{,}057.03 - 4{,}859.83 = 197.20\), which is not, so \(x^{*} = 11\). Equation 8.15 gives the same differences in closed form, \(\Delta C(S) = h - (h+b)G^{0}(S)\). With \(h = 950\), \(h + b = 9{,}500\) and the Poisson values \(G^{0}(10) = 0.137762\) and \(G^{0}(11) = 0.079241\), it gives \(950 - 1{,}308.74 = -358.74\) and \(950 - 752.79 = 197.21\), which agree to the cent.

B.3.3 When the Rule Fails

The rule needs discrete convexity, and without it the first stopping point may be the wrong one. Consider the costs

Table B.1: A cost that is not discretely convex. The differences fall from \(+1\) to \(-2\).
\(x\) 0 1 2 3 4
\(C(x)\) 5 3 4 2 6
\(\Delta C(x)\) \(-2\) \(+1\) \(-2\) \(+4\)

Notice in Table B.1 that the first non-negative difference is at \(x = 1\), so Equation B.2 returns \(x = 1\) at a cost of 3. The true minimum is at \(x = 3\), at a cost of 2. The rule stopped at a local minimum because the differences decreased afterward. Thus, before applying the rule, confirm that the differences never decrease, or know from the model that they cannot.

B.3.4 Expectations Keep Convexity

The costs of this book are expectations, such as the expected holding and backorder cost at a base-stock level. Convexity survives taking an expectation. If \(f(y)\) is discretely convex and \(D\) is a random demand, then \(E[f(S - D)]\) is discretely convex in \(S\). By Equation B.1,

\[ \begin{aligned} \Delta_{S} E[f(S - D)] &= E[f(S + 1 - D)] - E[f(S - D)] &&\text{the definition of a first difference}\\ &= E[\Delta f(S - D)] &&\text{the expectation of a difference} \end{aligned} \]

and each \(\Delta f(S - D)\) never decreases as \(S\) rises, so neither does its average. This is the step Section 8.6.1 uses. In the base-stock case it can also be seen directly: \(\Delta C(S) = h - (h+b)G^{0}(S)\), and \(G^{0}(S)\) never increases, so \(\Delta C(S)\) never decreases.

B.3.5 Marginal Analysis

Several items, each with a discretely convex cost, may share a budget of units. Let \(x_j\) represent the units given to item \(j\), and suppose the total cost \(\sum_j C_j(x_j)\) is to be minimized with \(\sum_j x_j\) fixed. Marginal analysis adds units one at a time, each to the item whose cost falls the most from it, that is, the item with the most negative \(\Delta C_j(x_j)\). For separable discretely convex costs this greedy rule is optimal at every total it reaches, because each item’s differences never decrease and the best next unit is never one that an earlier choice made worse.

When units cost different amounts, the rule ranks by the fall in cost per dollar, \(-\Delta C_j(x_j)/c_j\). It is then optimal at every budget the greedy sequence actually spends, and a budget between two of those totals can leave money idle. Section 10.9.2 applies this ranking to spares, and Section 10.9.3 meets the case in which an item’s curve is not convex.

B.3.6 The Lower Convex Hull

When a curve of cost against units is not convex, the greedy rule can be applied to its lower convex hull instead: the largest convex curve that lies on or below it. The hull keeps the points a convex curve would pass through and drops the points that sit above the line joining their neighbors. In Table B.1, the point \((2, 4)\) sits above the line from \((1, 3)\) to \((3, 2)\), which passes through \((2, 2.5)\) there, so the hull drops it. The hull is \((0, 5), (1, 3), (3, 2), (4, 6)\), with differences \(-2\), then \(-0.5\) per unit across the gap, then \(+4\), which never decrease. Greedy steps on it never stop at a local minimum. Section 10.9.3 strikes points from an allocation curve this way.

B.4 Differentiating an Integral

B.4.1 The Fundamental Theorem of Calculus

The expected costs of the single-period and continuous review models are integrals whose limits contain the decision. Let \(f(x)\) represent a function that is continuous. The fundamental theorem of calculus states that

\[ \frac{d}{db}\int_{a}^{b} f(x)\,dx = f(b), \qquad \frac{d}{db}\int_{b}^{\infty} f(x)\,dx = -f(b) \tag{B.3}\]

In words, raising the upper limit adds a slice of area of height \(f(b)\), and raising the lower limit removes one. Section D.3.4 uses the second form to show that \(dG^{1}(b)/db = -G^{0}(b)\).

B.4.2 The Leibniz Rule

When the decision appears inside the integrand as well as in a limit, the Leibniz rule applies. For a lower limit \(a\) that does not depend on \(Q\),

\[ \frac{d}{dQ}\int_{a}^{Q} g(x, Q)\,dx = g(Q, Q) + \int_{a}^{Q}\frac{\partial g(x, Q)}{\partial Q}\,dx \tag{B.4}\]

and with the decision in the lower limit, the boundary term enters with a minus sign. That is, the derivative has two parts: what the moving limit adds, and how the integrand itself changes.

B.4.3 The Newsvendor

The expected cost of the newsvendor, with continuous demand of density \(f\) and distribution \(F\), overage cost \(c_{o}\) and underage cost \(c_{u}\), is

\[ E[C(Q)] = c_{o}\int_{0}^{Q}(Q - x)f(x)\,dx + c_{u}\int_{Q}^{\infty}(x - Q)f(x)\,dx \]

We differentiate each integral by Equation B.4. In both, the integrand is zero at the moving limit \(x = Q\), so the boundary terms vanish:

\[ \begin{aligned} \frac{d}{dQ}\int_{0}^{Q}(Q - x)f(x)\,dx &= (Q - Q)f(Q) + \int_{0}^{Q}f(x)\,dx = F(Q) &&\text{the Leibniz rule}\\ \frac{d}{dQ}\int_{Q}^{\infty}(x - Q)f(x)\,dx &= -(Q - Q)f(Q) - \int_{Q}^{\infty}f(x)\,dx &&\text{lower limit, minus sign}\\ &= -\left[1 - F(Q)\right] &&\text{the tail of the density}\\ \frac{dE[C(Q)]}{dQ} &= c_{o}F(Q) - c_{u}\left[1 - F(Q)\right] &&\text{combine}\\ 0 &= (c_{o} + c_{u})F(Q) - c_{u} &&\text{a stationary point}\\ F(Q^{*}) &= \frac{c_{u}}{c_{u} + c_{o}} &&\text{the critical ratio} \end{aligned} \]

and differentiating once more, \(d^{2}E[C(Q)]/dQ^{2} = (c_{o} + c_{u})f(Q)\), which is never negative because a density is never negative. Thus, the expected cost is convex, and the critical ratio gives the minimum.

For the belt of Example 7.2, \(c_{o} = \$38\) and \(c_{u} = \$45\), so \(F(Q^{*}) = 45/83 = 0.5422\). With the normal approximation of mean 465.37 and standard deviation 92.64 that the example uses, the standard normal point at 0.5422 is 0.1059, and \(Q^{*} = 465.37 + 0.1059(92.64) = 475.18\), which rounds to the example’s 475 belts.

B.4.4 Approximating an Integral: Simpson’s Rule

Some integrals in the book have no closed form, and the cycle averages of Section 9.1 are the main ones. Let \(f(x)\) represent a function on the interval \([a, b]\), and let \(m = (a + b)/2\) represent its midpoint. Simpson’s rule fits the parabola through the three points \((a, f(a))\), \((m, f(m))\) and \((b, f(b))\) and integrates the parabola instead of \(f\):

\[ \int_{a}^{b} f(x)\,dx \approx \frac{b - a}{6}\left[f(a) + 4f(m) + f(b)\right] \tag{B.5}\]

Two properties matter. The rule is exact whenever \(f\) is a polynomial of degree three or less, which is more than the parabola alone would suggest, because the error of the cubic term cancels between the two halves. Otherwise its error is \(-\tfrac{(b-a)^{5}}{2880}f^{(4)}(\xi)\) for some \(\xi\) in the interval. That is, the error grows with the curvature of \(f\) and falls fast as the interval shrinks.

Thus, a long interval is split into an even number \(n\) of pieces of width \(h = (b - a)/n\), and the rule is applied to each pair:

\[ \int_{a}^{b} f(x)\,dx \approx \frac{h}{3}\left[f_{0} + 4f_{1} + 2f_{2} + 4f_{3} + \cdots + 4f_{n-1} + f_{n}\right] \tag{B.6}\]

where \(f_{i} = f(a + ih)\). For example, Equation 9.11 averages the transformer’s first order loss function over a review cycle from three lookups, \(\tfrac{1}{6}[0.0181 + 4(0.1156) + 0.4200] = 0.1501\), and the code’s composite rule on 128 pieces agrees to four decimals. Dividing Equation B.5 by \(b - a\) is what turns the integral into the average of Equation C.6.

B.5 Constrained Optimization

B.5.1 A Constraint That Binds

Let a decision \(\vec{Q} = (Q_1, \ldots, Q_n)\) minimize a cost \(C(\vec{Q})\) subject to a limit \(g(\vec{Q}) \le A\), where \(g\) measures a shared resource such as investment. If the minimum without the limit already satisfies it, the limit does not matter. If it violates it, the limit binds, and for a convex cost and a resource that rises with the decisions, the constrained minimum lies on the boundary \(g(\vec{Q}) = A\). In other words, there is no reason to stop short of the limit, because moving toward the unconstrained minimum lowers the cost all the way to the edge. That is the step Section 4.2.1 takes when it treats the inequality as an equality.

B.5.2 The Lagrangian

Let \(\theta\) represent a number called the Lagrange multiplier, and form the Lagrangian

\[ L(\vec{Q}, \theta) = C(\vec{Q}) + \theta\left[g(\vec{Q}) - A\right] \tag{B.7}\]

The multiplier is a price charged on each unit of the resource used beyond the limit and refunded on each unit left unused. For a fixed \(\theta\), minimizing \(L\) over \(\vec{Q}\) is an unconstrained problem. The idea of the method is to find the price at which that unconstrained answer uses exactly \(A\) of the resource. At that \(\theta^{*}\) the bracket in Equation B.7 is zero, so \(L = C\), and a decision that minimizes \(L\) among all decisions minimizes \(C\) among the decisions that meet the limit. For a convex cost and a convex resource function, such a \(\theta^{*}\) exists whenever the limit can be met with room to spare, that is, whenever some decision uses strictly less than \(A\).

Three conditions summarize the method, and together they are called the Karush-Kuhn-Tucker conditions:

  1. stationarity: \(\partial L/\partial Q_j = 0\) for every \(j\);
  2. feasibility: \(g(\vec{Q}) \le A\), and \(\theta \ge 0\);
  3. complementary slackness: \(\theta[g(\vec{Q}) - A] = 0\). That is, either the limit binds or its price is zero.

The sign \(\theta \ge 0\) matters. A negative price would reward using more of a scarce resource, which moves the answer the wrong way.

B.5.3 Working the Investment Limit

Example 4.1 minimizes the sum of three economic order quantity costs with the average investment \(\sum_j c_jQ_j/2\) held to $10,000, so \(g(\vec{Q}) = \sum_j c_jQ_j/2\) and \(A = 10{,}000\). Stationarity for item \(j\) is

\[ \begin{aligned} \frac{\partial L}{\partial Q_j} &= -\frac{k_j\lambda_j}{Q_j^{2}} + \frac{h_j}{2} + \theta\,\frac{c_j}{2} &&\text{only item } j\text{'s terms contain } Q_j\\ 0 &= -\frac{k_j\lambda_j}{Q_j^{2}} + \frac{h_j + \theta c_j}{2} &&\text{set to zero; collect}\\ Q_j(\theta) &= \sqrt{\frac{2k_j\lambda_j}{h_j + \theta c_j}} &&\text{solve as for the EOQ} \end{aligned} \]

which is an economic order quantity with the holding rate raised by \(\theta c_j\). In other words, the price on investment is charged as extra carrying cost. The multiplier is then the root of the investment at \(\theta\) less $10,000, which Table 4.3 finds by bisection at \(\theta^{*} = 0.14643\).

B.5.4 The Multiplier Is a Price

Let \(C^{*}(A)\) represent the least cost when the limit is \(A\). Then

\[ \frac{dC^{*}}{dA} = -\theta^{*} \tag{B.8}\]

That is, one more dollar of limit lowers the least cost by \(\theta^{*}\) dollars, and \(\theta^{*}\) is called the shadow price of the resource. The reason is in Equation B.7: at the optimum \(C^{*} = L\), and \(A\) enters \(L\) only through the term \(-\theta A\).

We check it on Example 4.1 by solving again at limits of $9,900 and $10,100, with $10,000 giving the least cost of $7,464.30 a year. The least costs at the two new limits are $7,479.39 and $7,450.10, and the central difference is

\[ \frac{C^{*}(10{,}100) - C^{*}(9{,}900)}{200} = \frac{7{,}450.10 - 7{,}479.39}{200} = -0.1465 \]

which agrees with \(\theta^{*} = 0.14643\) to three decimals. Notice that a forward difference does worse. From $10,000 to $10,100 alone it gives \((7{,}450.10 - 7{,}464.30)/100 = -0.1420\), because \(C^{*}\) curves and the forward difference measures the slope halfway along the step rather than at $10,000. Thus, Equation B.8 is a statement about a small change, and a central difference is the way to check it.

The multiplier says what a dollar of investment is worth to this distributor: about 15 cents a year. If capital costs less than that, the limit is too tight.

B.5.5 Lagrangian Relaxation

When the decisions are whole numbers, as with spares, the same price can be used without a derivative. Fix \(\theta\), minimize \(L\) item by item by Equation B.2, add up the resource used, and adjust \(\theta\) until the total meets the limit. This is Lagrangian relaxation. Because the costs and resources are whole-number functions, there may be no \(\theta\) at which the total lands exactly on the limit, and the method then returns the best answers on either side. Section 10.9.7 uses it on the spares budget.

B.6 Solving an Equation Numerically

B.6.1 Bisection

Many conditions in the book are equations with no formula for their root: the multiplier of Example 4.1, a reorder point that meets a fill rate, a level read off a distribution. Let \(R(\theta)\) represent a function whose root is wanted. The intermediate value theorem says that if \(R\) is continuous and changes sign between two values, it has a root between them. If \(R\) is also monotone, always falling or always rising, the root is unique.

Bisection uses both facts. Start with two values that bracket the root, one with \(R\) positive and one with \(R\) negative. Evaluate \(R\) at the midpoint and keep the half in which the sign changes. Each pass halves the bracket, so after \(m\) passes the root is known to within the starting width divided by \(2^{m}\). Table 4.3 runs eight passes on Example 4.1, from a bracket of width 0.30 to one of width \(0.30/2^{8} = 0.0012\). The method is slow, and it cannot fail.

B.6.2 Fixed-Point Iteration

Some conditions are written as \(x = \phi(x)\): the unknown on the left is a function of itself on the right. The classical approximation of Section 8.9 is one, because \(Q\) depends on \(r\) and \(r\) depends on \(Q\). Fixed-point iteration guesses \(x_0\), computes \(x_1 = \phi(x_0)\), then \(x_2 = \phi(x_1)\), and continues until two successive values agree to the precision wanted.

The method converges when the values settle on a single number, and that number then satisfies \(x = \phi(x)\). It is guaranteed to when \(\phi\) moves points closer together, which is the condition that \(|d\phi/dx| < 1\) near the root. The smaller that slope, the faster it settles. Table 8.12 converges in three passes; Table 8.14 closes about three quarters of the remaining distance per pass, which is a slope near 0.25. Iteration can also fail to converge, or converge slowly, so every iteration in the book reports its passes.

B.7 Dynamic Programming

Some problems are a sequence of decisions, each changing what the next one faces. Let the stage represent the point in the sequence, and the state what the decision maker needs to know there. Dynamic programming solves such a problem backward or forward from one end, using the principle of optimality: whatever the earlier decisions were, the remaining decisions must be optimal for the state they produced. Thus, the best plan can be built from the best plans of smaller problems, and each smaller problem is solved once.

The Wagner-Whitin recursion of Section 5.4.2 is a dynamic program. The stage is the period \(u\), and \(V(u)\) is the least cost of meeting the requirements of periods 1 through \(u\). If the last order in such a plan is placed in period \(t\), it covers periods \(t\) through \(u\) at the window cost \(w(t, u)\), and the earlier periods must be covered as cheaply as possible, at \(V(t-1)\). Thus,

\[ V(u) = \min_{1 \le t \le u}\left[V(t-1) + w(t, u)\right], \qquad V(0) = 0 \tag{B.9}\]

On Table 5.5, \(V(4) = \min[0 + 1{,}500,\ 300 + 1{,}020,\ 360 + 600,\ 600 + 300] = \$900\). The same problem is a shortest path: draw a node for each period boundary, an arc from \(t - 1\) to \(u\) costing \(w(t, u)\), and \(V(u)\) is the length of the shortest path from node 0 to node \(u\). The network has no cycles, because every arc runs forward in time, so the shortest path can be found in one pass in time order. Section 5.4.1 draws it.

The work grows with the square of the horizon \(N\), because each of the \(N\) columns compares up to \(N\) entries. That is written \(O(N^{2})\), read “of order \(N\) squared”: doubling the horizon roughly quadruples the work.

B.8 Series and Sums

A finite geometric series is a sum in which each term is the one before times a fixed ratio \(r\). Let \(S_n = 1 + r + r^{2} + \cdots + r^{n-1}\). Then

\[ \begin{aligned} S_n - rS_n &= (1 + r + \cdots + r^{n-1}) - (r + r^{2} + \cdots + r^{n}) &&\text{shift each term one place}\\ &= 1 - r^{n} &&\text{every term between cancels}\\ S_n &= \frac{1 - r^{n}}{1 - r}, \quad r \ne 1 &&\text{divide by } 1 - r \end{aligned} \tag{B.10}\]

Equation 2.8 is this series with \(r = 1 - p\), divided by \(n\): the probability that a record is still correct after \(t\) periods is \((1-p)^{t}\), because it must stay correct in each of the \(t\) periods independently. For example, with \(p = 0.03\) and \(n = 4\), \(S_4 = (1 - 0.97^{4})/0.03 = 0.1147/0.03 = 3.8236\), and dividing by 4 gives the 95.6% of Example 2.7.

Two further sums appear where a quantity is spread evenly over whole units, as in the discrete uniform of Section C.1.2:

\[ \sum_{i=1}^{n} i = \frac{n(n+1)}{2}, \qquad \sum_{i=1}^{n} i^{2} = \frac{n(n+1)(2n+1)}{6} \tag{B.11}\]

For example, with \(n = 4\) these are \(1 + 2 + 3 + 4 = 10 = 4(5)/2\) and \(1 + 4 + 9 + 16 = 30 = 4(5)(9)/6\).

B.9 K-Convexity

Theorem 9.1 proves that an \((s, S)\) policy is optimal when every order carries a fixed cost \(k\). Its proof uses a weakened convexity. A function \(C\) is \(K\)-convex if, for any \(x\), any \(y > 0\) and any \(z > 0\),

\[ K + C(x + y) \ge C(x) + y\,\frac{C(x) - C(x - z)}{z} \]

That is, the function may dip below the straight-line extension of an earlier chord, but never by more than \(K\). With \(K = 0\) this is ordinary convexity. The property survives the expectations and the period-to-period recursion of the multi-period problem, which is what lets Scarf (1960) conclude that an order-up-to level with a reorder point is the best form. Zipkin (2000) gives the proof in its inventory setting. The book needs only the statement of the theorem, not the proof.

B.10 Exercises

Exercise B.1 An item is demanded at \(\lambda = 2{,}400\) units a year and produced at \(p = 9{,}600\) units a year. The setup cost is \(k = \$75\) and the holding cost is \(h = \$4\) per unit per year. No shortages are permitted.

  1. Write the cost rate of Equation 3.13 without the purchase term.
  2. Differentiate it, set the derivative to zero, and solve for \(Q^{*}\). Report it to two decimals.
  3. Compute the second derivative at \(Q^{*}\) and say what it shows.

Exercise B.2 Take the item of Exercise B.1, but let it be bought rather than produced, so that \(p \to \infty\) and \(a = 1\). Backorders are permitted at \(b = \$16\) per unit per year, and \(\pi = 0\).

  1. Write the relevant cost \(C(Q, \hat{B})\) and its two partial derivatives.
  2. Solve the pair for \(Q^{*}\) and \(\hat{B}^{*}\), reporting both to two decimals.
  3. Confirm that \(\hat{B}^{*}/Q^{*} = h/(h+b)\).

Exercise B.3 A base-stock cost takes the values below at the levels \(S = 4\) through \(S = 10\).

\(S\) 4 5 6 7 8 9 10
\(C(S)\) 920 610 470 455 510 600 715
  1. Compute every first difference.
  2. Are the differences non-decreasing? Apply Equation B.2 and report \(S^{*}\).
  3. Change \(C(9)\) to 430 and repeat part (b). Which level does the rule now return, which level is optimal, and why do they differ?

Exercise B.4 Demand for a seasonal item is normal with mean 200 units and standard deviation 40 units. Each unit costs $30, sells for $60 and salvages for $10.

  1. Find \(c_{o}\) and \(c_{u}\).
  2. Differentiate the expected cost by Equation B.4 and obtain the critical ratio.
  3. Compute \(Q^{*}\) to two decimals, using a standard normal point to four decimals.

Exercise B.5 Two items share an investment limit of $1,200 of average investment. Item 1 has \(\lambda_1 = 1{,}000\) a year and \(c_1 = \$10\); item 2 has \(\lambda_2 = 4{,}000\) a year and \(c_2 = \$5\). Each costs \(k = \$40\) to order, and the carrying charge is \(i = 0.20\) per year.

  1. Find the unconstrained order quantities and the investment they require. Does the limit bind?
  2. Form the Lagrangian and derive \(Q_j(\theta)\).
  3. Find \(\theta^{*}\) to four decimals, by bisection or algebra, and the quantities.
  4. Interpret \(\theta^{*}\) as a shadow price, in dollars a year per dollar of limit.

Exercise B.6 Answer each part in a sentence or two.

  1. A cost function of one variable has a zero derivative at \(Q = 50\) and a second derivative of \(-3\) there. What is \(Q = 50\)?
  2. Why does Equation B.2 need the first differences to be non-decreasing, when the continuous recipe of Section B.1.4 only needs convexity? Are these the same requirement?
  3. A multiplier comes out negative. What does that say about the constraint?
  4. Why can bisection not fail on a continuous monotone function, while fixed-point iteration can?