FA-64901 / Epidemic compartment models / Open access
SEIR R0 with vital dynamics and vaccine coverage: infectious period mortality · case 01
R0 ignores that hosts can die while infectious and is too high with vital dynamics.
ROOT CAUSE
The infectious residence time uses 1/gamma instead of 1/(gamma+mu).
VERIFIED REPAIR
Restore the infectious period mortality rule: `beta * sigma / ((sigma + mu) * (gamma + mu))`.
Unsuccessful approach: Using gamma-mu lengthens the infectious period instead of shortening it.
Case contract
R0 = beta*sigma/((sigma+mu)*(gamma+mu)); when R0<=1 return [R0,0.0,0.0]; herd threshold 1-1/R0; critical coverage threshold/efficacy, None if it exceeds 1 (exactly 1 is feasible); values rounded to 6; None for invalid rates or efficacy outside (0,1].
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(beta, sigma, gamma, mu, efficacy):
if min(beta, sigma, gamma) <= 0 or mu < 0 or not 0 < efficacy <= 1:
return None
r0 = beta * sigma / ((sigma + mu) * gamma)
if r0 <= 1:
return [round(r0, 6), 0.0, 0.0]
threshold = 1 - 1 / r0
coverage = threshold / efficacy
if coverage > 1:
coverage = None
else:
coverage = round(coverage, 6)
return [round(r0, 6), round(threshold, 6), coverage]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6])],
[('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None),
('control: invalid negative mortality', (1.0, 0.5, 0.2, -0.1, 0.9), None),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773])],
[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None),
('control: invalid negative mortality', (1.0, 0.5, 0.2, -0.1, 0.9), None),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
('regression: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
('regression: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
[('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None)]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: measles-like high R0 | [14.4, 0.930556, 0.979532] | [14.4, 0.930556, 0.979532] | Passed |
| regression: flu-like moderate R0 with births | [1.923077, 0.48, 0.8] | [1.780627, 0.4384, 0.730667] | Failed |
| control: exact R0 of two with half efficacy | [2.0, 0.5, 1.0] | [2.0, 0.5, 1.0] | Passed |
| regression: subcritical with mortality | [0.96, 0.0, 0.0] | [0.8, 0.0, 0.0] | Failed |
| control: boundary R0 exactly one | [1.0, 0.0, 0.0] | [1.0, 0.0, 0.0] | Passed |
| regression: infeasible coverage poor vaccine | [5.806452, 0.827778, None] | [5.529954, 0.819167, None] | Failed |
| regression: high mortality relative to latency | [3.0, 0.666667, 0.666667] | [2.5, 0.6, 0.6] | Failed |
SHA-256 / 7bb2ad31767d4c8441d4ae009759bcc00006bc51e5568ac84d6421aac6aa8033
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, sigma, gamma, mu, efficacy):
if min(beta, sigma, gamma) <= 0 or mu < 0 or not 0 < efficacy <= 1:
return None
r0 = beta * sigma / ((sigma + mu) * (gamma - mu))
if r0 <= 1:
return [round(r0, 6), 0.0, 0.0]
threshold = 1 - 1 / r0
coverage = threshold / efficacy
if coverage > 1:
coverage = None
else:
coverage = round(coverage, 6)
return [round(r0, 6), round(threshold, 6), coverage]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6])],
[('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None),
('control: invalid negative mortality', (1.0, 0.5, 0.2, -0.1, 0.9), None),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773])],
[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None),
('control: invalid negative mortality', (1.0, 0.5, 0.2, -0.1, 0.9), None),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
('regression: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
('regression: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
[('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None)]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: measles-like high R0 | [14.4, 0.930556, 0.979532] | [14.4, 0.930556, 0.979532] | Passed |
| regression: flu-like moderate R0 with births | [2.090301, 0.5216, 0.869333] | [1.780627, 0.4384, 0.730667] | Failed |
| control: exact R0 of two with half efficacy | [2.0, 0.5, 1.0] | [2.0, 0.5, 1.0] | Passed |
| regression: subcritical with mortality | [1.2, 0.166667, 0.185185] | [0.8, 0.0, 0.0] | Failed |
| control: boundary R0 exactly one | [1.0, 0.0, 0.0] | [1.0, 0.0, 0.0] | Passed |
| regression: infeasible coverage poor vaccine | [6.112054, 0.836389, None] | [5.529954, 0.819167, None] | Failed |
| regression: high mortality relative to latency | [3.75, 0.733333, 0.733333] | [2.5, 0.6, 0.6] | Failed |
SHA-256 / 591df13ccbc9da6819306012fbd5c37c46f52e7e36a66247a38e9c9650f7b6ec
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, sigma, gamma, mu, efficacy):
if min(beta, sigma, gamma) <= 0 or mu < 0 or not 0 < efficacy <= 1:
return None
r0 = beta * sigma / ((sigma + mu) * (gamma + mu))
if r0 <= 1:
return [round(r0, 6), 0.0, 0.0]
threshold = 1 - 1 / r0
coverage = threshold / efficacy
if coverage > 1:
coverage = None
else:
coverage = round(coverage, 6)
return [round(r0, 6), round(threshold, 6), coverage]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6])],
[('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None),
('control: invalid negative mortality', (1.0, 0.5, 0.2, -0.1, 0.9), None),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773])],
[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None),
('control: invalid negative mortality', (1.0, 0.5, 0.2, -0.1, 0.9), None),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
('regression: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
[('control: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
('regression: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
[('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
('control: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
('regression: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
('control: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
('regression: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
('regression: high mortality relative to latency', (3.0, 0.1, 0.5, 0.1, 1.0), [2.5, 0.6, 0.6]),
('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None)]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: measles-like high R0 | [14.4, 0.930556, 0.979532] | [14.4, 0.930556, 0.979532] | Passed |
| regression: flu-like moderate R0 with births | [1.780627, 0.4384, 0.730667] | [1.780627, 0.4384, 0.730667] | Passed |
| control: exact R0 of two with half efficacy | [2.0, 0.5, 1.0] | [2.0, 0.5, 1.0] | Passed |
| regression: subcritical with mortality | [0.8, 0.0, 0.0] | [0.8, 0.0, 0.0] | Passed |
| control: boundary R0 exactly one | [1.0, 0.0, 0.0] | [1.0, 0.0, 0.0] | Passed |
| regression: infeasible coverage poor vaccine | [5.529954, 0.819167, None] | [5.529954, 0.819167, None] | Passed |
| regression: high mortality relative to latency | [2.5, 0.6, 0.6] | [2.5, 0.6, 0.6] | Passed |
SHA-256 / 1053d05ecf1000ce705418fb70e92e51543fd1998dcc68cac771bab9398ff6c6
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:28.886924+00:00.
Case digest / 38067655ce441eded6cd3c7a3afd2c46d0db47149ac8030ce4bbdf378dd77943