5D Library › 企业瓶颈诊断、产品线自蚕食审计与自动化改造回报边界 · English

第八章 从日志找瓶颈、合约账本与预注册的切换实验

从事件日志估计负荷

诊断的第一步是测量,而不是访谈。把第一章的网络逐件模拟 32 天(前 2 天作为预热),每天的事件日志给出每个团队的忙碌比例(忙碌的人时除以人数乘以一天)。

推导

# Chapter 8. p14: Finding the bottleneck from event logs. The network of
# p01 is simulated job by job for 32 days (2 days warm-up) at 20 jobs a
# day; each day's log gives every team's busy fraction (busy server time
# / (servers x 1 day)). How often does a sample of k logged days name the
# right team? Bootstrap over days, seed 83, 2,000 resamples per k.
import heapq
import importlib.util
import random

def load(name):
    spec = importlib.util.spec_from_file_location(name, name + ".py")
    m = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(m)
    return m

p01 = load("p01_jackson_open")
C, MU = p01.BASE["c"], p01.BASE["mu"]
DAYS, WARM = 32, 2

def simulate(rng, lam=20.0):
    busy = [[0.0] * DAYS for _ in range(4)]
    free = list(C)
    queue = [[] for _ in range(4)]
    ev = [(rng.expovariate(lam), 0, -1)]      # (time, kind, station)
    seq = 0

    def add_busy(i, t0, t1):
        while t0 < t1 and int(t0) < DAYS:
            d = int(t0)
            step = min(t1, d + 1) - t0
            busy[i][d] += step
            t0 += step

    def start(i, t):
        nonlocal seq
        free[i] -= 1
        s = rng.expovariate(MU[i])
        add_busy(i, t, t + s)
        seq += 1
        heapq.heappush(ev, (t + s, seq, i))

    def arrive(i, t):
        if free[i] > 0:
            start(i, t)
        else:
            queue[i].append(t)

    while ev:
        t, kind, i = heapq.heappop(ev)
        if t >= DAYS:
            break
        if i < 0:
            arrive(0, t)
            heapq.heappush(ev, (t + rng.expovariate(lam), 0, -1))
            continue
        free[i] += 1
        if queue[i]:
            queue[i].pop(0)
            start(i, t)
        u, acc = rng.random(), 0.0
        for j in range(4):
            acc += p01.ROUTE[i][j]
            if u < acc:
                arrive(j, t)
                break
    return [[busy[i][d] / C[i] for d in range(WARM, DAYS)]
            for i in range(4)]

if __name__ == "__main__":
    rng = random.Random(83)
    load_ = simulate(rng)
    n = len(load_[0])
    true = p01.network(20.0, C, MU)[0]
    print("   team         true load  logged load ({} days)".format(n))
    for i, name in enumerate(p01.NAMES):
        print("   {:<12} {:9.3f}  {:11.3f}".format(
            name, true[i], sum(load_[i]) / n))
    for k in (1, 3, 7, 14, 30):
        hit = 0
        for _ in range(2000):
            days = [rng.randrange(n) for _ in range(k)]
            est = [sum(load_[i][d] for d in days) for i in range(4)]
            hit += max(range(4), key=lambda i: est[i]) == 2
        print("   {:2d} logged days: bottleneck named correctly {:.3f}"
              .format(k, hit / 2000))
#    team         true load  logged load (30 days)
#    content          0.714        0.778
#    acquisition      0.625        0.678
#    conversion       0.833        0.858
#    fulfilment       0.579        0.553
#     1 logged days: bottleneck named correctly 0.526
#     3 logged days: bottleneck named correctly 0.716
#     7 logged days: bottleneck named correctly 0.827
#    14 logged days: bottleneck named correctly 0.904
#    30 logged days: bottleneck named correctly 0.976

30 天日志估计的负荷是:内容 0.778、投流 0.678、转化 0.858、履约 0.553(理论值 0.714、0.625、0.833、0.579)。日志能找出瓶颈,但需要足够的天数:只看 1 天,有 0.526 的概率认对;3 天 0.716;7 天 0.827;14 天 0.904;30 天 0.976。内容团队的负荷与转化团队只差一成多,短期的随机波动足以让两者排错。

24 个月的合约账本

推导

# Chapter 8. p15: A 24-month engagement ledger. Contracts from p09, each
# with the base fee that gives the consultant a certainty equivalent of
# RM 25k a month: the best share beta*, a 50% share, and a flat fee
# (beta 0). The gain ramps up linearly over the first 6 months; money is
# discounted at 1% a month. Figures in RM 1k, present values.
import importlib.util

def load(name):
    spec = importlib.util.spec_from_file_location(name, name + ".py")
    m = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(m)
    return m

p09 = load("p09_gainshare")
SIGMA = 40.0

def ledger(beta):
    ec, ef = beta * p09.A, (1 - beta) * p09.B
    gain = p09.A * ec + p09.B * ef
    fee = p09.base_fee(beta, SIGMA)
    pv = {"gain": 0.0, "fees": 0.0, "effort": 0.0}
    for t in range(1, 25):
        ramp = min(t / 6, 1.0)
        df = 1.01 ** -t
        pv["gain"] += df * ramp * gain
        pv["fees"] += df * (fee + beta * ramp * gain)
        pv["effort"] += df * ramp * ef ** 2 / 2
    pv["client"] = pv["gain"] - pv["fees"] - pv["effort"]
    return pv

