关于「实证闭环:三城周度台账、试算器与预注册检验」,《三城分布式团队协同与验收》给出的定量结论是什么?

结论:周度台账记下工作的流动,试算器把台账变成切分块数、批量间隔、抽检样本、检验间隔与激励斜率五条建议,预注册方案说明了检验需要多少样本:H1 在中等效应下每组几十件,H2 需要一季度的批次,H3 每周八到十一次交接。三条核心命题都写明了推翻条件,推翻它们的数据,只能来自读者自己的台账。

数据口径:书中的作息、午休、成本系数、汇率波动率与价格水平均为示意参数,全部计算由书中程序生成;本书是非个人化管理建议,不构成法律或税务建议,三城劳动、税务与准证事项须由当地持牌顾问确认;书中不以城市或国籍给任何人群贴标签,也不涉及任何多层分润。 书中以标注框区分已发表的证据、可运行的 Python 计算(20 段程序)、原典与作者的假说。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库

Three-City Async Handoff and Sampling Calculator (B-340)
ledger: 6 tasks; wait per handoff 6.77 h; loss per handoff 0.151
split: best 2 pieces, 35.78 h calendar; 8 pieces 68.15 h
handoff notes: send a batch every 1.83 h
sampling: 90 inspected, 3 defective, 1 escaped later
  posterior mean 0.0364 vs breakeven 0.0400 -> ship rest
  best sample per lot 42; sample every 2.32 working days
slope: 0.667 on pieces alone; 0.364 when notes go unmeasured
  MYR paid in a base unit: beta 0.663; one base unit = 2.00 baskets
  TWD paid in a base unit: beta 0.665; one base unit = 1.67 baskets
  VND paid in a base unit: beta 0.666; one base unit = 2.50 baskets
pay the slope in local currency and scale it by price level;
labour, tax and visa matters: licensed advisers in each city
查看完整验算程序
# Chapter 8. p81: the weekly three-city ledger and what it recommends.
# Six illustrative tasks logged in one week: route, hours, pieces,
# handoffs, hours waited at handoffs, hours of rework traced to a
# handoff, items sampled, defects found, and defects that escaped and
# came back later. From the ledger: the wait per handoff H and the loss
# per handoff delta that p21 needs; the batch interval of p31; the
# posterior defect rate, decision and sample size of p51; the sampling
# interval of p52; the slopes of p61, p62 and p63. Distilled unchanged
# into distill/tool.py, whose no-argument demo prints these lines.
import math

DEMO_LEDGER = ("T01:KL>TPE,40,4,3,21.0,5.5,15,0,0;"
               "T02:TPE>HCM,32,3,2,13.5,3.0,15,1,0;"
               "T03:HCM>KL,48,5,4,30.0,7.0,15,0,1;"
               "T04:KL>HCM,24,2,1,5.5,1.0,15,0,0;"
               "T05:TPE>KL,40,4,3,19.5,4.5,15,2,0;"
               "T06:HCM>TPE,36,3,2,12.0,2.5,15,0,0")
DEMO_FX = "MYR:0.10:0.50;TWD:0.06:0.60;VND:0.03:0.40"


def parse_ledger(text):
    rows = []
    for item in text.split(";"):
        tid, rest = item.split(":", 1)
        f = rest.split(",")
        rows.append({"id": tid, "route": f[0], "hours": float(f[1]),
                     "pieces": int(f[2]), "handoffs": int(f[3]),
                     "wait": float(f[4]), "rework": float(f[5]),
                     "sampled": int(f[6]), "defects": int(f[7]),
                     "escapes": int(f[8])})
    return rows


def estimates(rows):
    hand = math.fsum(r["handoffs"] for r in rows)
    wait = math.fsum(r["wait"] for r in rows)
    exposed = math.fsum(r["handoffs"] * r["hours"] / r["pieces"]
                        for r in rows)
    rework = math.fsum(r["rework"] for r in rows)
    return wait / hand, rework / exposed


def span(k, work, serial, h, delta):  # p21
    return (work * (serial + (1 - serial) / k) + (k - 1) * h
            + (k - 1) * delta * work / k)


def best_split(work, serial, h, delta):
    return min(range(1, 41), key=lambda k: (span(k, work, serial, h,
                                                  delta), k))


def batch_interval(lam, k, cw):  # p31
    return math.sqrt(2 * k / (lam * cw))


def lbeta(a, b):
    return math.lgamma(a) + math.lgamma(b) - math.lgamma(a + b)


def exp_cost(n, a, b, k1, k2, lot):  # p51
    terms = [n * k1]
    for d in range(n + 1):
        pred = math.comb(n, d) * math.exp(lbeta(a + d, b + n - d)
                                          - lbeta(a, b))
        post = (a + d) / (a + b + n)
        terms.append(pred * (lot - n) * min(k1, post * k2))
    return math.fsum(terms)


def best_n(a, b, k1, k2, lot):
    return min(range(0, lot), key=lambda n: (exp_cost(n, a, b, k1, k2,
                                                      lot), n))


def drift_rate(t, nu, k1, k2):  # p52, same constants as the chapter
    lam, p0, p1, n, rep, fa = 40, 0.02, 0.12, 15, 8.0, 2.0

    def alarm(p):
        return 1 - (1 - p) ** n - n * p * (1 - p) ** (n - 1)
    good, bad = 1 / nu, t * (1 / alarm(p1) - 0.5)
    cycle = good + bad
    cost = math.fsum([cycle / t * n * k1, good / t * alarm(p0) * fa,
                      bad * lam * (p1 - p0) * k2, rep])
    return cost / cycle


