关于「把一年排成背包问题」,《换汇点差、DCC 陷阱与居留天数》给出的定量结论是什么?

结论:第六章把一年写成背包问题:天数上限的成本是 16.5,台北多一天的影子价格 0.508,一年进出 4 次需要预留 5 天。

数据口径:书中的汇率、费率与行程均为示意模型;全部计算由书中程序生成;本书不是税务、移民、法律或投资建议。 书中以标注框区分已发表的证据、可运行的 Python 计算(16 段程序)、原典与作者的假说。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 与结论吻合的打印值: 0.508, 16.5

place free plan capped plan
Taipei238 182
Ho Chi Minh83 90
Shenzhen36 50
Tokyo8 14
home0 29
value934.0 free, 917.5 capped, cost of caps 16.5
shadow price of one more day in Taipei0.508
shadow price of one more day in Ho Chi Minh0.100
shadow price of one more day in Shenzhen0.000
shadow price of one more day in Tokyo0.000
查看完整验算程序
# Chapter 6. p11: Planning a year as a knapsack. A founder divides 365
# days among home and four other places. A day in place j is worth
# a_j - b_j d (falling as d days are spent there), so d days are worth
# a_j d - b_j d (d - 1) / 2. Caps: no more than 182 days in a place
# where 183 would make the founder tax-resident, and a short-stay limit
# of 90 days a year where only visa-free entry is planned. Exact
# dynamic programming over whole days; no sampling. The shadow price is
# what one more allowed day would add.
HOME = ("home", 1.8, 0.0, 365)
PLACES = (("Taipei", 3.4, 0.006, 182), ("Ho Chi Minh", 2.8, 0.01, 90),
          ("Shenzhen", 2.4, 0.012, 90), ("Tokyo", 2.2, 0.03, 90))

def value(a, b, d):
    return a * d - b * d * (d - 1) / 2

def solve(caps):
    best = {0: (0.0, ())}
    for (name, a, b, _), cap in zip(PLACES, caps):
        nxt = {}
        for used, (v, alloc) in best.items():
            for d in range(0, min(cap, 365 - used) + 1):
                key = used + d
                cand = v + value(a, b, d)
                if key not in nxt or cand > nxt[key][0]:
                    nxt[key] = (cand, alloc + (d,))
        best = nxt
    out = max(((v + HOME[1] * (365 - u), alloc + (365 - u,))
               for u, (v, alloc) in best.items()), key=lambda t: t[0])
    return out

if __name__ == "__main__":
    free = solve([365] * 4)
    capped = solve([p[3] for p in PLACES])
    names = [p[0] for p in PLACES] + ["home"]
    print("   place          free plan   capped plan")
    for i, n in enumerate(names):
        print("   {:12s}   {:9d}   {:11d}".format(n, free[1][i],
                                                 capped[1][i]))
    print("   value: {:.1f} free, {:.1f} capped, cost of caps {:.1f}"
          .format(free[0], capped[0], free[0] - capped[0]))
    caps = [p[3] for p in PLACES]
    for i in range(4):
        up = list(caps)
        up[i] += 1
        print("   shadow price of one more day in {}: {:.3f}".format(
            names[i], solve(up)[0] - capped[0]))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《多币种换汇点差微观结构、动态货币转换陷阱与税务居留天数规划》第 6 章「把一年排成背包问题」(版本 1.0.0). 5D Library. DOI 待发布

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

BibTeX
@book{fan2026108,
  author    = {Fan, Yafu},
  title     = {Multicurrency FX Spread Microstructure, Dynamic Currency Conversion Traps and Tax-Residency Day-Counting Thresholds},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论