FAILURE MAP
← Case archive

FA-64911 / Epidemic compartment models / Open access

SEIR R0 with vital dynamics and vaccine coverage: herd threshold · case 01

Herd immunity thresholds fall as R0 rises.

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

ROOT CAUSE

The susceptible fraction at equilibrium 1/R0 is reported instead of the immune fraction 1-1/R0.

THE FAILURE

The susceptible fraction at equilibrium 1/R0 is reported instead of the immune fraction 1-1/R0.

Unsuccessful approach: (R0-1)/(R0+1) is not the threshold and understates it for every R0>1.

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 + mu))
    if r0 <= 1:
        return [round(r0, 6), 0.0, 0.0]
    threshold = 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 = [[('regression: 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: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
  ('control: 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]),
  ('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None)],
 [('control: 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])],
 [('regression: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
  ('control: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
  ('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])],
 [('regression: 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: 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]),
  ('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), 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])],
 [('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
  ('regression: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
  ('control: 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 fixtureActualExpectedOutcome
regression: measles-like high R0[14.4, 0.069444, 0.073099][14.4, 0.930556, 0.979532]Failed
regression: flu-like moderate R0 with births[1.780627, 0.5616, 0.936][1.780627, 0.4384, 0.730667]Failed
regression: exact R0 of two with half efficacy[2.0, 0.5, 1.0][2.0, 0.5, 1.0]Passed
control: 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.180833, 0.361667][5.529954, 0.819167, None]Failed
control: invalid efficacy zeroNoneNonePassed

SHA-256 / 4bb324aded9227a7f97b808d9bea775cb2bb98bd605cb6a95fe835dcec54ab41

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 = (r0 - 1) / (r0 + 1)
    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 = [[('regression: 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: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
  ('control: 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]),
  ('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None)],
 [('control: 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])],
 [('regression: measles-like high R0', (1.8, 0.1, 0.125, 0.0, 0.95), [14.4, 0.930556, 0.979532]),
  ('control: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
  ('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])],
 [('regression: 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: 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]),
  ('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), 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])],
 [('regression: flu-like moderate R0 with births', (0.5, 0.5, 0.25, 0.02, 0.6), [1.780627, 0.4384, 0.730667]),
  ('regression: exact R0 of two with half efficacy', (2.0, 1.0, 1.0, 0.0, 0.5), [2.0, 0.5, 1.0]),
  ('control: 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 fixtureActualExpectedOutcome
regression: measles-like high R0[14.4, 0.87013, 0.915926][14.4, 0.930556, 0.979532]Failed
regression: flu-like moderate R0 with births[1.780627, 0.280738, 0.467896][1.780627, 0.4384, 0.730667]Failed
regression: exact R0 of two with half efficacy[2.0, 0.333333, 0.666667][2.0, 0.5, 1.0]Failed
control: 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.693719, None][5.529954, 0.819167, None]Failed
control: invalid efficacy zeroNoneNonePassed

SHA-256 / 6f14bdd6a1b7b6a99b324b56c2b28ef05745eefb7370e97ee89cca57708e6622

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / b6220dbdbbc79f0a34cb0147d87c07866b9c3471f9686a54b1e066512b50bb4e