关于「东西方原典考辨:桑弘羊均输与蒙日的挖填土方」,《最优传输与奢品调货》给出的定量结论是什么?

结论:第七章考辨《史记·平准书》的均输(示意模型中横向调拨省下 0.721 的运费)与蒙日的挖填土方。

数据口径:书中的门店、城市坐标、运价、库存、毛利与概率均为示意;全部计算由书中程序生成;本书是非个人化经营建议,书中小工具给出的每一条调拨都须由经营者人工放行。 第三章把位势读成地点价格:计入缺货毛利损失后,示意网络的最优总成本是 7322 元,「缺货店优先补」是 11003 元;每家店多一件货的影子价格都挤在边际缺货店的 1320 元附近,缺一件损失最大的店只值 1253 元,而影子价格是局部斜率,同一家店多 8 件只值 5709 元。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.721

commanderyto capital (100 li)freight/boltnet at capital
A3.0120480
B8.0320280
C11.7466134
D15.2609-9
E18.1724-124
commanderies whose freight exceeds the cloth's value: 2
hub freight 194450 coins; lateral freight 54340 coins; saving 0.721
lateral: A>CAP 30, B>CAP 20, C>CAP 30, C>G1 10, D>G2 50, E>G1 50, E>G2 10
查看完整验算程序
# Chapter 7. p71: "all tribute to the capital" against "pour across".
# A toy reading of the Pingzhun shu: five commanderies A to E pay tax in
# cloth (bolts); the capital needs 80 bolts and two frontier garrisons
# need 60 each. Positions are in units of 100 li; freight is 40 coins a
# bolt per 100 li; a bolt is worth 600 coins at the capital. All numbers
# are illustrative, chosen only to make the structure visible.
# Hub plan: everything to the capital, which forwards the garrisons'
# share. Lateral plan: one transportation problem solved by MODI.
import math

def northwest(s, d):
    # 西北角初解:阶梯形走 m + n - 1 步,保证基是一棵生成树
    s, d = list(s), list(d)
    m, n = len(s), len(d)
    x = [[0] * n for _ in range(m)]
    basis = []
    i = j = 0
    while True:
        q = min(s[i], d[j])
        x[i][j] = q
        basis.append((i, j))
        s[i] -= q
        d[j] -= q
        if i == m - 1 and j == n - 1:
            break
        if s[i] == 0 and i < m - 1:
            i += 1
        else:
            j += 1
    return x, basis


def potentials(c, basis, m, n):
    # 位势:基格上 u_i + v_j = c_ij,取 u_0 = 0
    u = [None] * m
    v = [None] * n
    u[0] = 0
    while None in u or None in v:
        for i, j in basis:
            if u[i] is not None and v[j] is None:
                v[j] = c[i][j] - u[i]
            elif v[j] is not None and u[i] is None:
                u[i] = c[i][j] - v[j]
    return u, v


def tree_path(basis, i, j):
    # 基树中从列 j 走回行 i 的格子序列(闭回路去掉入基格)
    adj = {}
    for a, b in basis:
        adj.setdefault(("r", a), []).append(("c", b))
        adj.setdefault(("c", b), []).append(("r", a))
    prev = {("r", i): None}
    todo = [("r", i)]
    while todo:
        node = todo.pop()
        for nb in adj.get(node, []):
            if nb not in prev:
                prev[nb] = node
                todo.append(nb)
    path, node = [], ("c", j)
    while prev[node] is not None:
        p = prev[node]
        cell = (p[1], node[1]) if p[0] == "r" else (node[1], p[1])
        path.append(cell)
        node = p
    return path


def modi(c, s, d, x=None, basis=None, trace=None):
    # 位势法(MODI):检验数 r_ij = c_ij - u_i - v_j 全部非负即最优
    m, n = len(s), len(d)
    if x is None:
        x, basis = northwest(s, d)
    x = [row[:] for row in x]
    basis = list(basis)
    steps = 0
    while True:
        u, v = potentials(c, basis, m, n)
        best, cell = 0, None
        for i in range(m):
            for j in range(n):
                r = c[i][j] - u[i] - v[j]
                if r < best:
                    best, cell = r, (i, j)
        if cell is None:
            return x, basis, u, v, steps
        i, j = cell
        path = tree_path(basis, i, j)
        minus, plus = path[0::2], path[1::2]
        theta = min(x[a][b] for a, b in minus)
        out = [e for e in minus if x[e[0]][e[1]] == theta][0]
        x[i][j] += theta
        for a, b in minus:
            x[a][b] -= theta
        for a, b in plus:
            x[a][b] += theta
        basis.remove(out)
        basis.append(cell)
        steps += 1
        if trace is not None:
            trace.append((cell, best, theta, out))


def total(c, x):
    return math.fsum(c[i][j] * x[i][j]
                     for i in range(len(x)) for j in range(len(x[0])))

POS = {"CAP": (0, 0), "A": (3, 0), "B": (0, 8), "C": (10, 6),
       "D": (14, -6), "E": (18, 2), "G1": (16, 8), "G2": (20, -4)}
SRC, TAX = ["A", "B", "C", "D", "E"], [30, 20, 40, 50, 60]
DST, NEED = ["CAP", "G1", "G2"], [80, 60, 60]
RATE, VALUE = 40, 600


def dist(a, b):
    (x1, y1), (x2, y2) = POS[a], POS[b]
    return math.hypot(x1 - x2, y1 - y2)


def fr(a, b):
    return round(RATE * dist(a, b))


print("commandery  to capital (100 li)  freight/bolt  net at capital")
loss = 0
for a in SRC:
    f = fr(a, "CAP")
    loss += f > VALUE
    print("%-10s %20.1f %13d %15d" % (a, dist(a, "CAP"), f, VALUE - f))
print("commanderies whose freight exceeds the cloth's value: %d" % loss)
hub = math.fsum([q * fr(a, "CAP") for a, q in zip(SRC, TAX)]
                + [q * fr("CAP", g) for g, q in zip(DST[1:], NEED[1:])])
C = [[fr(a, b) for b in DST] for a in SRC]
x = modi(C, TAX, NEED)[0]
lat = total(C, x)
print("hub freight %d coins; lateral freight %d coins; saving %.3f"
      % (int(hub), int(lat), 1.0 - lat / hub))
print("lateral: " + ", ".join(
    "%s>%s %d" % (SRC[i], DST[j], x[i][j])
    for i in range(5) for j in range(3) if x[i][j]))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《最优传输康托罗维奇对偶、跨区域奢品调货最小搬运代价与客群迁移矩阵母典》第 7 章「东西方原典考辨:桑弘羊均输与蒙日的挖填土方」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-233 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026233,
  author    = {Fan, Yafu},
  title     = {Optimal Transport and Kantorovich Duality: Minimum-Cost Rebalancing of Luxury Stock across Regions and Client-Migration Matrices},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论