FAILURE MAP
← Case archive

FA-65031 / Epidemic compartment models / Open access

Final epidemic size by bisection: subcritical regime · case 01

Subcritical pathogens report a large positive overshoot.

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

ROOT CAUSE

The R0<=1 guard is missing so 1-1/R0 is negative in the overshoot.

VERIFIED REPAIR

Restore the subcritical regime rule: `if r0 <= 1: / return [0.0, 0, 0.0]`.

Unsuccessful approach: Guarding only R0<=0 still evaluates subcritical cases.

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):
    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 = [[('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: 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
control: flu-like R0 1.5[0.582812, 5828, 0.249478][0.582812, 5828, 0.249478]Passed
control: measles-like R0 12[0.999994, 1000, 0.083327][0.999994, 1000, 0.083327]Passed
control: R0 2[0.796812, 3984, 0.296812][0.796812, 3984, 0.296812]Passed
control: 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
regression: subcritical 0.8[0.0, 0, 0.25][0.0, 0, 0.0]Failed
regression: subcritical 0.5[0.0, 0, 1.0][0.0, 0, 0.0]Failed

SHA-256 / 2653cf921869e5a72be2b7fa36967b458cab2d8b97da9d13fa8318de07c9b917

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 <= 0:
        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 = [[('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: 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
control: flu-like R0 1.5[0.582812, 5828, 0.249478][0.582812, 5828, 0.249478]Passed
control: measles-like R0 12[0.999994, 1000, 0.083327][0.999994, 1000, 0.083327]Passed
control: R0 2[0.796812, 3984, 0.296812][0.796812, 3984, 0.296812]Passed
control: 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
regression: subcritical 0.8[0.0, 0, 0.25][0.0, 0, 0.0]Failed
regression: subcritical 0.5[0.0, 0, 1.0][0.0, 0, 0.0]Failed

SHA-256 / cddb4e5a26b9e1b19469f2ffc6335df718d79fbcd90f2c44611a3ad2a4ac51be

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 = [[('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('control: R0 1.2 mid city', (1.2, 250000, 1e-10), [0.313698, 78425, 0.147032]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: flu-like R0 1.5', (1.5, 10000, 1e-12), [0.582812, 5828, 0.249478]),
  ('control: measles-like R0 12', (12.0, 1000, 1e-12), [0.999994, 1000, 0.083327]),
  ('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('regression: subcritical 0.5', (0.5, 100, 1e-12), [0.0, 0, 0.0])],
 [('control: R0 2', (2.0, 5000, 1e-12), [0.796812, 3984, 0.296812]),
  ('control: 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]),
  ('regression: subcritical 0.8', (0.8, 1000, 1e-12), [0.0, 0, 0.0]),
  ('control: coarse tolerance', (2.5, 1000, 0.0001), [0.89267, 893, 0.29267]),
  ('control: R0 3 small town', (3.0, 777, 1e-12), [0.94048, 731, 0.273813]),
  ('regression: 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
control: flu-like R0 1.5[0.582812, 5828, 0.249478][0.582812, 5828, 0.249478]Passed
control: measles-like R0 12[0.999994, 1000, 0.083327][0.999994, 1000, 0.083327]Passed
control: R0 2[0.796812, 3984, 0.296812][0.796812, 3984, 0.296812]Passed
control: 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
regression: subcritical 0.8[0.0, 0, 0.0][0.0, 0, 0.0]Passed
regression: subcritical 0.5[0.0, 0, 0.0][0.0, 0, 0.0]Passed

SHA-256 / c7a3724cc5c945c33f074a0be032665523317c7daf491fc474d1f6f4b46c88ad

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.127370+00:00.

Case digest / 2625fbcaa032ab07ad61542c6e04cbb0e665cabbfc1c24c0d63370b47a78d7a2