What does Routing Periodic Quotas conclude, in numbers, about “A Standard-Library Simplex: Exact Fractions, Bland's Rule and the Worst Case”?

Answer: Chapter 2 writes a simplex method in Fractions with Bland's rule and finds a shadow price of 9/40 for heavy quota.

Scope of the numbers: Under illustrative parameters the linear programme gains 0.1668 to 0.2217 over arrival order, but only 0.41 % to 5.05 % over a fixed rule that sorts by complexity; most of the gain comes from sorting itself. Parameters are illustrative and contain no vendor's prices or quotas; all calculations are generated by the book's programs.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 40

class demand on H on F dropped
routine300 0 300 0
standard150 0 150 0
complex60 28 32 0
critical20 20 0 0
H quota used 600 of 600, F quota used 696 of 900
expected output points (exact)893 = 893.0000
shadow price per H quota unit9/40
shadow price per F quota unit0
pivots under Bland's rule7
Show the full program
# Chapter 2. p21: an exact simplex on Fractions solves one routing cycle.
# Model: maximise c.x subject to A x <= b, x >= 0, with b >= 0, so the
# slack basis is feasible and no phase one is needed. Arithmetic is
# exact (fractions.Fraction); pivots follow Bland's lowest-index rule.
# Instance: two model tiers, H (heavy reasoning) and F (fast), four
# task classes. Quotas, quota costs, success shares and values are
# illustrative units, not any vendor's real prices or limits.
from fractions import Fraction as Fr


def simplex(c, A, b, rule="bland", cap=500):
    m, n = len(A), len(c)
    T = [[Fr(v) for v in A[i]] + [Fr(int(i == j)) for j in range(m)]
         + [Fr(b[i])] for i in range(m)]
    z = [-Fr(v) for v in c] + [Fr(0)] * (m + 1)
    basis = [n + i for i in range(m)]
    steps = 0
    while steps < cap:
        cols = [j for j in range(n + m) if z[j] < 0]
        if not cols:
            break
        if rule == "bland":
            e = cols[0]
        else:
            e = min(cols, key=lambda j: (z[j], j))
        rows = [i for i in range(m) if T[i][e] > 0]
        if not rows:
            return None
        r = min(rows, key=lambda i: (T[i][-1] / T[i][e], basis[i]))
        p = T[r][e]
        T[r] = [v / p for v in T[r]]
        for i in range(m):
            if i != r and T[i][e] != 0:
                f = T[i][e]
                T[i] = [a - f * w for a, w in zip(T[i], T[r])]
        f = z[e]
        z = [a - f * w for a, w in zip(z, T[r])]
        basis[r] = e
        steps += 1
    x = [Fr(0)] * (n + m)
    for i, j in enumerate(basis):
        x[j] = T[i][-1]
    return x[:n], z[-1], z[n:n + m], steps


CLASSES = ("routine", "standard", "complex", "critical")
DEMAND = (300, 150, 60, 20)
VALUE = (1, 2, 5, 10)
COST = {"H": (4, 6, 10, 16), "F": (1, 2, 3, 4)}
SUCC = {"H": ("0.97", "0.95", "0.90", "0.85"),
        "F": ("0.95", "0.80", "0.45", "0.15")}
QUOTA = {"H": 600, "F": 900}

# variables: x[c, H] for c = 0..3, then x[c, F] for c = 0..3
c = [VALUE[k] * Fr(SUCC[t][k]) for t in "HF" for k in range(4)]
A = [[COST["H"][k] if t == "H" else 0 for t in "HF" for k in range(4)],
     [COST["F"][k] if t == "F" else 0 for t in "HF" for k in range(4)]]
b = [QUOTA["H"], QUOTA["F"]]
for k in range(4):
    A.append([1 if j == k else 0 for t in "HF" for j in range(4)])
    b.append(DEMAND[k])
x, val, y, steps = simplex(c, A, b)
print("class      demand  on H   on F   dropped")
for k in range(4):
    h, f = x[k], x[4 + k]
    print("%-9s  %5d  %5s  %5s  %5s" % (CLASSES[k], DEMAND[k], h, f,
                                       DEMAND[k] - h - f))
useH = Fr(0)
useF = Fr(0)
for k in range(4):
    useH += COST["H"][k] * x[k]
    useF += COST["F"][k] * x[4 + k]
print("H quota used %s of %d, F quota used %s of %d" % (
    useH, QUOTA["H"], useF, QUOTA["F"]))
print("expected output points (exact): %s = %.4f" % (val, float(val)))
print("shadow price per H quota unit: %s" % y[0])
print("shadow price per F quota unit: %s" % y[1])
print("pivots under Bland's rule: %d" % steps)

Single source and citation

Fan, Y. (2026). Peak-Shaving Periodic Quotas and Cross-Model Routing: Linear Programming against Reset Countdowns to Split Work between Heavy-Reasoning and Fast Models (Version 1.0.0), Chapter 2: A Standard-Library Simplex: Exact Fractions, Bland's Rule and the Worst Case. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-270 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026270,
  author    = {Fan, Yafu},
  title     = {Peak-Shaving Periodic Quotas and Cross-Model Routing: Linear Programming against Reset Countdowns to Split Work between Heavy-Reasoning and Fast Models},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book