if __name__ == "__main__":
    b = p09.best(SIGMA)
    print("   contract          PV gain  PV fees  client effort  client net")
    for label, beta in (("beta* = {:.3f}".format(b), b), ("beta = 0.5", 0.5),
                        ("flat fee", 0.0)):
        v = ledger(beta)
        print("   {:<16} {:8,.0f} {:8,.0f} {:14,.0f} {:11,.0f}".format(
            label, v["gain"], v["fees"], v["effort"], v["client"]))
#    contract          PV gain  PV fees  client effort  client net
#    beta* = 0.214       1,622      519            580         523
#    beta = 0.5          1,278      629            235         415
#    flat fee            1,880      531            940         409

用第五章的三种合约(每种都按顾问每月确定性等价 RM 25k 设定底座费),增量在头 6 个月线性爬升,按每月 1% 贴现。最优分成 0.214:增量现值 1,622(千令吉),顾问费现值 519,企业自身投入的成本 580,企业净得 523。分成 0.5:增量现值降到 1,278,企业净得 415。固定费:增量现值最高(1,880),因为企业知道改善全归自己而投入最多,但它自身投入的成本也最高(940),企业净得 409。分成合约对企业更有利,并不是因为顾问费更低,而是因为双方的投入更接近最优。

注

四步核查。 第一,用至少两周的事件日志估计每个团队的负荷,不用访谈或工时表。第二,先扩容瓶颈,再按瓶颈的节奏放行上游的工作;非瓶颈的改善以降低波动为先。第三,删减 SKU 之前先估计转移分流率与增量贡献,并确认接收商品有产能。第四,分成合约写明对照组、年度合计核对与审计触发条件,并在合约中写明结果不论好坏都按同一方法结算 (Kohavi et al. 2020)。

预注册的切换实验

瓶颈改造的效果怎样证明?可以按周随机切换:一些周启用额外的成交顾问,一些周不启用;每周丢弃前 2 天作为洗脱期。

推导

# Chapter 8. p16: A pre-registered switchback test of a bottleneck fix.
# Weeks alternate at random between "extra closer on" and "off"; the
# outcome is closed sales per week, with week-to-week coefficient of
# variation 0.12. The first 2 days of each week are dropped as wash-out,
# which leaves 5 of 7 days and raises the CV by sqrt(7/5). Weeks per arm
# for power 0.80, two-sided alpha 0.05: 2 * ((1.96 + 0.84) * cv / lift)^2.
from math import ceil, sqrt

def weeks(lift, cv=0.12, washout=True):
    c = cv * sqrt(7 / 5) if washout else cv
    return ceil(2 * ((1.96 + 0.84) * c / lift) ** 2)

if __name__ == "__main__":
    print("   lift   weeks per arm (no wash-out / with wash-out)")
    for lift in (0.05, 0.10, 0.15, 0.20):
        print("   {:4.0%}   {:3d} / {:3d}".format(
            lift, weeks(lift, washout=False), weeks(lift)))
#    lift   weeks per arm (no wash-out / with wash-out)
#      5%    91 / 127
#     10%    23 /  32
#     15%    11 /  15
#     20%     6 /   8

每周成交量的变异系数为 0.12 时,若要检出 10% 的提升,不设洗脱期时每组需要 23 周,设洗脱期时需要 32 周;检出 20% 的提升只需 6 周与 8 周;检出 5% 的提升则需要 91 周与 127 周。

假说 · 尚未验证

预注册的预测(尚未验证): 在示意的四团队结构中,给转化团队增加一名成交顾问会使每周成交量提高至少 10%;在内容团队上同等金额的自动化投入,使每周成交量提高不到 3%。什么会证明它错: 在按周随机切换的实验中,前者的提升显著低于 10%,或后者的提升显著高于 3%。

全书小结

在排队网络中,吞吐量由瓶颈决定;非瓶颈的自动化可以缩短交付周期,却不能提高产出上限,而把更多工作推入瓶颈只会让在制品按双曲线膨胀、让线索变冷。产品线的自蚕食要用转移分流率与毛利稀释矩阵来看:接回毛利高于自身毛利的副线在拉低总利润,而「砍掉三成」并不是定律。外部顾问的合约在双边道德风险下应当是一笔小的底座费加约两成的增量分成,增量要以对照组测量、按年度核对。诊断本身不产生产能,它的价值在于把投资引向瓶颈。

参考文献

Kohavi, Ron, Diane Tang, and Ya Xu. 2020. Trustworthy Online Controlled Experiments: A Practical Guide to a/b Testing. Cambridge University Press.

Fan, Y. (2026). Enterprise Bottleneck Diagnostics, SKU Cannibalization Audits and Automation Return Bounds: Theory-of-Constraints Queueing Networks, Margin Dilution Matrices and Value-Based Advisory Pricing [企业瓶颈诊断、产品线自蚕食审计与自动化改造回报边界] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090217 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).