FAILURE MAP
← Case archive

FA-65041 / Epidemic compartment models / Open access

Final epidemic size by bisection: upper bracket · case 01

The attack fraction never exceeds the herd-immunity threshold (no overshoot).

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The bracket is capped at the herd-immunity threshold, below the final size.

VERIFIED REPAIR

Restore the upper bracket rule: `lo, hi = 1e-9, 1.0`.

Unsuccessful approach: Capping at 1/R0 still excludes the root for R0 above about 1.3.

Case contract

Attack fraction z is the positive root of z = 1-exp(-R0*z) found by bisection on (1e-9, 1] until the bracket is narrower than tol; for R0<=1 return [0.0, 0, 0.0]; return [z rounded 6, round(z*pop), overshoot z-(1-1/R0) rounded 6].

Why this case matters

Compartmental epidemic calculations drive outbreak forecasts, vaccine targets and hospital planning; a single wrong flow, rate conversion or boundary silently changes every downstream number.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(r0, pop, tol):
    if r0 <= 1:
        return [0.0, 0, 0.0]
    lo, hi = 1e-9, 1 - 1 / r0
    for _ in range(200):
        mid = (lo + hi) / 2
        if mid - (1 - math.exp(-r0 * mid)) < 0:
            lo = mid
        else:
            hi = mid
        if hi - lo < tol:
            break
    z = (lo + hi) / 2
    return [round(z, 6), round(z * pop), round(z - (1 - 1 / r0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('regression: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('regression: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: flu-like R0 1.5[0.333333, 3333, -0.0][0.582812, 5828, 0.249478]Failed
regression: measles-like R0 12[0.916667, 917, -0.0][0.999994, 1000, 0.083327]Failed
regression: R0 2[0.5, 2500, -0.0][0.796812, 3984, 0.296812]Failed
regression: near threshold 1.05[0.047619, 4762, -0.0][0.093702, 9370, 0.046083]Failed
control: boundary R0 exactly 1[0.0, 0, 0.0][0.0, 0, 0.0]Passed
control: subcritical 0.8[0.0, 0, 0.0][0.0, 0, 0.0]Passed
control: subcritical 0.5[0.0, 0, 0.0][0.0, 0, 0.0]Passed

SHA-256 / de1369b68a7ab558a66031089ac3b3f7afc5eda4f398ec16d4138993f18cb377

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(r0, pop, tol):
    if r0 <= 1:
        return [0.0, 0, 0.0]
    lo, hi = 1e-9, 1 / r0
    for _ in range(200):
        mid = (lo + hi) / 2
        if mid - (1 - math.exp(-r0 * mid)) < 0:
            lo = mid
        else:
            hi = mid
        if hi - lo < tol:
            break
    z = (lo + hi) / 2
    return [round(z, 6), round(z * pop), round(z - (1 - 1 / r0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('regression: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('regression: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: flu-like R0 1.5[0.582812, 5828, 0.249478][0.582812, 5828, 0.249478]Passed
regression: measles-like R0 12[0.083333, 83, -0.833333][0.999994, 1000, 0.083327]Failed
regression: R0 2[0.5, 2500, -0.0][0.796812, 3984, 0.296812]Failed
regression: near threshold 1.05[0.093702, 9370, 0.046083][0.093702, 9370, 0.046083]Passed
control: boundary R0 exactly 1[0.0, 0, 0.0][0.0, 0, 0.0]Passed
control: subcritical 0.8[0.0, 0, 0.0][0.0, 0, 0.0]Passed
control: subcritical 0.5[0.0, 0, 0.0][0.0, 0, 0.0]Passed

SHA-256 / 5e0c727b13ae4aa633734bd85e36bd53be990187a34d382961a2596199f5cf50

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(r0, pop, tol):
    if r0 <= 1:
        return [0.0, 0, 0.0]
    lo, hi = 1e-9, 1.0
    for _ in range(200):
        mid = (lo + hi) / 2
        if mid - (1 - math.exp(-r0 * mid)) < 0:
            lo = mid
        else:
            hi = mid
        if hi - lo < tol:
            break
    z = (lo + hi) / 2
    return [round(z, 6), round(z * pop), round(z - (1 - 1 / r0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('regression: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('regression: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('regression: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('regression: near threshold 1.05', (1.05, 100000, 1e-12), [0.093702, 9370, 0.046083]),
  ('control: boundary R0 exactly 1', (1.0, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('regression: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: flu-like R0 1.5[0.582812, 5828, 0.249478][0.582812, 5828, 0.249478]Passed
regression: measles-like R0 12[0.999994, 1000, 0.083327][0.999994, 1000, 0.083327]Passed
regression: R0 2[0.796812, 3984, 0.296812][0.796812, 3984, 0.296812]Passed
regression: near threshold 1.05[0.093702, 9370, 0.046083][0.093702, 9370, 0.046083]Passed
control: boundary R0 exactly 1[0.0, 0, 0.0][0.0, 0, 0.0]Passed
control: subcritical 0.8[0.0, 0, 0.0][0.0, 0, 0.0]Passed
control: subcritical 0.5[0.0, 0, 0.0][0.0, 0, 0.0]Passed

SHA-256 / 276fe074ca17ce115b08783f76d26d7774ee7427a71e69e15d95b8a4d32c785e

Verification & scope

Deterministic bounded teaching model with a stipulated contract; not a validated scientific or public-health modelling library. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:47:30.168957+00:00.

Case digest / 0031257ce8b8308b7146f65103d90cb42abec58dbb63d695e20c689e5ffa61a9