Skip to content

Vol. II, Ch. 4

DCT Laboratory — Volume II, Chapter 4

Nonlinear and Mixed-Integer Enterprise Optimization

Seed 26204 · Companion to Chapter 4 and AXIOM Lab 2.4 (module AXIOM-04) · Mirrored in DCT_V2_Ch04_Lab.xlsx

This laboratory reproduces Worked Example 4.1, Can Meridian Automate Part of a Line?, with the book's declarations, and works the five steps of AXIOM Lab 2.4: explore, search, audit, bound, branch. It ends with two of the chapter's other Meridian results: a price list on a lumpy capital cap (Proposition 4.1(iii)) and Worked Example 1.1's package solved by branch-and-bound (Section 4.5). Every Meridian number below is the book's (Table 4.4, Figures 4.1–4.3, Online Appendix 4.B.2–4.B.3); the final cell checks them. Money is in $ million.

The declarations (Worked Example 4.1, the situation and Step 1)

The automation program of Worked Example 2.1 (Volume I, Worked Example 6.1): a round costs $120 million and closes half of the efficiency gap between today's 71 and the ceiling of 85; each point gained saves $10 million a year from the year of the round. Liquidity starts at $620 million; the board's floor of $350 million must hold after paying for a round and at each year end, and year 6 must end with $470 million, the cash for another round. Both executive pledges are dropped, as in Worked Example 3.1: payouts are free, and a plan is worth its payouts over six years plus twenty years of its year-6 savings, the credit the board now gives for the expected life of the automated lines (Chapters 2 and 3 gave ten). All amounts are undiscounted.

The chief operating officer's declaration: a fraction zz of a round costs $120 million times zz and closes the fraction z/2z/2 of the remaining gap, each automated station doing its share of a whole round's work. The gap after year kk is 14∏j≤k(1−zj/2)14\prod_{j \le k}(1 - z_j/2) points, Volume I's recursion read for fractions and identical at whole rounds. Payouts can wait, so the floors never bind, and a plan z∈[0,1]6\mathbf{z} \in [0, 1]^6 is worth the cash it frees above $470 million plus twenty years of its year-6 savings: V(z)=150+∑kSk−120∑kzk+20 S6,Sk=140−10×gapk.V(\mathbf{z}) = 150 + \sum_k S_k - 120\sum_k z_k + 20\,S_6, \qquad S_k = 140 - 10 \times \text{gap}_k . Chapter 3's relaxation writes the gap after Zk=z1+⋯+zkZ_k = z_1 + \cdots + z_k rounds as 14×2−Zk14 \times 2^{-Z_k}: the form that agrees with Volume I's recursion at every plan of whole rounds and makes the instance convex.

Python Code
import warnings
import numpy as np
from scipy.optimize import minimize, Bounds, NonlinearConstraint
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, StrMethodFormatter
plt.rcParams.update({"figure.dpi": 110, "axes.spines.top": False, "axes.spines.right": False})
MONEY = StrMethodFormatter("{x:,.0f}")     # axis ticks in $ million, with thousands separators
SEED = 26204          # the lab's seed: random plans in Panel 1, fresh starts in Panel 3
BOOK_SEED = 2026      # the book's 100 starts (Online Appendix 4.B.3)

COST, GAP0, VAL = 120.0, 14.0, 10.0       # a round ($m); the efficiency gap today, 85 - 71; $m a year per point
Q0, FLOOR, Q_END = 620.0, 350.0, 470.0     # liquidity today; the board's floor; year 6's end condition
M, K = 20.0, 6                             # twenty years' credit for the year-6 savings; six years
SMAX, CASH = VAL * GAP0, Q0 - Q_END        # 140 a year with the gap closed; 150 of cash above 470 today
SLOPE = SMAX * np.log(2.0)                 # Chapter 3's savings 140 (1 - 2^-Z) rise at SLOPE x 2^-Z

def gaps(z):                               # each fraction z of a round closes z/2 of the remaining gap
    return GAP0 * np.cumprod(1.0 - np.asarray(z, float) / 2.0)

def savings(z):
    return SMAX - VAL * gaps(z)

def relaxed_savings(z):                    # Chapter 3's exponential form: the gap is 14 x 2^-Z after Z rounds
    return SMAX * (1.0 - 2.0 ** -np.cumsum(np.asarray(z, float)))

def value(z, M=M, sav=savings):            # payouts free: the cash above 470 at the end, plus M years of S_6
    z = np.asarray(z, float)
    S = sav(z)
    return CASH + S.sum() - COST * z.sum() + M * S[-1]

def ceiling(z, M=M):                       # the same plan valued in Chapter 3's relaxation
    return value(z, M, relaxed_savings)

def slack(z, sav=savings):                 # payouts deferred to year 6: the smallest slack in the floors and the end
    z = np.asarray(z, float)
    q = Q0 + np.cumsum(sav(z) - COST * z)              # year-end liquidity
    after = np.r_[Q0, q[:-1]] - COST * z               # liquidity just after paying for each round
    return min((after - FLOOR).min(), (q - FLOOR).min(), q[-1] - Q_END)

def marginal(z, M=M):                      # V is affine in each round: the unit difference is the exact derivative
    z = np.asarray(z, float)
    g = np.zeros(K)
    for j in range(K):
        hi, lo = z.copy(), z.copy()
        hi[j], lo[j] = 1.0, 0.0
        g[j] = value(hi, M) - value(lo, M)
    return g

def hessian(z, M=M):                       # exact second derivatives; zero on the diagonal
    z = np.asarray(z, float)
    H = np.zeros((K, K))
    for i in range(K):
        for j in range(i + 1, K):
            def v(a, b):
                u = z.copy()
                u[i], u[j] = a, b
                return value(u, M)
            H[i, j] = H[j, i] = v(1, 1) - v(1, 0) - v(0, 1) + v(0, 0)
    return H

def label(z):                              # "years 1–3 and 5"
    runs = []
    for y in [k + 1 for k in range(K) if z[k] > 0.5]:
        if runs and y == runs[-1][1] + 1:
            runs[-1][1] = y
        else:
            runs.append([y, y])
    parts = [f"{a}–{b}" if b > a else f"{a}" for a, b in runs]
    return "no round" if not parts else "years " + (parts[0] if len(parts) == 1 else ", ".join(parts[:-1]) + " and " + parts[-1])

SCHEDULES = [np.array(s, float) for s in np.ndindex(*(2,) * K)]       # the 64 plans of whole rounds
A3, A4, A5, A6 = (1, 1, 1, 0, 0, 0), (1, 1, 1, 1, 0, 0), (1, 1, 1, 0, 1, 0), (1, 1, 1, 0, 0, 1)

w = np.array(A4, float)
print(f"{label(A4)}: the gap after each year " + ", ".join(f"{g:g}" for g in gaps(w)) + " points; savings "
      + ", ".join(f"{s:g}" for s in savings(w)) + " a year")
print(f"{label(A4)} is worth {value(A4):,.2f} = {CASH:.0f} + {savings(A4).sum():.2f} of savings in years 1–6 "
      f"- {COST * w.sum():.0f} for four rounds + {M:.0f} x {savings(A4)[-1]:.2f}")
print(f"every one of the 64 plans of whole rounds keeps the floors and the end condition with at least "
      f"${min(slack(s) for s in SCHEDULES):.1f}m to spare")
years 1–4: the gap after each year 7, 3.5, 1.75, 0.875, 0.875, 0.875 points; savings 70, 105, 122.5, 131.25, 131.25, 131.25 a year
years 1–4 is worth 2,986.25 = 150 + 691.25 of savings in years 1–6 - 480 for four rounds + 20 x 131.25
every one of the 64 plans of whole rounds keeps the floors and the end condition with at least $85.0m to spare

Panel 1 — Model partial rounds (Worked Example 4.1, Step 1; Proposition 4.2(i): $2,982.61 million, $3.64 million less than none)

Rounds multiply, so VV is not concave (Chapter 3's chord test fails), but it is affine in each year's round when the others are fixed: the case of Proposition 4.2. Part (i) answers the chief operating officer's first question at once: part of a round is worth the same blend of none and a whole round, never more than the better of the two. Each slack in the floors is affine in each round too, so its smallest value over the box is taken at a corner: $85 million. At twenty years' credit, Chapter 3's relaxation runs 0.15 of a year-5 round; read for partial rounds that plan is worth $2,982.61 million, $3.64 million less than running none (Figure 4.1(b)). At ten years' credit, its 0.39 of a year-4 round would have lost $2.46 million. The exponential form overstates part rounds, 2−z≤1−z/22^{-z} \le 1 - z/2 for zz between 0 and 1, so its relaxation is a ceiling on this model too: a ceiling, not a plan.

Python Code
rng = np.random.default_rng(SEED)          # the lab's seed: 20,000 random plans for the structural checks
blend, low_slack, excess = 0.0, np.inf, np.inf
for _ in range(20_000):
    z, j, t = rng.random(K), rng.integers(K), rng.random()
    lo, hi, mid = z.copy(), z.copy(), z.copy()
    lo[j], hi[j], mid[j] = 0.0, 1.0, t
    blend = max(blend, abs(value(mid) - ((1 - t) * value(lo) + t * value(hi))))
    low_slack = min(low_slack, slack(z))
    excess = min(excess, (relaxed_savings(z) - savings(z)).min())
print(f"part of a round is the blend of none and a whole round: largest error over 20,000 random plans {blend:.1e}")
print(f"smallest slack in the floors: {min(slack(s) for s in SCHEDULES):.1f} at the corners, {low_slack:.1f} over the random plans")
half = 0.5 * (np.array(A4, float) + np.array(A5, float))
print(f"not concave: halfway between {label(A4)} and {label(A5)}, V = {value(half):,.2f}, below the average of the two, "
      f"{0.5 * (value(A4) + value(A5)):,.2f}")
zz = np.linspace(0.0, 1.0, 100_001)
print(f"2^-z <= 1 - z/2 on [0, 1] (smallest margin {((1 - zz / 2) - 2.0 ** -zz).min():.1e}): Chapter 3's savings exceed "
      f"these in every year (smallest excess {excess:.1e}), so its relaxation is a ceiling")

def ceiling_grad(z, M=M):                  # the marginal value of each round in the relaxation
    d = SLOPE * 2.0 ** -np.cumsum(z)
    return np.array([d[j:].sum() + M * d[-1] for j in range(K)]) - COST

def relaxation(M=M, fix0=(), fix1=()):
    # Chapter 3's relaxation, with some rounds fixed at none (fix0) or at a whole round (fix1): the value is concave
    # and only the box can bind (the floors keep their slack, its savings being larger), so SciPy's L-BFGS-B, a
    # quasi-Newton method for box limits, finds the best plan; its KKT residual certifies it
    lo, hi = np.zeros(K), np.ones(K)
    hi[list(fix0)], lo[list(fix1)] = 0.0, 1.0
    r = minimize(lambda z: -ceiling(z, M), (lo + hi) / 2, jac=lambda z: -ceiling_grad(z, M), method="L-BFGS-B",
                 bounds=list(zip(lo, hi)), options={"ftol": 1e-15, "gtol": 1e-11, "maxiter": 2000})
    z, g, kkt = r.x, ceiling_grad(r.x, M), 0.0
    for j in range(K):                     # a free round inside the box has marginal value 0, at 1 it is >= 0, at 0 <= 0
        if hi[j] > lo[j]:
            kkt = max(kkt, max(0.0, g[j]) if z[j] <= 1e-9 else max(0.0, -g[j]) if z[j] >= 1 - 1e-9 else abs(g[j]))
    return ceiling(z, M), z, kkt

C20, Z20, kkt20 = relaxation(20.0)
C10, Z10, kkt10 = relaxation(10.0)
print(f"\ntwenty years' credit: the relaxation runs {label(np.floor(Z20 + 1e-9))} and {Z20[4]:.3f} of a year-5 round, "
      f"ceiling {C20:,.2f} (KKT residual {kkt20:.0e})")
print(f"  read for partial rounds that plan is worth {value(Z20):,.2f}, {value(A4) - value(Z20):.2f} less than running none: "
      f"a year-5 round's marginal value is {marginal(A4)[4]:.2f} at every fraction")
print(f"ten years' credit: the relaxation runs {Z10[3]:.3f} of a year-4 round (ceiling {C10:,.2f}); here it is worth "
      f"{value(Z10, 10.0):,.2f}, {value(A3, 10.0) - value(Z10, 10.0):.2f} less than three whole rounds")

fig, axes = plt.subplots(1, 2, figsize=(7.6, 3.6))
t = np.linspace(0.0, 1.0, 201)
for ax, base, j, mm, zr, base_name in ((axes[0], A4, 4, 20.0, Z20, "none"), (axes[1], A3, 3, 10.0, Z10, "three rounds")):
    plans = [np.where(np.arange(K) == j, s, np.array(base, float)) for s in t]
    hi_v, lo_v = max(ceiling(p, mm) for p in plans), min(value(p, mm) for p in plans)
    span = hi_v - lo_v
    ax.plot(t, [ceiling(p, mm) for p in plans], color="#E65100", lw=2, label="Chapter 3's relaxation: a ceiling")
    ax.plot(t, [value(p, mm) for p in plans], color="#1F4E79", lw=2, label="partial rounds: a straight line")
    ax.plot(zr[j], ceiling(zr, mm), "o", color="#E65100", ms=6)
    ax.plot(zr[j], value(zr, mm), "o", color="#1F4E79", ms=6)
    ax.axvline(zr[j], color="#BDBDBD", lw=0.7, ls=":", zorder=0)
    ax.text(0.98, hi_v + 0.30 * span, f"relaxation: ceiling {ceiling(zr, mm):,.2f} at {zr[j]:.2f} of a round",
            color="#E65100", fontsize=7.5, ha="right", va="top")
    ax.text(0.98, hi_v + 0.20 * span, f"partial rounds: {value(zr, mm):,.2f} there, {value(base, mm) - value(zr, mm):.2f} "
            f"below {base_name}", color="#1F4E79", fontsize=7.5, ha="right", va="top")
    ax.set(xlim=(0, 1), ylim=(lo_v - 0.06 * span, hi_v + 0.32 * span),
           xlabel=f"part of a year-{j + 1} round added to {label(base)}")
    ax.yaxis.set_major_formatter(MONEY)
axes[0].set(ylabel=r"value (\$ million)", title="twenty years' credit")
axes[1].set(title="ten years' credit")
axes[0].legend(frameon=False, fontsize=7.5, loc="lower left")
for ax in axes:
    ax.title.set_fontsize(9)
fig.suptitle("Part of a round: a straight line under Chapter 3's ceiling (seed 26204)", fontsize=10)
plt.tight_layout(); plt.show()
part of a round is the blend of none and a whole round: largest error over 20,000 random plans 1.4e-12
smallest slack in the floors: 85.0 at the corners, 88.0 over the random plans
not concave: halfway between years 1–4 and years 1–3 and 5, V = 2,957.81, below the average of the two, 2,981.88
2^-z <= 1 - z/2 on [0, 1] (smallest margin 0.0e+00): Chapter 3's savings exceed these in every year (smallest excess 5.0e-04), so its relaxation is a ceiling

twenty years' credit: the relaxation runs years 1–4 and 0.153 of a year-5 round, ceiling 2,987.26 (KKT residual 4e-11)
  read for partial rounds that plan is worth 2,982.61, 3.64 less than running none: a year-5 round's marginal value is -23.75 at every fraction
ten years' credit: the relaxation runs 0.394 of a year-4 round (ceiling 1,687.09); here it is worth 1,677.54, 2.46 less than three whole rounds
Part of a round: a straight line under Chapter 3's ceiling (seed 26204)

Panel 2 — Explore: two peaks and a saddle (AXIOM Lab 2.4, step 1; Figure 4.1(a): a saddle at (0.75, 0.84) worth $2,966.20 million)

AXIOM Lab 2.4, step 1. Hold whole rounds in years 1–3 and none in year 6, and let the year-4 round xx and the year-5 round yy vary: the value is 2,905+81.25x+72.5y−96.25xy2{,}905 + 81.25x + 72.5y - 96.25xy. The corners that run only the year-4 round or only the year-5 round are strict local maxima, every marginal value pointing out of the box (Proposition 4.2(iii)). Inside the face both marginal values vanish at 0.75 of a round in year 4 and 0.84 in year 5, a plan worth $2,966.20 million that passes the first-order test. The Hessian on the face has zeros on its diagonal, since VV is affine in each round, and −96.25-96.25 off it, at every point of the face: eigenvalues ±96.25\pm 96.25. Moving a fraction tt of a round from year 5 to year 4 adds 96.25 t296.25\,t^2, about $1 million for a tenth of a round: a saddle (Theorem 4.1(ii); Proposition 4.2(iv)). The dashed line, the saddle's line of slope 1, separates the plans from which an ascent reaches each corner.

Python Code
fa = value(A3)
fb, fc = value(A4) - fa, value(A5) - fa
fd = value((1, 1, 1, 1, 1, 0)) - value(A4) - value(A5) + fa
print(f"the face (years 1–3 whole, none in year 6): V = {fa:,.2f} + {fb:.2f}x + {fc:.2f}y {fd:+.2f}xy")
for x, y in ((0, 0), (1, 0), (0, 1), (1, 1)):
    g = fb + fd * y, fc + fd * x
    verdict = "strict local maximum" if (g[0] > 0) == (x == 1) and (g[1] > 0) == (y == 1) else "not a local maximum"
    print(f"  corner ({x}, {y}), {label((1, 1, 1, x, y, 0)):16s} V = {fa + fb * x + fc * y + fd * x * y:,.2f}; "
          f"marginal values {g[0]:+7.2f} (year 4), {g[1]:+7.2f} (year 5): {verdict}")
xs, ys = -fc / fd, -fb / fd                 # where both marginal values on the face vanish
SADDLE = np.array([1, 1, 1, xs, ys, 0.0])
Hf = hessian(SADDLE)[3:5, 3:5]
ev, evec = np.linalg.eigh(Hf)
print(f"stationary plan ({xs:.4f}, {ys:.4f}) = (72.5/96.25, 81.25/96.25): V = {value(SADDLE):,.2f}; "
      f"marginal values of years 4 and 5 {marginal(SADDLE)[3]:.0e}, {marginal(SADDLE)[4]:.0e}")
print(f"Hessian on the face {Hf.tolist()}, the same at every point: eigenvalues {ev[0]:+.2f} along (1, 1), "
      f"{ev[1]:+.2f} along (1, -1)")
print(f"moving t of a round from year 5 to year 4 adds {-fd:.2f} t^2: a tenth of a round adds {-fd * 0.01:.2f}")

fig, (ax, bx) = plt.subplots(1, 2, figsize=(7.6, 3.6), gridspec_kw={"width_ratios": [1, 1.2]})
X, Y = np.meshgrid(np.linspace(0, 1, 201), np.linspace(0, 1, 201))
F = fa + fb * X + fc * Y + fd * X * Y
ax.contourf(X, Y, F, levels=np.arange(2900, 2990.1, 5.0), cmap="Purples", alpha=0.3)
ax.contour(X, Y, F, levels=np.arange(2910, 2981, 10.0), colors="#9E9E9E", linewidths=0.5)
ax.plot([xs, xs], [0, 1], color="#616161", lw=0.6)          # the saddle's own level, 2,966.20: two straight lines
ax.plot([0, 1], [ys, ys], color="#616161", lw=0.6)
xx = np.linspace(0, 1, 50)
keep = (ys + xx - xs >= 0) & (ys + xx - xs <= 1)
ax.plot(xx[keep], (ys + xx - xs)[keep], color="#1A1A1A", lw=0.9, ls=(0, (4, 2)))
box = dict(boxstyle="square,pad=0.15", fc="white", ec="none", alpha=0.85)
for (x, y), name, (tx, ty) in (((1, 0), "years 1–4\n2,986.25", (0.70, 0.13)), ((0, 1), "years 1–3 and 5\n2,977.50", (0.30, 0.67))):
    ax.plot(x, y, "o", color="#5E35B1", ms=8, clip_on=False, zorder=5)
    ax.annotate(name, xy=(x, y), xytext=(tx, ty), color="#5E35B1", fontsize=7.5, ha="center", va="center", bbox=box,
                arrowprops=dict(arrowstyle="-", color="#5E35B1", lw=0.6, shrinkB=5), zorder=6)
ax.plot(xs, ys, "X", color="#B71C1C", ms=9, zorder=5)
ax.annotate("saddle\n2,966.20", xy=(xs, ys), xytext=(0.55, 0.45), color="#B71C1C", fontsize=7.5, ha="center",
            va="center", bbox=box, arrowprops=dict(arrowstyle="-", color="#B71C1C", lw=0.6, shrinkB=5), zorder=6)
ax.text(0.03, 0.03, "2,905.00", fontsize=7, color="#424242")
ax.set(xlim=(0, 1), ylim=(0, 1), aspect="equal", xticks=[0, 0.5, 1], yticks=[0, 0.5, 1],
       xlabel="round in year 4, x", ylabel="round in year 5, y")
s = np.linspace(-0.15, 0.15, 121)
bx.plot(s, [value(SADDLE + np.r_[0, 0, 0, u, -u, 0]) - value(SADDLE) for u in s], color="#B71C1C", lw=2,
        label=r"move $t$ from year 5 to year 4: $+96.25\,t^2$")
bx.plot(s, [value(SADDLE + np.r_[0, 0, 0, u, u, 0]) - value(SADDLE) for u in s], color="#1F4E79", lw=2,
        label=r"add $t$ to both rounds: $-96.25\,t^2$")
bx.axhline(0, color="#999999", lw=0.6)
bx.set(xlabel=r"$t$ (fraction of a round)", ylabel=r"value less the saddle's (\$ million)")
bx.legend(frameon=False, fontsize=7.5, loc="lower center")
fig.suptitle("Two peaks and a saddle where only years 4 and 5 vary (seed 26204)", fontsize=10)
plt.tight_layout(); plt.show()
the face (years 1–3 whole, none in year 6): V = 2,905.00 + 81.25x + 72.50y -96.25xy
  corner (0, 0), years 1–3        V = 2,905.00; marginal values  +81.25 (year 4),  +72.50 (year 5): not a local maximum
  corner (1, 0), years 1–4        V = 2,986.25; marginal values  +81.25 (year 4),  -23.75 (year 5): strict local maximum
  corner (0, 1), years 1–3 and 5  V = 2,977.50; marginal values  -15.00 (year 4),  +72.50 (year 5): strict local maximum
  corner (1, 1), years 1–5        V = 2,962.50; marginal values  -15.00 (year 4),  -23.75 (year 5): not a local maximum
stationary plan (0.7532, 0.8442) = (72.5/96.25, 81.25/96.25): V = 2,966.20; marginal values of years 4 and 5 -5e-13, -5e-13
Hessian on the face [[0.0, -96.25], [-96.25, 0.0]], the same at every point: eigenvalues -96.25 along (1, 1), +96.25 along (1, -1)
moving t of a round from year 5 to year 4 adds 96.25 t^2: a tenth of a round adds 0.96
Two peaks and a saddle where only years 4 and 5 vary (seed 26204)

Panel 3 — Search from 100 starts (AXIOM Lab 2.4, step 2; Worked Example 4.1, Step 2; Table 4.4: 87, 11 and 2 runs)

AXIOM Lab 2.4, step 2. The planners run SciPy's SLSQP, an SQP method, from 100 plans drawn at random from the box, with the floors and the end condition imposed. With the book's seed, 2026 (Online Appendix 4.B.3), the runs end at three plans: years 1–4 (87 runs), years 1–3 and 5 (11) and years 1–3 and 6 (2). The lab's seed draws 100 fresh starts for SLSQP and for an interior-point method, SciPy's trust-constr, which treats the inequalities with a barrier as IPOPT does. Each method returns a KKT point, and which one depends on where it starts. If a basin attracts a share vv of random starts, NN starts all miss it with probability (1−v)N(1 - v)^N: finding a basin that attracts 5 percent of them with 95 percent confidence takes N≥ln⁡0.05/ln⁡0.95N \ge \ln 0.05/\ln 0.95, about 59 starts. No number of starts can list the basins it missed; a bound can (Panel 6).

Python Code
def constraints(z):                        # floors after each round and at each year end; year 6's end condition
    z = np.asarray(z, float)
    q = Q0 + np.cumsum(savings(z) - COST * z)
    after = np.r_[Q0, q[:-1]] - COST * z
    return np.r_[after - FLOOR, q - FLOOR, q[-1] - Q_END]

def search(z0, method="SLSQP"):            # one local search; returns the plan it ends at and its iterations
    # Iteration counts vary with SciPy's version (its SLSQP was rewritten in 1.16); where the runs end does not.
    if method == "SLSQP":
        r = minimize(lambda z: -value(z), z0, method="SLSQP", bounds=[(0, 1)] * K,
                     constraints=[{"type": "ineq", "fun": constraints}], options={"ftol": 1e-12, "maxiter": 500})
        tol = 1e-5
    else:                                  # the interior-point method stops a barrier's width inside the box
        with warnings.catch_warnings():    # V is affine in each round: some SciPy versions warn of zero-curvature steps
            warnings.simplefilter("ignore", UserWarning)
            r = minimize(lambda z: -value(z), z0, method="trust-constr", bounds=Bounds(np.zeros(K), np.ones(K)),
                         constraints=[NonlinearConstraint(constraints, 0, np.inf)],
                         options={"gtol": 1e-10, "xtol": 1e-12, "maxiter": 3000})
        tol = 1e-3
    end = tuple(int(round(v)) if abs(v - round(v)) < tol else round(float(v), 3) for v in r.x)
    return end, r.nit

def multistart(seed, method, n=100):
    rng = np.random.default_rng(seed)
    out = []
    for _ in range(n):
        z0 = rng.random(K)
        out.append((z0, *search(z0, method)))
    return out

RUNS = {"SLSQP from the book's starts (seed 2026)": multistart(BOOK_SEED, "SLSQP"),
        f"SLSQP from the lab's starts (seed {SEED})": multistart(SEED, "SLSQP"),
        f"interior point from the lab's starts (seed {SEED})": multistart(SEED, "trust-constr")}
INVENTORY = {}
for name, runs in RUNS.items():
    ends = {}
    for z0, end, nit in runs:
        ends.setdefault(end, []).append(nit)
    INVENTORY[name] = ends
    print(name)
    for end, its in sorted(ends.items(), key=lambda e: -value(e[0])):
        kind = label(end) if all(v in (0, 1) for v in end) else f"the fractional plan {end}"
        print(f"   {kind:18s} {len(its):3d} run{'s' if len(its) > 1 else ' '}   worth {value(end):,.2f}   "
              f"{np.mean(its):5.1f} iterations on average")
print("every run ends at a corner: none stops at the saddle" if all(all(v in (0, 1) for v in e) for ends in
      INVENTORY.values() for e in ends) else "some run ends inside the box")
n59 = np.log(0.05) / np.log(0.95)
print(f"a basin that attracts 5 percent of starts: N >= ln 0.05 / ln 0.95 = {n59:.1f}, so {int(np.ceil(n59))} starts "
      f"find it with 95 percent confidence")

LAB_RUN = RUNS[f"SLSQP from the lab's starts (seed {SEED})"]
COLORS = {A4: "#1F4E79", A5: "#E65100", A6: "#5E35B1"}
fig, (ax, bx) = plt.subplots(1, 2, figsize=(7.6, 3.6), gridspec_kw={"width_ratios": [1, 1.25]})
for end, col in COLORS.items():
    pts = np.array([z0[3:5] for z0, e, _ in LAB_RUN if e == end]).reshape(-1, 2)
    ax.scatter(pts[:, 0], pts[:, 1], s=16, color=col, zorder=3)
ax.set(xlim=(0, 1), ylim=(0, 1), aspect="equal", xticks=[0, 0.5, 1], yticks=[0, 0.5, 1],
       xlabel="year-4 round at the start", ylabel="year-5 round at the start",
       title=f"SLSQP from the lab's 100 starts")
ax.title.set_fontsize(9)
names = list(RUNS)
x = np.arange(len(names))
for i, (end, col) in enumerate(COLORS.items()):
    counts = [len(INVENTORY[n].get(end, [])) for n in names]
    bx.bar(x + (i - 1) * 0.27, counts, 0.27, color=col, label=f"ends at {label(end)}")
    for xi, c in zip(x + (i - 1) * 0.27, counts):
        bx.text(xi, c + 1.5, str(c), ha="center", fontsize=7.5, color=col)
mean_its = [np.mean([nit for _, _, nit in RUNS[n]]) for n in names]
bx.set_xticks(x)
bx.set_xticklabels([f"SLSQP\nbook's starts (2026)\n{mean_its[0]:.1f} iterations", f"SLSQP\nlab's starts\n{mean_its[1]:.1f} iterations",
                    f"interior point\nlab's starts\n{mean_its[2]:.1f} iterations"], fontsize=7.5)
bx.set(ylim=(0, 100), ylabel="runs of 100")
bx.legend(frameon=False, fontsize=7.5, loc="upper right")
fig.suptitle("Where 100 local searches end depends on where they start (seed 26204)", fontsize=10)
plt.tight_layout(); plt.show()
SLSQP from the book's starts (seed 2026)
   years 1–4           87 runs   worth 2,986.25     8.5 iterations on average
   years 1–3 and 5     11 runs   worth 2,977.50     8.5 iterations on average
   years 1–3 and 6      2 runs   worth 2,968.75     8.5 iterations on average
SLSQP from the lab's starts (seed 26204)
   years 1–4           93 runs   worth 2,986.25     8.7 iterations on average
   years 1–3 and 5      6 runs   worth 2,977.50     8.3 iterations on average
   years 1–3 and 6      1 run    worth 2,968.75    10.0 iterations on average
interior point from the lab's starts (seed 26204)
   years 1–4           61 runs   worth 2,986.25    95.2 iterations on average
   years 1–3 and 5     22 runs   worth 2,977.50    38.0 iterations on average
   years 1–3 and 6     17 runs   worth 2,968.75    60.6 iterations on average
every run ends at a corner: none stops at the saddle
a basin that attracts 5 percent of starts: N >= ln 0.05 / ln 0.95 = 58.4, so 59 starts find it with 95 percent confidence
Where 100 local searches end depends on where they start (seed 26204)

Panel 4 — Audit each answer (AXIOM Lab 2.4, step 3; Theorems 4.1–4.2: zero residuals, unique prices, three strict local maxima and a saddle)

AXIOM Lab 2.4, step 3: the KKT verification, plan by plan. Which commitments bind (only box limits: the floors keep at least $85 million of slack), the rank check for LICQ, the multipliers read from the marginal values, the residuals of stationarity and of the signs, and the reduced-Hessian test on the critical directions. Only box limits bind, so LICQ holds and each plan's multipliers are unique (Theorem 4.2(i)). At each corner every binding limit carries a positive price, so there are no critical directions: the test of Theorem 4.1(iii) passes at once and value falls linearly away from the plan (Proposition 4.2(iii)). At the saddle years 4 and 5 are free and the Lagrangian's Hessian on them has a positive eigenvalue, whose eigenvector is a direction of escape. A search started exactly at the saddle stops there, since it passes the first-order audit; started a thousandth of a round away, it climbs to a corner.

Python Code
def audit(z, M=M):
    z = np.asarray(z, float)
    g = marginal(z, M)
    up, low = np.isclose(z, 1.0), np.isclose(z, 0.0)          # binding limits z_j <= 1 and z_j >= 0
    price_up, price_low = np.where(up, g, 0.0), np.where(low, -g, 0.0)
    N = np.vstack([np.eye(K)[up], -np.eye(K)[low]])           # gradients of the binding limits, written g_i(z) <= 0
    residual = max(np.abs(g - price_up + price_low).max(), max(0.0, -min(price_up.min(), price_low.min())))
    critical = ~((up & (price_up > 1e-9)) | (low & (price_low > 1e-9)))   # free rounds and unpriced binding limits
    eig = np.linalg.eigvalsh(hessian(z, M)[np.ix_(critical, critical)]) if critical.any() else np.array([])
    return {"g": g, "up": price_up, "low": price_low, "binding": len(N), "rank": np.linalg.matrix_rank(N),
            "residual": residual, "critical": int(critical.sum()), "eig": eig}

print("plan                               binding  rank  LICQ  residual  critical  curvature       verdict")
AUDITS = {}
for z, name in ((A4, label(A4)), (A5, label(A5)), (A6, label(A6)), (SADDLE, "years 1–3; 0.75 in 4; 0.84 in 5")):
    a = AUDITS[name] = audit(z)
    curv = "none to test" if not a["critical"] else " ".join(f"{e:+.2f}" for e in a["eig"])
    verdict = ("strict local maximum" if a["residual"] < 1e-9 and (a["critical"] == 0 or a["eig"].max() < 0)
               else "saddle: a KKT point, not a local maximum" if a["residual"] < 1e-9 else "not a KKT point")
    print(f"{name:35s} {a['binding']:5d} {a['rank']:5d}   {'yes' if a['rank'] == a['binding'] else 'no':4s}"
          f"{a['residual']:9.1e} {a['critical']:7d}   {curv:15s} {verdict}")
print("\nprices of the binding limits ($m a round): + on z <= 1, - on z >= 0     year 1 ... year 6")
for name, a in AUDITS.items():
    print(f"  {name:35s}" + " ".join(f"{u - l:+9.3f}" if u or l else "     free" for u, l in zip(a["up"], a["low"])))
print(f"\nslack in the floors at the saddle: {slack(SADDLE):.1f}")
for start, where in ((SADDLE, "exactly at the saddle"), (SADDLE + 1e-3 * np.r_[0, 0, 0, 1, -1, 0], "0.001 toward year 4"),
                     (SADDLE + 1e-3 * np.r_[0, 0, 0, -1, 1, 0], "0.001 toward year 5")):
    end, nit = search(start)
    stop = label(end) if all(v in (0, 1) for v in end) else f"the saddle {end}"
    print(f"SLSQP started {where:22s} stops at {stop} after {nit} iteration{'s' if nit > 1 else ''}")
plan                               binding  rank  LICQ  residual  critical  curvature       verdict
years 1–4                               6     6   yes   0.0e+00       0   none to test    strict local maximum
years 1–3 and 5                         6     6   yes   0.0e+00       0   none to test    strict local maximum
years 1–3 and 6                         6     6   yes   0.0e+00       0   none to test    strict local maximum
years 1–3; 0.75 in 4; 0.84 in 5         4     4   yes   4.5e-13       2   -96.25 +96.25   saddle: a KKT point, not a local maximum

prices of the binding limits ($m a round): + on z <= 1, - on z >= 0     year 1 ... year 6
  years 1–4                           +203.750  +133.750   +98.750   +81.250   -23.750   -28.125
  years 1–3 and 5                     +212.500  +142.500  +107.500   -15.000   +72.500   -28.125
  years 1–3 and 6                     +221.250  +151.250  +116.250   -10.625   -19.375   +63.750
  years 1–3; 0.75 in 4; 0.84 in 5     +152.110   +82.110   +47.110      free      free   -53.802

slack in the floors at the saddle: 85.0
SLSQP started exactly at the saddle  stops at the saddle (1, 1, 1, 0.753, 0.844, 0) after 1 iteration
SLSQP started 0.001 toward year 4    stops at years 1–4 after 5 iterations
SLSQP started 0.001 toward year 5    stops at years 1–3 and 5 after 7 iterations

Panel 5 — Read the local prices (Worked Example 4.1, Step 3: $81.25, $23.75 and $28.13 million; a swap worth $8.75 million)

Each local maximum carries prices, and they differ by basin. At years 1–4, the year-4 round is worth $81.25 million more than it costs at the margin, and forcing a round into year 5 or 6 would lose $23.75 or $28.13 million. At years 1–3 and 5, a year-4 round would lose $15.00 million at the margin, yet moving the year-5 round to year 4 gains $8.75 million. Local prices answer "what does a small change from here cost?", not "is there a better basin?": the swap changes two rounds at once, and their interaction, $96.25 million, the difference between the swap's value and the sum of the two one-round changes, is invisible to prices that move one round at a time (Theorem 4.3(ii)).

Python Code
print("marginal value of a round, $m      year 1    year 2    year 3    year 4    year 5    year 6")
for z in (A4, A5, A6):
    print(f"  at {label(z):30s}" + "".join(f"{g:+10.3f}" for g in marginal(z)))
g4, g5 = marginal(A4), marginal(A5)
print(f"\nat {label(A4)}: the year-4 round is worth {g4[3]:.2f} more than it costs at the margin; forcing a round "
      f"into year 5 or 6 would lose {-g4[4]:.2f} or {-g4[5]:.3f}")
print(f"at {label(A5)}: a year-4 round would lose {-g5[3]:.2f} at the margin, and dropping the year-5 round {g5[4]:.2f}")
SWAP = value(A4) - value(A5)
ONE_BY_ONE = g5[3] - g5[4]
print(f"moving the year-5 round to year 4 gains {SWAP:.2f}; the two one-round changes add to {ONE_BY_ONE:+.2f}; "
      f"their interaction is {SWAP - ONE_BY_ONE:.2f}, the face's -d")
marginal value of a round, $m      year 1    year 2    year 3    year 4    year 5    year 6
  at years 1–4                       +203.750  +133.750   +98.750   +81.250   -23.750   -28.125
  at years 1–3 and 5                 +212.500  +142.500  +107.500   -15.000   +72.500   -28.125
  at years 1–3 and 6                 +221.250  +151.250  +116.250   -10.625   -19.375   +63.750

at years 1–4: the year-4 round is worth 81.25 more than it costs at the margin; forcing a round into year 5 or 6 would lose 23.75 or 28.125
at years 1–3 and 5: a year-4 round would lose 15.00 at the margin, and dropping the year-5 round 72.50
moving the year-5 round to year 4 gains 8.75; the two one-round changes add to -87.50; their interaction is 96.25, the face's -d

Panel 6 — Bound: bracket the inventory (AXIOM Lab 2.4, step 4; Worked Example 4.1, Step 4; Table 4.4: a ceiling of $2,987.26 million, gaps of $1.01, $9.76 and $18.51 million)

AXIOM Lab 2.4, step 4. No number of runs proves that a fourth basin does not exist; Chapter 3's relaxation (Lab 2.3) does. Its ceiling, $2,987.26 million, bounds every plan of whole or partial rounds, found or not. Panel 1 solved it with L-BFGS-B and certified the answer by its KKT conditions; an exact solution confirms it. The relaxation's marginal values fall from year to year (the difference is the slope of its savings, which is positive), so its best plan runs whole rounds up to one round, which solves its own marginal equation, and none after it. The best local answer lies within $1.01 million, or 0.03 percent, of the ceiling; the other two lie $9.76 and $18.51 million below it.

Python Code
def relaxation_exact(M=M, fix0=(), fix1=()):
    # Candidates: each free round as the pivot, the free rounds before it whole and those after it none; the pivot
    # solves its marginal equation SLOPE 2^-Z (sum of the later 2^-(Z_k - Z_f) + M 2^-(Z_6 - Z_f)) = 120, clipped to
    # [0, 1]. The best plan is one of the candidates, so the best candidate is the relaxation's best plan.
    fixed = {**{j: 0.0 for j in fix0}, **{j: 1.0 for j in fix1}}
    best = None
    if len(fixed) == K:
        z = np.array([fixed[j] for j in range(K)])
        return ceiling(z, M), z
    for f in [j for j in range(K) if j not in fixed]:
        z = np.array([fixed.get(j, 1.0 if j < f else 0.0) for j in range(K)])
        z[f] = 0.0
        Z = np.cumsum(z)
        A = (2.0 ** -(Z[f:] - Z[f])).sum() + M * 2.0 ** -(Z[-1] - Z[f])
        z[f] = np.clip(np.log2(SLOPE * A / COST) - Z[f], 0.0, 1.0)
        if best is None or ceiling(z, M) > best[0]:
            best = (ceiling(z, M), z)
    return best

CE20, ZE20 = relaxation_exact(20.0)
print(f"ceiling {C20:,.4f} with {Z20[4]:.4f} of a year-5 round; the exact solution {CE20:,.4f}, "
      f"{ZE20[4]:.4f} (difference {abs(C20 - CE20):.0e})")
print(f"the relaxation's best plan keeps the floors with {slack(Z20, relaxed_savings):.1f} to spare")
FOUND = INVENTORY["SLSQP from the book's starts (seed 2026)"]
TABLE_44 = [(label(z), len(FOUND.get(z, [])), value(z), "passes", "strict local maximum") for z in (A4, A5, A6)]
TABLE_44.append(("years 1–3; 0.75 in year 4; 0.84 in year 5", 0, value(SADDLE), "passes", "saddle"))
print("\nTable 4.4: where 100 local searches end at twenty years' credit ($ million, undiscounted)")
print("plan                                         runs      value   first order   second order           below ceiling")
for name, runs, v, first, second in TABLE_44:
    print(f"{name:42s} {runs:6d} {v:10,.2f}   {first:11s}   {second:22s} {C20 - v:9.2f}")
print(f"ceiling (Chapter 3)                                {C20:10,.2f}")
print(f"\nthe best local answer lies {C20 - value(A4):.2f} below the ceiling, {100 * (C20 - value(A4)) / C20:.2f} percent")
ceiling 2,987.2597 with 0.1531 of a year-5 round; the exact solution 2,987.2597, 0.1531 (difference 5e-13)
the relaxation's best plan keeps the floors with 85.0 to spare

Table 4.4: where 100 local searches end at twenty years' credit ($ million, undiscounted)
plan                                         runs      value   first order   second order           below ceiling
years 1–4                                      87   2,986.25   passes        strict local maximum        1.01
years 1–3 and 5                                11   2,977.50   passes        strict local maximum        9.76
years 1–3 and 6                                 2   2,968.75   passes        strict local maximum       18.51
years 1–3; 0.75 in year 4; 0.84 in year 5       0   2,966.20   passes        saddle                     21.06
ceiling (Chapter 3)                                  2,987.26

the best local answer lies 1.01 below the ceiling, 0.03 percent

Panel 7 — Branch: close the gap (AXIOM Lab 2.4, step 5; Worked Example 4.1, Step 5; Figure 4.3: five convex solves; seven at ten years' credit)

AXIOM Lab 2.4, step 5. Part rounds never pay, so a best plan has whole rounds (Proposition 4.2(ii)), and branch-and-bound with the relaxation as each node's ceiling finds it and proves it (Theorem 4.4). The book's search goes depth first, branches on the most fractional round and visits first the child nearer the relaxation's answer (Online Appendix 4.B.3). After each node the gap is the largest ceiling still open, each open node carrying its parent's, less the incumbent's value (Theorem 4.4(i)). At twenty years' credit the node without a year-5 round runs 0.09 of a year-6 round, with a ceiling of $2,986.56 million; without a year-6 round as well, the relaxation's answer is years 1–4, lumpy and worth $2,986.25 million: the incumbent (Theorem 4.4(iii)). The node with a year-6 round has a ceiling of $2,973.88 million and the node with a year-5 round one of $2,980.95 million, both below the incumbent, so both are pruned (Theorem 4.4(ii)). Five convex solves, no enumeration, gap zero. At ten years' credit the same search proves Chapter 3's three-round plan best in seven solves.

Python Code
def branch_and_bound(M, tol=1e-6):
    best_v, best_z, log = -np.inf, None, []
    stack = [((), (), np.inf)]                # (rounds fixed at none, rounds fixed whole, the parent's ceiling)
    while stack:
        f0, f1, _ = stack.pop()
        v, z, _ = relaxation(M, f0, f1)
        frac = [j for j in range(K) if 1e-6 < z[j] < 1 - 1e-6]
        if v <= best_v + tol:
            verdict = "pruned"
        elif not frac:
            verdict, best_v, best_z = "incumbent", v, np.round(z)
        else:
            j = max(frac, key=lambda i: min(z[i], 1 - z[i]))        # the most fractional round
            verdict = f"branch on year {j + 1}"
            down, up = (f0 + (j,), f1, v), (f0, f1 + (j,), v)
            stack += [down, up] if z[j] >= 0.5 else [up, down]   # the nearer child is taken first
        open_ceiling = max([b for *_, b in stack], default=-np.inf)
        gap = max(open_ceiling, best_v) - best_v if best_v > -np.inf else np.inf
        log.append((f0, f1, v, z, verdict, gap))
    return best_v, best_z, log

def fixings(f0, f1):
    parts = sorted([(j, 0) for j in f0] + [(j, 1) for j in f1])
    return ", ".join(f"z{j + 1} = {b}" for j, b in parts) or "none"

TREES = {}
for mm in (20.0, 10.0):
    best_v, best_z, log = TREES[mm] = branch_and_bound(mm)
    print(f"{mm:.0f} years' credit                                                               gap after")
    print("node  rounds fixed               ceiling   relaxation's rounds       verdict               the node")
    for i, (f0, f1, v, z, verdict, gap) in enumerate(log, start=1):
        rounds = " ".join(f"{x:.2f}" if 1e-6 < x < 1 - 1e-6 else f"{x:.0f}" for x in z)
        print(f"{i:3d}   {fixings(f0, f1):23s} {v:10,.2f}   {rounds:22s}    {verdict:18s} "
              f"{'no incumbent' if gap == np.inf else f'{gap:12.2f}'}")
    print(f"best plan {label(best_z)}, worth {best_v:,.2f}, proved in {len(log)} convex solves "
          f"(Theorem 4.4(iv) allows at most 2^7 - 1 = 127 nodes; enumeration would value 64 plans)\n")
LOG20, LOG10 = TREES[20.0][2], TREES[10.0][2]

fig, axes = plt.subplots(1, 2, figsize=(7.6, 3.6))
for ax, mm in zip(axes, (20.0, 10.0)):
    best_v, _, log = TREES[mm]
    nodes = np.arange(1, len(log) + 1)
    inc, current = [], np.nan
    for _, _, v, _, verdict, _ in log:
        current = v if verdict == "incumbent" else current
        inc.append(current)
    inc = np.array(inc)
    top = np.array([np.nan if gap == np.inf else i + gap for (*_, gap), i in zip(log, inc)])
    ax.fill_between(np.r_[nodes, nodes[-1] + 0.5], np.r_[inc, inc[-1]], np.r_[top, top[-1]], step="post",
                    color="#E65100", alpha=0.18, lw=0, label="gap: the open ceilings above the incumbent")
    ax.step(np.r_[nodes, nodes[-1] + 0.5], np.r_[inc, inc[-1]], where="post", color="#5E35B1", lw=1.2, ls="--",
            label="the incumbent")
    for i, (f0, f1, v, z, verdict, gap) in zip(nodes, log):
        mk, col = {"incumbent": ("*", "#5E35B1"), "pruned": ("X", "#616161")}.get(verdict, ("o", "#1F4E79"))
        ax.plot(i, v, mk, color=col, ms=12 if mk == "*" else 7, zorder=4)
        ax.annotate(f"{v:,.2f}", (i, v), textcoords="offset points", xytext=(0, 7), ha="center", fontsize=7)
    ax.set(xlim=(0.5, len(log) + 0.5), xticks=nodes, xlabel="node, in the order solved",
           title=f"{mm:.0f} years' credit: {label(TREES[mm][1])} in {len(log)} solves")
    ax.title.set_fontsize(9)
    ax.yaxis.set_major_locator(MultipleLocator(5))
    ax.yaxis.set_major_formatter(MONEY)
    lo = min(v for _, _, v, *_ in log)
    hi = max(v for _, _, v, *_ in log)
    ax.set_ylim(lo - 0.10 * (hi - lo), hi + 0.14 * (hi - lo))
axes[0].set_ylabel(r"the node's ceiling (\$ million)")
axes[0].plot([], [], "o", color="#1F4E79", ms=6, ls="none", label="branched")
axes[0].plot([], [], "X", color="#616161", ms=6, ls="none", label="pruned")
axes[1].legend(*axes[0].get_legend_handles_labels(), frameon=False, fontsize=7, loc="lower left")
fig.suptitle("Ceilings by node: the gap closes when the last node is pruned (seed 26204)", fontsize=10)
plt.tight_layout(); plt.show()
20 years' credit                                                               gap after
node  rounds fixed               ceiling   relaxation's rounds       verdict               the node
  1   none                      2,987.26   1 1 1 1 0.15 0            branch on year 5   no incumbent
  2   z5 = 0                    2,986.56   1 1 1 1 0 0.09            branch on year 6   no incumbent
  3   z5 = 0, z6 = 0            2,986.25   1 1 1 1 0 0               incumbent                  1.01
  4   z5 = 0, z6 = 1            2,973.88   1 1 1 0.34 0 1            pruned                     1.01
  5   z5 = 1                    2,980.95   1 1 1 0.28 1 0            pruned                     0.00
best plan years 1–4, worth 2,986.25, proved in 5 convex solves (Theorem 4.4(iv) allows at most 2^7 - 1 = 127 nodes; enumeration would value 64 plans)

10 years' credit                                                               gap after
node  rounds fixed               ceiling   relaxation's rounds       verdict               the node
  1   none                      1,687.09   1 1 1 0.39 0 0            branch on year 4   no incumbent
  2   z4 = 0                    1,683.45   1 1 1 0 0.28 0            branch on year 5   no incumbent
  3   z4 = 0, z5 = 0            1,681.01   1 1 1 0 0 0.15            branch on year 6   no incumbent
  4   z4 = 0, z5 = 0, z6 = 0    1,680.00   1 1 1 0 0 0               incumbent                  7.09
  5   z4 = 0, z5 = 0, z6 = 1    1,658.15   1 1 0.78 0 0 1            pruned                     7.09
  6   z4 = 0, z5 = 1            1,668.64   1 1 0.69 0 1 0            pruned                     7.09
  7   z4 = 1                    1,679.81   1 1 0.60 1 0 0            pruned                     0.00
best plan years 1–3, worth 1,680.00, proved in 7 convex solves (Theorem 4.4(iv) allows at most 2^7 - 1 = 127 nodes; enumeration would value 64 plans)

Ceilings by node: the gap closes when the last node is pruned (seed 26204)

Panel 8 — Test the credit (Worked Example 4.1, Step 6; Theorem 4.3: $131.25 million a year of credit; switches at 10.71 and 25.43 years)

The three local maxima all run four rounds by year 6, so their values rise together, by $131.25 million per year of credit, and their ranking does not change with it (Theorem 4.3(ii)). The best plan changes only where the number of rounds does (Theorem 4.3(iv)): three early rounds are worth 455+122.5M455 + 122.5M and four are worth 361.25+131.25M361.25 + 131.25M, so the best plan jumps from three rounds to four at 10.71 years of credit, and from four to five at 25.43 (Worked Example 2.1). Each plan's value grows at the rate of its own year-6 savings, and a price read at nine years understates the value of credit at twelve. The answer of Worked Example 4.1 holds for any credit between 10.71 and 25.43 years.

Python Code
def early(n):
    return np.array([1.0] * n + [0.0] * (K - n))

PAY = {n: value(early(n), 0.0) for n in range(K + 1)}       # n early rounds with no credit: the payouts
S6 = {n: savings(early(n))[-1] for n in range(K + 1)}       # and the slope in the credit, the year-6 savings
for n in range(2, 6):
    print(f"{n} early rounds are worth {PAY[n]:7.2f} + {S6[n]:7.3f} M")
TIE = {n: (PAY[n] - PAY[n + 1]) / (S6[n + 1] - S6[n]) for n in range(2, K)}
pay_all = np.array([value(s, 0.0) for s in SCHEDULES])
s6_all = np.array([savings(s)[-1] for s in SCHEDULES])
Ms = np.round(np.arange(0.0, 60.0 + 1e-9, 0.001), 3)
best = np.argmax(pay_all[None, :] + Ms[:, None] * s6_all[None, :], axis=1)
print("\nthe best of the 64 plans, as the credit rises from 0 to 60 years:")
for i in np.nonzero(np.diff(best))[0]:
    n = int(SCHEDULES[best[i]].sum())
    print(f"   at {TIE[n]:6.2f} years: {label(SCHEDULES[best[i]])} -> {label(SCHEDULES[best[i + 1]])}")
print("\nthe three local maxima at twenty years' credit, by the credit:")
for z in (A4, A5, A6):
    print(f"   {label(z):18s} slope {savings(z)[-1]:.2f}: " + "  ".join(f"{m:.2f} y {value(z, m):9,.2f}" for m in (10.71, 20.0, 25.43)))
print(f"\nthe price of a year of credit: {S6[3]:.2f} at nine years (three rounds best), {S6[4]:.2f} at twelve (four rounds)")
2 early rounds are worth  505.00 + 105.000 M
3 early rounds are worth  455.00 + 122.500 M
4 early rounds are worth  361.25 + 131.250 M
5 early rounds are worth  250.00 + 135.625 M

the best of the 64 plans, as the credit rises from 0 to 60 years:
   at   2.86 years: years 1–2 -> years 1–3
   at  10.71 years: years 1–3 -> years 1–4
   at  25.43 years: years 1–4 -> years 1–5
   at  53.86 years: years 1–5 -> years 1–6

the three local maxima at twenty years' credit, by the credit:
   years 1–4          slope 131.25: 10.71 y  1,766.94  20.00 y  2,986.25  25.43 y  3,698.94
   years 1–3 and 5    slope 131.25: 10.71 y  1,758.19  20.00 y  2,977.50  25.43 y  3,690.19
   years 1–3 and 6    slope 131.25: 10.71 y  1,749.44  20.00 y  2,968.75  25.43 y  3,681.44

the price of a year of credit: 122.50 at nine years (three rounds best), 131.25 at twelve (four rounds)

Panel 9 — A price list on a lumpy cap (Proposition 4.1(iii); Section 4.6: $150 million against a ceiling of $650 million; Chapter 3's relaxation $746.08 million)

With a $60 million capital cap, half a round, at ten years' credit, no whole round can run and the program is worth $150 million, the cash above $470 million paid out. Pricing the cap at μ\mu gives the ceiling q(μ)=max⁡z [V(z)−μ(120∑kzk−60)]q(\mu) = \max_{\mathbf{z}}\,[V(\mathbf{z}) - \mu(120\sum_k z_k - 60)] over the 64 plans of whole rounds (Theorem 3.4(i)); the best price, μ=25/3\mu = 25/3, leaves a ceiling of $650 million, because no price can express that half a round is no round. It is tighter than the $746 million of Chapter 3's relaxation with the cap (Section 4.6), and still far above the true $150 million. In the partial-round model half a round in year 1 is worth exactly $650 million, the blend of none and one round (Proposition 4.2(i)).

Python Code
BEST_N = {}
for s in SCHEDULES:                        # the best value with n whole rounds, at ten years' credit
    n = int(s.sum())
    BEST_N[n] = max(BEST_N.get(n, -np.inf), value(s, 10.0))
P_STAR = max(BEST_N[n] for n in BEST_N if COST * n <= 60.0)
print("best value with n whole rounds:", ", ".join(f"{n}: {v:,.2f}" for n, v in BEST_N.items()))
print(f"within the $60m cap only the plan with no round fits: worth {P_STAR:.2f}")
lines = [(BEST_N[n], 60.0 - COST * n) for n in BEST_N]               # q(mu) = max over n of best_n + mu (60 - 120 n)
q = lambda mu: max(b + a * mu for b, a in lines)
kinks = [(b2 - b1) / (a1 - a2) for b1, a1 in lines for b2, a2 in lines if a1 > a2]
MU = min((mu for mu in kinks if mu >= 0), key=q)
print(f"the best price on the cap: mu = {MU:.4f} (25/3 = {25 / 3:.4f}), ceiling q = {q(MU):.2f}; "
      f"at mu = 0 the ceiling is {q(0.0):,.2f}")
r = minimize(lambda z: -ceiling(z, 10.0), np.full(K, 0.05), jac=lambda z: -ceiling_grad(z, 10.0), method="SLSQP",
             bounds=[(0, 1)] * K, constraints=[{"type": "ineq", "fun": lambda z: 60.0 - COST * np.sum(z),
                                                "jac": lambda z: -COST * np.ones(K)}], options={"ftol": 1e-9, "maxiter": 500})
CAP_RELAX = -r.fun
print(f"Chapter 3's relaxation with the cap: {CAP_RELAX:.2f}, running {r.x[0]:.3f} of a year-1 round ({r.message})")
HALF = np.r_[0.5, np.zeros(K - 1)]
print(f"partial rounds: half a round in year 1 is worth {value(HALF, 10.0):.2f} = "
      f"({BEST_N[0]:.0f} + {BEST_N[1]:,.0f}) / 2, a blend that no price list can tell from a plan")
best value with n whole rounds: 0: 150.00, 1: 1,150.00, 2: 1,555.00, 3: 1,680.00, 4: 1,673.75, 5: 1,606.25, 6: 1,510.31
within the $60m cap only the plan with no round fits: worth 150.00
the best price on the cap: mu = 8.3333 (25/3 = 8.3333), ceiling q = 650.00; at mu = 0 the ceiling is 1,680.00
Chapter 3's relaxation with the cap: 746.08, running 0.500 of a year-1 round (Optimization terminated successfully)
partial rounds: half a round in year 1 is worth 650.00 = (150 + 1,150) / 2, a blend that no price list can tell from a plan

Panel 10 — Worked Example 1.1's package by branch-and-bound (Section 4.5; Theorem 4.4; Figure 4.2; Online Appendix 4.B.2: $12.50 million in five nodes)

Section 4.5 solves Worked Example 1.1's package by branch-and-bound: minimize the cost 0.03 l+8 ϕ0.03\,l + 8\,\phi of a standby line ll and a delay ϕ\phi subject to breach odds of at most 5 percent, with the line in $50 million tranches (0 to 400) and the delay in whole quarters (0 to 6). The odds are counted on the book's 100,000 paths of Volume I's Chapter 8 model, drawn exactly as Volume I draws them (seed 8, Online Appendix 1.B.4). For costs, bounds are floors and Theorem 4.4's inequalities reverse. A node keeps its ranges and drops integrality: its relaxation scans the line on a $1 million grid and takes, for each line, the least delay that meets the appetite, raised to the node's lower limit on delay (Online Appendix 4.B.2). The search branches on the delay while it is fractional, then on the line between tranches, and takes the open node with the lowest floor first. The node with no delay is infeasible, since the line alone leaves the odds at 8.4 percent at best; so the cut "delay at least one quarter" is valid, and it lifts the floor from $10.44 to $11.63 million, closing $1.19 million of the $2.06 million gap before any branching.

Python Code
N_PATHS, Q = 100_000, 12
A_E, SD_W = 0.6, 50.0                      # execution and market: E' = 0.6 E + w, w with sd $50m a quarter
LAM, J_MEAN, J_SD = 0.10, 120.0, 50.0      # funding-window closures: 0.10 a year, gamma sizes, never recovered
DEPTH0, DEPTH_PER_Q = 28.0, 4.0            # the plan's trough (index points); a quarter of delay: 4 points shallower
FEE, VQ, APPETITE = 0.03, 8.0, 0.05        # line fees over the program; a quarter of delay ($m); the board's appetite

TQ = np.arange(1, Q + 1) / 4               # the program's twelve quarters, in years
TROUGH = (TQ / 2.0) * np.exp(1 - TQ / 2.0)                 # the trough's shape, per index point of depth
BASE = 6.2 * (112 + (100 - 112) * np.exp(-0.35 * TQ))      # planned liquidity without the trough ($m)
SHAPE = 6.2 * TROUGH

rng = np.random.default_rng(8)             # Volume I's stream, in the book's order (Online Appendix 1.B.4)
E_PATHS, e, CLOSURES = np.empty((N_PATHS, Q)), np.zeros(N_PATHS), []
for k in range(Q):
    w = rng.normal(0.0, SD_W, N_PATHS)
    count = rng.poisson(LAM / 4, N_PATHS)
    size = rng.gamma((J_MEAN / J_SD) ** 2, J_SD ** 2 / J_MEAN, count.sum())
    CLOSURES.append((np.repeat(np.arange(N_PATHS), count), size))
    e = A_E * e + w
    E_PATHS[:, k] = e

def critical_depths(line):                 # a path breaches the floor exactly when the trough is deeper than this
    lost, cum = np.empty((N_PATHS, Q)), np.zeros(N_PATHS)
    for k, (path, size) in enumerate(CLOSURES):
        cum += np.bincount(path, np.maximum(size - line, 0.0), N_PATHS)
        lost[:, k] = cum
    return np.sort(((BASE + E_PATHS - lost - FLOOR) / SHAPE).min(axis=1))

def odds(line, phi):
    return np.searchsorted(critical_depths(line), DEPTH0 - DEPTH_PER_Q * phi) / N_PATHS

def least_delay(line):                     # the least delay meeting the appetite with this line (nan: none)
    d = min(DEPTH0, critical_depths(line)[int(np.floor(APPETITE * N_PATHS))])
    return np.nan if d < 0 else (DEPTH0 - d) / DEPTH_PER_Q

L1 = np.arange(0.0, 400.0 + 0.5, 1.0)       # lines on a $1 million grid
D1 = np.array([least_delay(l) for l in L1])

def package_floor(lmin=0.0, lmax=400.0, dmin=0.0, dmax=6.0):
    # a node's relaxation: each line in its range with the least delay meeting the appetite, raised to the node's
    # lower limit on delay and kept within its upper limit; the cheapest is the node's floor (None: infeasible)
    keep = (L1 >= lmin - 1e-9) & (L1 <= lmax + 1e-9) & ~np.isnan(D1)
    l, d = L1[keep], np.maximum(D1[keep], dmin)
    l, d = l[d <= dmax + 1e-12], d[d <= dmax + 1e-12]
    if len(l) == 0:
        return None
    i = int(np.argmin(FEE * l + VQ * d))
    return l[i], d[i], FEE * l[i] + VQ * d[i]

def package_bnb(tranche):
    nodes, open_, best = [], [], [None]
    lumpy = lambda l, d: abs(l / tranche - round(l / tranche)) < 1e-9 and abs(d - round(d)) < 1e-9
    def solve(limits):
        res = package_floor(**limits)
        if res is None:
            verdict = "infeasible"
        elif best[0] is not None and res[2] >= best[0][2] - 1e-9:
            verdict = "pruned"                 # its floor is no lower than the incumbent's cost
        elif lumpy(res[0], res[1]):
            best[0], verdict = res, "lumpy: the incumbent"
        else:
            verdict = "open"
        nodes.append({"limits": limits, "answer": res, "verdict": verdict})
        if verdict == "open":
            open_.append(len(nodes) - 1)
    solve({})
    while open_:
        k = min(open_, key=lambda i: nodes[i]["answer"][2])
        open_.remove(k)
        l, d, c = nodes[k]["answer"]
        if best[0] is not None and c >= best[0][2] - 1e-9:
            nodes[k]["verdict"] = "pruned"
            continue
        lim = nodes[k]["limits"]
        if abs(d - round(d)) > 1e-9:
            nodes[k]["verdict"] = "branch on the delay"
            kids = [{**lim, "dmax": np.floor(d)}, {**lim, "dmin": np.ceil(d)}]
        else:
            low = tranche * np.floor(l / tranche)
            nodes[k]["verdict"] = "branch on the line"
            kids = [{**lim, "lmax": low}, {**lim, "lmin": low + tranche}]
        for kid in kids:
            solve(kid)
    return nodes, best[0]

def ranges(lim):
    out = []
    if "dmax" in lim and lim.get("dmin", 0) == lim["dmax"]:
        out.append(f"delay {lim['dmax']:.0f}")
    elif "dmin" in lim:
        out.append(f"delay ≥ {lim['dmin']:.0f}")
    elif "dmax" in lim:
        out.append(f"delay ≤ {lim['dmax']:.0f}")
    if "lmax" in lim:
        out.append(f"line ≤ {lim['lmax']:.0f}")
    if "lmin" in lim:
        out.append(f"line ≥ {lim['lmin']:.0f}")
    return ", ".join(out) or "all"

PACKAGE = {}
for tranche in (50.0, 10.0):
    nodes, best = PACKAGE[tranche] = package_bnb(tranche)
    print(f"${tranche:.0f}m tranches, whole quarters")
    print("node  ranges                   relaxed answer (line, delay)        floor   verdict")
    for i, nd in enumerate(nodes, start=1):
        a = nd["answer"]
        ans = "none: the appetite cannot be met" if a is None else f"({a[0]:.0f}, {a[1]:.3f})"
        print(f"{i:3d}   {ranges(nd['limits']):24s} {ans:34s} {'' if a is None else f'{a[2]:6.2f}':7s} {nd['verdict']}")
    print(f"best package: a ${best[0]:.0f}m line with {best[1]:.0f} quarter of delay, ${best[2]:.2f}m, odds "
          f"{100 * odds(best[0], best[1]):.2f}%; {len(nodes)} nodes\n")

L5 = L1[::5]                               # Volume I's $5 million grid
c5 = FEE * L5 + VQ * D1[::5]
i5 = int(np.nanargmin(c5))
V1_ROOT = (L5[i5], D1[::5][i5], c5[i5])
N3 = PACKAGE[50.0][0][2]["answer"]
BEST50 = PACKAGE[50.0][1]
print(f"node 1 on the $1m grid: ({PACKAGE[50.0][0][0]['answer'][0]:.0f}, {PACKAGE[50.0][0][0]['answer'][1]:.2f}), "
      f"${PACKAGE[50.0][0][0]['answer'][2]:.2f}m; the book quotes Volume I's answer on its $5m grid, "
      f"({V1_ROOT[0]:.0f}, {V1_ROOT[1]:.2f}), ${V1_ROOT[2]:.2f}m: no pruning decision depends on the difference")
print(f"the line alone: odds at least {100 * odds(400.0, 0.0):.2f}% even with a $400m line, so no package without delay meets 5%")
print(f"the cut 'delay at least one quarter' lifts the floor from {V1_ROOT[2]:.2f} to {N3[2]:.2f}: it closes "
      f"{N3[2] - V1_ROOT[2]:.2f} of the {BEST50[2] - V1_ROOT[2]:.2f} gap, the price of the lumps")
print(f"a relative gap of 0.01 percent: ${1e-4 * BEST50[2] * 1e6:,.0f} on the ${BEST50[2]:.2f}m package; "
      f"${1e-4 * value(A4):.2f}m on Meridian's automation value")
$50m tranches, whole quarters
node  ranges                   relaxed answer (line, delay)        floor   verdict
  1   all                      (166, 0.681)                        10.43  branch on the delay
  2   delay 0                  none: the appetite cannot be met           infeasible
  3   delay ≥ 1                (121, 1.000)                        11.63  branch on the line
  4   delay ≥ 1, line ≤ 100    (100, 1.287)                        13.30  pruned
  5   delay ≥ 1, line ≥ 150    (150, 1.000)                        12.50  lumpy: the incumbent
best package: a $150m line with 1 quarter of delay, $12.50m, odds 4.00%; 5 nodes

$10m tranches, whole quarters
node  ranges                   relaxed answer (line, delay)        floor   verdict
  1   all                      (166, 0.681)                        10.43  branch on the delay
  2   delay 0                  none: the appetite cannot be met           infeasible
  3   delay ≥ 1                (121, 1.000)                        11.63  branch on the line
  4   delay ≥ 1, line ≤ 120    (120, 1.004)                        11.63  branch on the delay
  5   delay ≥ 1, line ≥ 130    (130, 1.000)                        11.90  lumpy: the incumbent
  6   delay 1, line ≤ 120      none: the appetite cannot be met           infeasible
  7   delay ≥ 2, line ≤ 120    (70, 2.000)                         18.10  pruned
best package: a $130m line with 1 quarter of delay, $11.90m, odds 4.63%; 7 nodes

node 1 on the $1m grid: (166, 0.68), $10.43m; the book quotes Volume I's answer on its $5m grid, (170, 0.67), $10.44m: no pruning decision depends on the difference
the line alone: odds at least 8.40% even with a $400m line, so no package without delay meets 5%
the cut 'delay at least one quarter' lifts the floor from 10.44 to 11.63: it closes 1.19 of the 2.06 gap, the price of the lumps
a relative gap of 0.01 percent: $1,250 on the $12.50m package; $0.30m on Meridian's automation value

Validation — the book's numbers, and agreement with DCT_V2_Ch04_Lab.xlsx

Each checkpoint is a number printed in Chapter 4 (Worked Example 4.1, Table 4.4, Figures 4.1–4.3, Sections 4.1–4.6) or in Online Appendix 4.B.2–4.B.3. The workbook recomputes the ones marked workbook with spreadsheet formulas and shows PASS against the same engine values on its Checks sheet.

Python Code
N_LOCAL = sum(all((g > 0) if s[j] else (g < 0) for j, g in enumerate(marginal(s))) for s in SCHEDULES)
NODES50, NODES10 = PACKAGE[50.0][0], PACKAGE[10.0][0]
checks = [
    ("smallest floor slack over every plan, $m (workbook)", min(slack(s) for s in SCHEDULES), 85.0, 1e-9),
    ("part of a round is a blend: largest error", blend, 0.0, 1e-9),
    ("relaxation's year-5 round at 20 years (workbook)", Z20[4], 0.15, 0.005),
    ("that plan in the partial-round model, $m (workbook)", value(Z20), 2982.61, 0.005),
    ("that plan below running none, $m (workbook)", value(A4) - value(Z20), 3.64, 0.005),
    ("relaxation's year-4 round at 10 years (workbook)", Z10[3], 0.39, 0.005),
    ("that plan below three rounds at 10 years, $m (workbook)", value(A3, 10.0) - value(Z10, 10.0), 2.46, 0.005),
    ("face: constant, $m (workbook)", fa, 2905.0, 1e-9),
    ("face: year-4 coefficient (workbook)", fb, 81.25, 1e-9),
    ("face: year-5 coefficient (workbook)", fc, 72.5, 1e-9),
    ("face: interaction coefficient (workbook)", fd, -96.25, 1e-9),
    ("saddle: year-4 round (workbook)", xs, 0.75, 0.005),
    ("saddle: year-5 round (workbook)", ys, 0.84, 0.005),
    ("saddle: value, $m (workbook)", value(SADDLE), 2966.20, 0.005),
    ("saddle: positive eigenvalue on the face (workbook)", ev.max(), 96.25, 1e-9),
    ("runs ending at years 1–4 (seed 2026)", len(FOUND.get(A4, [])), 87, 0),
    ("runs ending at years 1–3 and 5 (seed 2026)", len(FOUND.get(A5, [])), 11, 0),
    ("runs ending at years 1–3 and 6 (seed 2026)", len(FOUND.get(A6, [])), 2, 0),
    ("starts to find a 5% basin at 95% (workbook)", np.ceil(n59), 59, 0),
    ("years 1–4, $m (workbook)", value(A4), 2986.25, 1e-9),
    ("years 1–3 and 5, $m (workbook)", value(A5), 2977.50, 1e-9),
    ("years 1–3 and 6, $m (workbook)", value(A6), 2968.75, 1e-9),
    ("strict local maxima among the 64 plans (workbook)", N_LOCAL, 3, 0),
    ("largest KKT residual, three local maxima (workbook)", max(AUDITS[label(z)]["residual"] for z in (A4, A5, A6)), 0.0, 1e-9),
    ("years 1–4: year-4 round above its cost, $m (workbook)", g4[3], 81.25, 1e-9),
    ("years 1–4: forcing a year-5 round, $m (workbook)", -g4[4], 23.75, 1e-9),
    ("years 1–4: forcing a year-6 round, $m (workbook)", -g4[5], 28.13, 0.005),
    ("years 1–3 and 5: a year-4 round, $m (workbook)", -g5[3], 15.00, 1e-9),
    ("swap of the year-5 round into year 4, $m (workbook)", SWAP, 8.75, 1e-9),
    ("interaction of the two rounds, $m (workbook)", SWAP - ONE_BY_ONE, 96.25, 1e-9),
    ("ceiling: Chapter 3's relaxation, $m (workbook)", C20, 2987.26, 0.005),
    ("best local answer below the ceiling, $m (workbook)", C20 - value(A4), 1.01, 0.005),
    ("best local answer below the ceiling, % (workbook)", 100 * (C20 - value(A4)) / C20, 0.03, 0.005),
    ("years 1–3 and 5 below the ceiling, $m (workbook)", C20 - value(A5), 9.76, 0.005),
    ("years 1–3 and 6 below the ceiling, $m (workbook)", C20 - value(A6), 18.51, 0.005),
    ("saddle below the ceiling, $m (workbook)", C20 - value(SADDLE), 21.06, 0.005),
    ("branch-and-bound at 20 years: solves (workbook)", len(LOG20), 5, 0),
    ("node 2: ceiling, $m (workbook)", LOG20[1][2], 2986.56, 0.005),
    ("node 2: year-6 round (workbook)", LOG20[1][3][5], 0.09, 0.005),
    ("node 3: the incumbent, $m (workbook)", LOG20[2][2], 2986.25, 1e-6),
    ("node 4: ceiling, $m (workbook)", LOG20[3][2], 2973.88, 0.005),
    ("node 5: ceiling, $m (workbook)", LOG20[4][2], 2980.95, 0.005),
    ("gap after the last node, $m (workbook)", LOG20[-1][5], 0.0, 1e-9),
    ("branch-and-bound at 10 years: solves (workbook)", len(LOG10), 7, 0),
    ("10 years: root ceiling, $m (workbook)", LOG10[0][2], 1687.09, 0.005),
    ("10 years: best plan, three rounds, $m (workbook)", TREES[10.0][0], 1680.00, 1e-6),
    ("credit: slope of three rounds, $m a year (workbook)", S6[3], 122.5, 1e-9),
    ("credit: slope of four rounds, $m a year (workbook)", S6[4], 131.25, 1e-9),
    ("credit: three rounds to four, years (workbook)", TIE[3], 10.71, 0.005),
    ("credit: four rounds to five, years (workbook)", TIE[4], 25.43, 0.005),
    ("$60m cap: best plan of whole rounds, $m (workbook)", P_STAR, 150.0, 1e-9),
    ("$60m cap: best ceiling from a price, $m (workbook)", q(MU), 650.0, 1e-9),
    ("$60m cap: the best price (workbook)", MU, 25 / 3, 1e-9),
    ("$60m cap: Chapter 3's relaxation, $m (workbook)", CAP_RELAX, 746.08, 0.005),
    ("$60m cap: half a round in year 1, $m (workbook)", value(HALF, 10.0), 650.0, 1e-9),
    ("package: the line alone at best, odds %", 100 * odds(400.0, 0.0), 8.40, 0.005),
    ("package: Volume I's continuous floor, $m (workbook)", V1_ROOT[2], 10.44, 0.005),
    ("package: node 3 line, $m", N3[0], 121, 0),
    ("package: node 3 floor, $m (workbook)", N3[2], 11.63, 0.005),
    ("package: node 4 floor, $m (workbook)", NODES50[3]["answer"][2], 13.30, 0.005),
    ("package: node 5, the best package, $m (workbook)", BEST50[2], 12.50, 0.005),
    ("package: nodes", len(NODES50), 5, 0),
    ("package: the price of the lumps, $m (workbook)", BEST50[2] - V1_ROOT[2], 2.06, 0.005),
    ("package: the cut closes, $m (workbook)", N3[2] - V1_ROOT[2], 1.19, 0.005),
    ("$10m tranches: nodes", len(NODES10), 7, 0),
    ("$10m tranches: best package, $m (workbook)", PACKAGE[10.0][1][2], 11.90, 0.005),
    ("$10m tranches: floor of two quarters, $m (workbook)", NODES10[6]["answer"][2], 18.10, 0.005),
    ("0.01% of the package's cost, $ (workbook)", 1e-4 * BEST50[2] * 1e6, 1250, 0.5),
    ("0.01% of Meridian's automation value, $m (workbook)", 1e-4 * value(A4), 0.3, 0.005),
]
ok = 0
for name, got, want, tol in checks:
    status = "PASS" if abs(got - want) <= tol else "FAIL"
    ok += status == "PASS"
    print(f"{name:55s} {got:12.4f}   book {want:10.4f}   {status}")
print(f"\n{ok} of {len(checks)} checkpoints PASS")
smallest floor slack over every plan, $m (workbook)          85.0000   book    85.0000   PASS
part of a round is a blend: largest error                     0.0000   book     0.0000   PASS
relaxation's year-5 round at 20 years (workbook)              0.1531   book     0.1500   PASS
that plan in the partial-round model, $m (workbook)        2982.6149   book  2982.6100   PASS
that plan below running none, $m (workbook)                   3.6351   book     3.6400   PASS
relaxation's year-4 round at 10 years (workbook)              0.3941   book     0.3900   PASS
that plan below three rounds at 10 years, $m (workbook)       2.4629   book     2.4600   PASS
face: constant, $m (workbook)                              2905.0000   book  2905.0000   PASS
face: year-4 coefficient (workbook)                          81.2500   book    81.2500   PASS
face: year-5 coefficient (workbook)                          72.5000   book    72.5000   PASS
face: interaction coefficient (workbook)                    -96.2500   book   -96.2500   PASS
saddle: year-4 round (workbook)                               0.7532   book     0.7500   PASS
saddle: year-5 round (workbook)                               0.8442   book     0.8400   PASS
saddle: value, $m (workbook)                               2966.2013   book  2966.2000   PASS
saddle: positive eigenvalue on the face (workbook)           96.2500   book    96.2500   PASS
runs ending at years 1–4 (seed 2026)                         87.0000   book    87.0000   PASS
runs ending at years 1–3 and 5 (seed 2026)                   11.0000   book    11.0000   PASS
runs ending at years 1–3 and 6 (seed 2026)                    2.0000   book     2.0000   PASS
starts to find a 5% basin at 95% (workbook)                  59.0000   book    59.0000   PASS
years 1–4, $m (workbook)                                   2986.2500   book  2986.2500   PASS
years 1–3 and 5, $m (workbook)                             2977.5000   book  2977.5000   PASS
years 1–3 and 6, $m (workbook)                             2968.7500   book  2968.7500   PASS
strict local maxima among the 64 plans (workbook)             3.0000   book     3.0000   PASS
largest KKT residual, three local maxima (workbook)           0.0000   book     0.0000   PASS
years 1–4: year-4 round above its cost, $m (workbook)        81.2500   book    81.2500   PASS
years 1–4: forcing a year-5 round, $m (workbook)             23.7500   book    23.7500   PASS
years 1–4: forcing a year-6 round, $m (workbook)             28.1250   book    28.1300   PASS
years 1–3 and 5: a year-4 round, $m (workbook)               15.0000   book    15.0000   PASS
swap of the year-5 round into year 4, $m (workbook)           8.7500   book     8.7500   PASS
interaction of the two rounds, $m (workbook)                 96.2500   book    96.2500   PASS
ceiling: Chapter 3's relaxation, $m (workbook)             2987.2597   book  2987.2600   PASS
best local answer below the ceiling, $m (workbook)            1.0097   book     1.0100   PASS
best local answer below the ceiling, % (workbook)             0.0338   book     0.0300   PASS
years 1–3 and 5 below the ceiling, $m (workbook)              9.7597   book     9.7600   PASS
years 1–3 and 6 below the ceiling, $m (workbook)             18.5097   book    18.5100   PASS
saddle below the ceiling, $m (workbook)                      21.0584   book    21.0600   PASS
branch-and-bound at 20 years: solves (workbook)               5.0000   book     5.0000   PASS
node 2: ceiling, $m (workbook)                             2986.5634   book  2986.5600   PASS
node 2: year-6 round (workbook)                               0.0859   book     0.0900   PASS
node 3: the incumbent, $m (workbook)                       2986.2500   book  2986.2500   PASS
node 4: ceiling, $m (workbook)                             2973.8787   book  2973.8800   PASS
node 5: ceiling, $m (workbook)                             2980.9460   book  2980.9500   PASS
gap after the last node, $m (workbook)                        0.0000   book     0.0000   PASS
branch-and-bound at 10 years: solves (workbook)               7.0000   book     7.0000   PASS
10 years: root ceiling, $m (workbook)                      1687.0887   book  1687.0900   PASS
10 years: best plan, three rounds, $m (workbook)           1680.0000   book  1680.0000   PASS
credit: slope of three rounds, $m a year (workbook)         122.5000   book   122.5000   PASS
credit: slope of four rounds, $m a year (workbook)          131.2500   book   131.2500   PASS
credit: three rounds to four, years (workbook)               10.7143   book    10.7100   PASS
credit: four rounds to five, years (workbook)                25.4286   book    25.4300   PASS
$60m cap: best plan of whole rounds, $m (workbook)          150.0000   book   150.0000   PASS
$60m cap: best ceiling from a price, $m (workbook)          650.0000   book   650.0000   PASS
$60m cap: the best price (workbook)                           8.3333   book     8.3333   PASS
$60m cap: Chapter 3's relaxation, $m (workbook)             746.0808   book   746.0800   PASS
$60m cap: half a round in year 1, $m (workbook)             650.0000   book   650.0000   PASS
package: the line alone at best, odds %                       8.4040   book     8.4000   PASS
package: Volume I's continuous floor, $m (workbook)          10.4406   book    10.4400   PASS
package: node 3 line, $m                                    121.0000   book   121.0000   PASS
package: node 3 floor, $m (workbook)                         11.6300   book    11.6300   PASS
package: node 4 floor, $m (workbook)                         13.2969   book    13.3000   PASS
package: node 5, the best package, $m (workbook)             12.5000   book    12.5000   PASS
package: nodes                                                5.0000   book     5.0000   PASS
package: the price of the lumps, $m (workbook)                2.0594   book     2.0600   PASS
package: the cut closes, $m (workbook)                        1.1894   book     1.1900   PASS
$10m tranches: nodes                                          7.0000   book     7.0000   PASS
$10m tranches: best package, $m (workbook)                   11.9000   book    11.9000   PASS
$10m tranches: floor of two quarters, $m (workbook)          18.1000   book    18.1000   PASS
0.01% of the package's cost, $ (workbook)                  1250.0000   book  1250.0000   PASS
0.01% of Meridian's automation value, $m (workbook)           0.2986   book     0.3000   PASS

69 of 69 checkpoints PASS

Next. Part II builds the methods that exploit the structure of time. Chapter 5 states the dynamic instance and solves it by transcription: the path becomes one large program, every method of Part I applies, and the multipliers of the dynamics become prices that carry each stock's value back through time. Its Worked Example asks when Meridian should pay its shareholders while it automates. AXIOM-04 runs this lab interactively (Lab 2.4); this notebook and the workbook are its reproducible record.

Dynamic Corporate Transformation — Volume I: Foundations and Mathematical Framework; Volume II: Enterprise Optimization & Applications
Jump to any chapter

Volume I: Foundations and Mathematical Framework

  1. Ch. 1Introduction to Dynamic Corporate Transformation
  2. Ch. 2Enterprise Systems and Transformation
  3. Ch. 3Mathematical Foundations
  4. Ch. 4Enterprise Modeling Principles
  5. Ch. 5Enterprise State Representation
  6. Ch. 6Enterprise Transformation Operators
  7. Ch. 7Dynamic Enterprise Systems
  8. Ch. 8Stochastic Enterprise Dynamics
  9. Ch. 9Enterprise State Architecture
  10. Ch. 10Enterprise Capital Architecture
  11. Ch. 11Enterprise Performance Architecture
  12. Ch. 12Enterprise Risk, Resilience, and Robustness Architecture
  13. Ch. 13Unified Enterprise Transformation Architecture
  14. Ch. 14Mathematical Analysis of the Unified Enterprise Transformation Architecture
  15. Ch. 15Mathematical Formulation of Enterprise Optimization
  16. Ch. 16Synthesis, Future Directions, and Transition to Volume II

Volume II: Enterprise Optimization & Applications

  1. Ch. 1Introduction to Enterprise Optimization
  2. Ch. 2The General Enterprise Optimization Problem Revisited
  3. Ch. 3Convex Enterprise Optimization
  4. Ch. 4Nonlinear and Mixed-Integer Enterprise Optimization
  5. Ch. 5Dynamic Enterprise Optimization
  6. Ch. 6Optimal Control of Enterprise Systems
  7. Ch. 7Dynamic Programming for Enterprise Systems
  8. Ch. 8Hamilton–Jacobi–Bellman Enterprise Framework
  9. Ch. 9Stochastic Enterprise Optimization
  10. Ch. 10Neuro-Fuzzy Robust Enterprise Optimization
  11. Ch. 11Distributionally Robust Enterprise Optimization
  12. Ch. 12Multi-Objective Enterprise Optimization
  13. Ch. 13Machine Learning for Enterprise Transformation
  14. Ch. 14Artificial Intelligence for Enterprise Optimization
  15. Ch. 15Enterprise Digital Twins and Autonomous Enterprise Transformation
  16. Ch. 16Enterprise Applications and Integrated Transformation Case Studies

Dynamic Corporate Transformation

Springer Nature · Management for Professionals · Forthcoming 2027

  • Volume I — Foundations and Mathematical Framework
  • Volume II — Enterprise Optimization & Applications
Buy Volume I: Dynamic Corporate Transformation: Foundations and Mathematical FrameworkBuy Volume II: Dynamic Corporate Transformation: Enterprise Optimization & Applications
Jump to any chapter

Volume I: Foundations and Mathematical Framework

  1. Ch. 1Introduction to Dynamic Corporate Transformation
  2. Ch. 2Enterprise Systems and Transformation
  3. Ch. 3Mathematical Foundations
  4. Ch. 4Enterprise Modeling Principles
  5. Ch. 5Enterprise State Representation
  6. Ch. 6Enterprise Transformation Operators
  7. Ch. 7Dynamic Enterprise Systems
  8. Ch. 8Stochastic Enterprise Dynamics
  9. Ch. 9Enterprise State Architecture
  10. Ch. 10Enterprise Capital Architecture
  11. Ch. 11Enterprise Performance Architecture
  12. Ch. 12Enterprise Risk, Resilience, and Robustness Architecture
  13. Ch. 13Unified Enterprise Transformation Architecture
  14. Ch. 14Mathematical Analysis of the Unified Enterprise Transformation Architecture
  15. Ch. 15Mathematical Formulation of Enterprise Optimization
  16. Ch. 16Synthesis, Future Directions, and Transition to Volume II

Volume II: Enterprise Optimization & Applications

  1. Ch. 1Introduction to Enterprise Optimization
  2. Ch. 2The General Enterprise Optimization Problem Revisited
  3. Ch. 3Convex Enterprise Optimization
  4. Ch. 4Nonlinear and Mixed-Integer Enterprise Optimization
  5. Ch. 5Dynamic Enterprise Optimization
  6. Ch. 6Optimal Control of Enterprise Systems
  7. Ch. 7Dynamic Programming for Enterprise Systems
  8. Ch. 8Hamilton–Jacobi–Bellman Enterprise Framework
  9. Ch. 9Stochastic Enterprise Optimization
  10. Ch. 10Neuro-Fuzzy Robust Enterprise Optimization
  11. Ch. 11Distributionally Robust Enterprise Optimization
  12. Ch. 12Multi-Objective Enterprise Optimization
  13. Ch. 13Machine Learning for Enterprise Transformation
  14. Ch. 14Artificial Intelligence for Enterprise Optimization
  15. Ch. 15Enterprise Digital Twins and Autonomous Enterprise Transformation
  16. Ch. 16Enterprise Applications and Integrated Transformation Case Studies