关于「标准库单纯形:分数精确运算、布兰德规则与最坏情形」,《周期配额的路由与倒计时》给出的定量结论是什么?

结论:第二章用 Fraction 写出带布兰德规则的单纯形法,解出重推理配额的影子价格 9/40。

数据口径:示意参数下,线性规划相对先到先用多出 0.1668 到 0.2217,相对按复杂度分档的固定规则只多出 0.41 % 到 5.05 %,大头来自分档本身。 书中参数为示意,不含任何厂商的价格或配额;全部计算由书中程序生成。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 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
查看完整验算程序
# 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)

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《周期配额削峰填谷与跨模型路由、重置倒计时线性规划与重推理轻量模型算力分配母典》第 2 章「标准库单纯形:分数精确运算、布兰德规则与最坏情形」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 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}
}

本书其他章节结论