def best_interval(nu, k1, k2):
    grid = [i / 100 for i in range(5, 3001)]
    return min(grid, key=lambda t: (drift_rate(t, nu, k1, k2), t))


def beta_single(r, s2):  # p61
    return 1 / (1 + r * s2)


def beta_multi(r, s2, s, m):  # p62
    def eff(b):
        e1, e2 = (b - s * m) / (1 - s * s), (m - s * b) / (1 - s * s)
        if e2 < 0:
            return b, 0.0
        if e1 < 0:
            return 0.0, m
        return e1, e2

    def surplus(b):
        e1, e2 = eff(b)
        cost = (e1 * e1 + e2 * e2) / 2 + s * e1 * e2
        return e1 + e2 + m * e2 - cost - r * b * b * s2 / 2
    grid = [i / 1000 for i in range(0, 1501)]
    return max(grid, key=lambda b: (surplus(b), -b))


def beta_fx(r, s2, vol):  # p63, analytic mean over 12 monthly paydays
    v = math.fsum(math.exp(vol * vol * t / 12) - 1
                  for t in range(1, 13)) / 12
    return 1 / (1 + r * (s2 * (1 + v) + v))


def run(a):
    rows = parse_ledger(a.ledger)
    h, delta = estimates(rows)
    k = best_split(a.work, a.serial, h, delta)
    pa, pb = (float(x) for x in a.prior.split(","))
    n = best_n(pa, pb, a.k1, a.k2, a.lot)
    sampled = int(math.fsum(r["sampled"] for r in rows))
    found = int(math.fsum(r["defects"] for r in rows))
    escaped = int(math.fsum(r["escapes"] for r in rows))
    post = (pa + found) / (pa + pb + sampled)
    fx = []
    for item in a.fx.split(";"):
        code, vol, level = item.split(":")
        fx.append({"code": code, "beta_base_unit": round(beta_fx(
            a.risk, a.noise, float(vol)), 3), "price_level": float(level),
            "real_per_base_unit": round(1 / float(level), 2)})
    return {
        "tasks": len(rows), "wait_per_handoff_h": round(h, 2),
        "loss_per_handoff": round(delta, 3),
        "best_split": k, "span_best_h": round(span(
            k, a.work, a.serial, h, delta), 2),
        "span_8_pieces_h": round(span(8, a.work, a.serial, h, delta), 2),
        "batch_interval_h": round(batch_interval(
            a.rate, a.note_cost, a.delay_cost), 2),
        "sampled": sampled, "defects": found, "escapes": escaped,
        "posterior_mean": round(post, 4),
        "breakeven": round(a.k1 / a.k2, 4),
        "decision": "inspect rest" if post > a.k1 / a.k2 else "ship rest",
        "best_sample_n": n,
        "sample_every_days": best_interval(1 / a.shift_days, a.k1, a.k2),
        "beta_single": round(beta_single(a.risk, a.noise), 3),
        "beta_with_notes": beta_multi(a.risk, a.noise, a.subst, a.norm),
        "fx": fx}


def show(o):
    print("Three-City Async Handoff and Sampling Calculator (B-340)")
    print("ledger: %d tasks; wait per handoff %.2f h; loss per handoff "
          "%.3f" % (o["tasks"], o["wait_per_handoff_h"],
                    o["loss_per_handoff"]))
    print("split: best %d pieces, %.2f h calendar; 8 pieces %.2f h" % (
        o["best_split"], o["span_best_h"], o["span_8_pieces_h"]))
    print("handoff notes: send a batch every %.2f h" % o["batch_interval_h"])
    print("sampling: %d inspected, %d defective, %d escaped later" % (
        o["sampled"], o["defects"], o["escapes"]))
    print("  posterior mean %.4f vs breakeven %.4f -> %s" % (
        o["posterior_mean"], o["breakeven"], o["decision"]))
    print("  best sample per lot %d; sample every %.2f working days" % (
        o["best_sample_n"], o["sample_every_days"]))
    print("slope: %.3f on pieces alone; %.3f when notes go unmeasured" % (
        o["beta_single"], o["beta_with_notes"]))
    for f in o["fx"]:
        print("  %s paid in a base unit: beta %.3f; one base unit = %.2f "
              "baskets" % (f["code"], f["beta_base_unit"],
                           f["real_per_base_unit"]))
    print("pay the slope in local currency and scale it by price level;")
    print("labour, tax and visa matters: licensed advisers in each city")


class Args:
    ledger, fx, prior = DEMO_LEDGER, DEMO_FX, "1,19"
    work, serial, rate, note_cost, delay_cost = 40.0, 0.3, 1.5, 0.5, 0.2
    k1, k2, lot, shift_days = 0.5, 12.5, 200, 40.0
    risk, noise, subst, norm = 1.0, 0.5, 0.5, 0.4


show(run(Args))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《跨时区多城市分布式团队协同、异步交付核验与区域人才配置效率母典》第 8 章「实证闭环:三城周度台账、试算器与预注册检验」(版本 1.0.0). 5D Library. DOI 待发布

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

BibTeX
@book{fan2026340,
  author    = {Fan, Yafu},
  title     = {Distributed Multi-City Team Coordination, Asynchronous Deliverable Verification and Regional Talent Allocation across KL, Taipei and HCMC},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论