fix(fire-target): Family/home targets monotonic (kills Family==Household)
The recompute solved each Case's FIRE number with an independent binary search, so Monte-Carlo path noise + the coarse £15k tolerance made Family (Household + 2 kids) tie or even UNDERCUT Household (6 hard inversions + 5 exact ties across the 22 countries) — the ~£20k kids cost quantised to ~£0. Now solve the Cases in increasing-cost order and lower-bound each by the previous Case's target on the SAME return paths: a heavier Case (more spend / +kids / +home) can never need less net worth than a lighter one, so Solo <= Household <= Family <= Family+home holds by construction. tol tightened 15k -> 1k so the genuine but small kids/home increment resolves instead of snapping to the previous grid step. Kids/home were already modelled correctly (verified) — this is purely a solver-resolution + monotonicity fix. Found + verified via the fire-countdown flaw-hunt workflow. 346 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
6efe3b0c31
commit
1b8809a01b
2 changed files with 33 additions and 3 deletions
|
|
@ -494,6 +494,16 @@ async def _recompute_fire_targets(
|
|||
)
|
||||
jur = jurisdiction_for_city(slug)
|
||||
kids_cf = kids_annual_spend(ratios, kids_base=kids_base)
|
||||
# Solve the Cases in increasing-cost order and lower-bound each
|
||||
# by the previous Case's target on the SAME return paths. A
|
||||
# heavier Case (more spend / +kids / +home) can never need LESS
|
||||
# net worth than a lighter one, so this guarantees
|
||||
# Solo <= Household <= Family <= Family+home by construction —
|
||||
# killing the Monte-Carlo-noise inversions where Family looked
|
||||
# cheaper than Household. tol is tight (£1k) so the genuine but
|
||||
# small kids/home increment (~£20k at the 99% bar) resolves
|
||||
# instead of being quantised to the previous grid step.
|
||||
prev_target = 0.0
|
||||
for case in (Case.SOLO, Case.HOUSEHOLD, Case.FAMILY):
|
||||
spend = case_base_spend(case, ratios)
|
||||
home_variants = (False, True) if case is Case.FAMILY else (False,)
|
||||
|
|
@ -509,10 +519,13 @@ async def _recompute_fire_targets(
|
|||
kids_start_year=KIDS_START_YEAR, kids_end_year=KIDS_END_YEAR,
|
||||
with_home=with_home, home_amount_gbp=home_amount, home_year=home_year,
|
||||
)
|
||||
# Bound the search to a sane SWR band (spend × 60 ≈
|
||||
# 1.67% floor) so the binary search converges fast.
|
||||
# hi = sane SWR band (spend × 60 ≈ 1.67% floor); lo =
|
||||
# previous (lighter) Case's target -> monotone chain +
|
||||
# a small band for the nested solves (fast).
|
||||
hi = min(5_000_000.0, spend * 60.0)
|
||||
res = solve_target_nw(
|
||||
paths, inp, hi=min(5_000_000.0, spend * 60.0), tol=15_000.0)
|
||||
paths, inp, lo=min(prev_target, hi), hi=hi, tol=1_000.0)
|
||||
prev_target = float(res.target_nw_gbp)
|
||||
await upsert_fire_target(sess, inp, res, n_paths)
|
||||
written += 1
|
||||
tag = "+home" if with_home else ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue