broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, gamma, pop, i0, days, substeps):
    if pop <= 0 or i0 < 0 or i0 > pop or substeps < 1:
        return None
    dt = 1.0 / substeps
    s = float(pop - i0)
    i = float(i0)
    r = 0.0
    peak_i = 0.0
    peak_day = 0
    for day in range(1, days + 1):
        for _ in range(substeps):
            new_inf = min(beta * s * i / pop * dt, s)
            new_rec = gamma * i * dt
            s -= new_inf
            i += new_inf - new_rec
            r += new_rec
        if i > peak_i:
            peak_i = i
            peak_day = day
    return [round(s, 3), round(peak_i, 3), peak_day, round(r, 3)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: mild outbreak in 1000', (0.3, 0.1, 1000, 1, 60, 4), [85.915, 303.71, 39, 810.961]),
  ('control: fast outbreak daily steps', (0.9, 0.2, 500, 5, 40, 1), [2.433, 249.994, 10, 497.014]),
  ('regression: subcritical seed decays', (0.08, 0.2, 1000, 10, 20, 2), [984.011, 10.0, 0, 15.167]),
  ('control: overshoot-prone large beta single step', (3.0, 0.5, 100, 50, 5, 1), [0.0, 75.0, 1, 95.312]),
  ('control: overshoot-prone large beta two steps', (2.5, 0.3, 200, 80, 6, 2), [0.0, 156.8, 1, 166.339]),
  ('regression: boundary zero days', (0.5, 0.1, 100, 3, 0, 2), [97.0, 3.0, 0, 0.0]),
  ('control: boundary no seed', (0.5, 0.1, 100, 0, 10, 2), [100.0, 0.0, 0, 0.0])],
 [('control: overshoot-prone large beta single step', (3.0, 0.5, 100, 50, 5, 1), [0.0, 75.0, 1, 95.312]),
  ('control: overshoot-prone large beta two steps', (2.5, 0.3, 200, 80, 6, 2), [0.0, 156.8, 1, 166.339]),
  ('regression: boundary zero days', (0.5, 0.1, 100, 3, 0, 2), [97.0, 3.0, 0, 0.0]),
  ('control: boundary no seed', (0.5, 0.1, 100, 0, 10, 2), [100.0, 0.0, 0, 0.0]),
  ('control: invalid seed above population', (0.5, 0.1, 100, 150, 10, 2), None),
  ('control: invalid zero substeps', (0.5, 0.1, 100, 1, 10, 0), None),
  ('regression: whole population seeded', (0.5, 0.2, 40, 40, 5, 2), [0.0, 40.0, 0, 26.053])],
 [('regression: subcritical seed decays', (0.08, 0.2, 1000, 10, 20, 2), [984.011, 10.0, 0, 15.167]),
  ('control: boundary no seed', (0.5, 0.1, 100, 0, 10, 2), [100.0, 0.0, 0, 0.0]),
  ('control: invalid seed above population', (0.5, 0.1, 100, 150, 10, 2), None),
  ('control: invalid zero substeps', (0.5, 0.1, 100, 1, 10, 0), None),
  ('control: slow recovery long run', (0.25, 0.05, 2000, 2, 90, 3), [19.331, 965.817, 43, 1829.639]),
  ('control: large city fine steps', (0.4, 0.15, 100000, 20, 50, 8), [13105.196, 25867.476, 37, 75829.968]),
  ('regression: whole population seeded', (0.5, 0.2, 40, 40, 5, 2), [0.0, 40.0, 0, 26.053])],
 [('control: mild outbreak in 1000', (0.3, 0.1, 1000, 1, 60, 4), [85.915, 303.71, 39, 810.961]),
  ('control: fast outbreak daily steps', (0.9, 0.2, 500, 5, 40, 1), [2.433, 249.994, 10, 497.014]),
  ('regression: subcritical seed decays', (0.08, 0.2, 1000, 10, 20, 2), [984.011, 10.0, 0, 15.167]),
  ('control: slow recovery long run', (0.25, 0.05, 2000, 2, 90, 3), [19.331, 965.817, 43, 1829.639]),
  ('control: large city fine steps', (0.4, 0.15, 100000, 20, 50, 8), [13105.196, 25867.476, 37, 75829.968]),
  ('control: small village', (0.6, 0.25, 50, 1, 30, 2), [5.845, 11.78, 12, 43.206]),
  ('regression: whole population seeded', (0.5, 0.2, 40, 40, 5, 2), [0.0, 40.0, 0, 26.053])],
 [('control: mild outbreak in 1000', (0.3, 0.1, 1000, 1, 60, 4), [85.915, 303.71, 39, 810.961]),
  ('control: fast outbreak daily steps', (0.9, 0.2, 500, 5, 40, 1), [2.433, 249.994, 10, 497.014]),
  ('regression: subcritical seed decays', (0.08, 0.2, 1000, 10, 20, 2), [984.011, 10.0, 0, 15.167]),
  ('control: overshoot-prone large beta single step', (3.0, 0.5, 100, 50, 5, 1), [0.0, 75.0, 1, 95.312]),
  ('control: overshoot-prone large beta two steps', (2.5, 0.3, 200, 80, 6, 2), [0.0, 156.8, 1, 166.339]),
  ('regression: boundary zero days', (0.5, 0.1, 100, 3, 0, 2), [97.0, 3.0, 0, 0.0]),
  ('regression: whole population seeded', (0.5, 0.2, 40, 40, 5, 2), [0.0, 40.0, 0, 26.053])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, gamma, pop, i0, days, substeps):
    if pop <= 0 or i0 < 0 or i0 > pop or substeps < 1:
        return None
    dt = 1.0 / substeps
    s = float(pop - i0)
    i = float(i0)
    r = 0.0
    peak_i = i * dt
    peak_day = 0
    for day in range(1, days + 1):
        for _ in range(substeps):
            new_inf = min(beta * s * i / pop * dt, s)
            new_rec = gamma * i * dt
            s -= new_inf
            i += new_inf - new_rec
            r += new_rec
        if i > peak_i:
            peak_i = i
            peak_day = day
    return [round(s, 3), round(peak_i, 3), peak_day, round(r, 3)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: mild outbreak in 1000', (0.3, 0.1, 1000, 1, 60, 4), [85.915, 303.71, 39, 810.961]),
  ('control: fast outbreak daily steps', (0.9, 0.2, 500, 5, 40, 1), [2.433, 249.994, 10, 497.014]),
  ('regression: subcritical seed decays', (0.08, 0.2, 1000, 10, 20, 2), [984.011, 10.0, 0, 15.167]),
  ('control: overshoot-prone large beta single step', (3.0, 0.5, 100, 50, 5, 1), [0.0, 75.0, 1, 95.312]),
  ('control: overshoot-prone large beta two steps', (2.5, 0.3, 200, 80, 6, 2), [0.0, 156.8, 1, 166.339]),
  ('regression: boundary zero days', (0.5, 0.1, 100, 3, 0, 2), [97.0, 3.0, 0, 0.0]),
  ('control: boundary no seed', (0.5, 0.1, 100, 0, 10, 2), [100.0, 0.0, 0, 0.0])],
 [('control: overshoot-prone large beta single step', (3.0, 0.5, 100, 50, 5, 1), [0.0, 75.0, 1, 95.312]),
  ('control: overshoot-prone large beta two steps', (2.5, 0.3, 200, 80, 6, 2), [0.0, 156.8, 1, 166.339]),
  ('regression: boundary zero days', (0.5, 0.1, 100, 3, 0, 2), [97.0, 3.0, 0, 0.0]),
  ('control: boundary no seed', (0.5, 0.1, 100, 0, 10, 2), [100.0, 0.0, 0, 0.0]),
  ('control: invalid seed above population', (0.5, 0.1, 100, 150, 10, 2), None),
  ('control: invalid zero substeps', (0.5, 0.1, 100, 1, 10, 0), None),
  ('regression: whole population seeded', (0.5, 0.2, 40, 40, 5, 2), [0.0, 40.0, 0, 26.053])],
 [('regression: subcritical seed decays', (0.08, 0.2, 1000, 10, 20, 2), [984.011, 10.0, 0, 15.167]),
  ('control: boundary no seed', (0.5, 0.1, 100, 0, 10, 2), [100.0, 0.0, 0, 0.0]),
  ('control: invalid seed above population', (0.5, 0.1, 100, 150, 10, 2), None),
  ('control: invalid zero substeps', (0.5, 0.1, 100, 1, 10, 0), None),
  ('control: slow recovery long run', (0.25, 0.05, 2000, 2, 90, 3), [19.331, 965.817, 43, 1829.639]),
  ('control: large city fine steps', (0.4, 0.15, 100000, 20, 50, 8), [13105.196, 25867.476, 37, 75829.968]),
  ('regression: whole population seeded', (0.5, 0.2, 40, 40, 5, 2), [0.0, 40.0, 0, 26.053])],
 [('control: mild outbreak in 1000', (0.3, 0.1, 1000, 1, 60, 4), [85.915, 303.71, 39, 810.961]),
  ('control: fast outbreak daily steps', (0.9, 0.2, 500, 5, 40, 1), [2.433, 249.994, 10, 497.014]),
  ('regression: subcritical seed decays', (0.08, 0.2, 1000, 10, 20, 2), [984.011, 10.0, 0, 15.167]),
  ('control: slow recovery long run', (0.25, 0.05, 2000, 2, 90, 3), [19.331, 965.817, 43, 1829.639]),
  ('control: large city fine steps', (0.4, 0.15, 100000, 20, 50, 8), [13105.196, 25867.476, 37, 75829.968]),
  ('control: small village', (0.6, 0.25, 50, 1, 30, 2), [5.845, 11.78, 12, 43.206]),
  ('regression: whole population seeded', (0.5, 0.2, 40, 40, 5, 2), [0.0, 40.0, 0, 26.053])],
 [('control: mild outbreak in 1000', (0.3, 0.1, 1000, 1, 60, 4), [85.915, 303.71, 39, 810.961]),
  ('control: fast outbreak daily steps', (0.9, 0.2, 500, 5, 40, 1), [2.433, 249.994, 10, 497.014]),
  ('regression: subcritical seed decays', (0.08, 0.2, 1000, 10, 20, 2), [984.011, 10.0, 0, 15.167]),
  ('control: overshoot-prone large beta single step', (3.0, 0.5, 100, 50, 5, 1), [0.0, 75.0, 1, 95.312]),
  ('control: overshoot-prone large beta two steps', (2.5, 0.3, 200, 80, 6, 2), [0.0, 156.8, 1, 166.339]),
  ('regression: boundary zero days', (0.5, 0.1, 100, 3, 0, 2), [97.0, 3.0, 0, 0.0]),
  ('regression: whole population seeded', (0.5, 0.2, 40, 40, 5, 2), [0.0, 40.0, 0, 26.053])]]
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)

prompt:
A declining subcritical outbreak reports its peak on day 1 instead of at the seed on day 0.

Frequency-dependent SIR integrated with forward Euler at dt=1/substeps; new infections per substep are beta*S*I/pop*dt capped at S; peak prevalence and its day are sampled at day ends (day 0 is the seed); return [S, peak I, peak day, R] rounded to 3 decimals, or None for invalid input.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / (latent_days + infectious_days)
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

prompt:
Onsets drain the exposed class many times over per day and turn negative.

Daily forward-Euler SEIR with sigma=1/latent_days and gamma=1/infectious_days; only I transmits (beta*S*I/pop); seeds start in E and are part of pop; return [daily E->I onsets rounded to 4, total population rounded to 4], or None for non-positive durations or population.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * (e + i) / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * e / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

prompt:
Transmission starts on day 0 although no seed is infectious yet.

Daily forward-Euler SEIR with sigma=1/latent_days and gamma=1/infectious_days; only I transmits (beta*S*I/pop); seeds start in E and are part of pop; return [daily E->I onsets rounded to 4, total population rounded to 4], or None for non-positive durations or population.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(exposure, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset - removal, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

prompt:
The reported onset curve is shifted a latent period earlier and starts at zero.

Daily forward-Euler SEIR with sigma=1/latent_days and gamma=1/infectious_days; only I transmits (beta*S*I/pop); seeds start in E and are part of pop; return [daily E->I onsets rounded to 4, total population rounded to 4], or None for non-positive durations or population.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - removal
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

prompt:
Total population grows every day and onsets keep rising after the epidemic ends.

Daily forward-Euler SEIR with sigma=1/latent_days and gamma=1/infectious_days; only I transmits (beta*S*I/pop); seeds start in E and are part of pop; return [daily E->I onsets rounded to 4, total population rounded to 4], or None for non-positive durations or population.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('regression: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('regression: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('regression: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), 0.0, 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * i
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('regression: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('regression: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('regression: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('regression: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

prompt:
Population totals exceed the census by exactly the seed count.

Daily forward-Euler SEIR with sigma=1/latent_days and gamma=1/infectious_days; only I transmits (beta*S*I/pop); seeds start in E and are part of pop; return [daily E->I onsets rounded to 4, total population rounded to 4], or None for non-positive durations or population.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * (i + onset)
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(beta, latent_days, infectious_days, pop, e0, days):
    if latent_days <= 0 or infectious_days <= 0 or pop <= 0:
        return None
    sigma = 1.0 / latent_days
    gamma = 1.0 / infectious_days
    s, e, i, r = float(pop - e0), float(e0), 0.0, 0.0
    incidence = []
    for day in range(days):
        exposure = beta * s * i / pop
        onset = sigma * e
        removal = gamma * onset
        s -= exposure
        e += exposure - onset
        i += onset - removal
        r += removal
        incidence.append(round(onset, 4))
    return [incidence, round(s + e + i + r, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None)],
 [('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed', (0.9, 4, 3, 100, 60, 6), [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.0]),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: influenza-like 2 day latency',
   (0.6, 2, 3, 1000, 10, 8),
   [[5.0, 2.5, 2.735, 3.0948, 3.5019, 3.9584, 4.4687, 5.0378], 1000.0]),
  ('regression: measles-like long latency',
   (1.5, 8, 7, 5000, 5, 12),
   [[0.625, 0.5469, 0.5956, 0.7239, 0.9186, 1.1836, 1.5328, 1.9882, 2.5798, 3.3471, 4.3413, 5.6281], 5000.0]),
  ('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('regression: long infectious period',
   (0.3, 5, 14, 2000, 50, 10),
   [[10.0, 8.0, 6.985, 6.5977, 6.6203, 6.9212, 7.4223, 8.0781, 8.8635, 9.7655], 2000.0])],
 [('regression: one-day latency', (0.4, 1, 4, 200, 4, 6), [[4.0, 0.0, 1.568, 1.1666, 1.4758, 1.5459], 200.0]),
  ('control: no transmission',
   (0.0, 3, 5, 100, 20, 6),
   [[6.6667, 4.4444, 2.963, 1.9753, 1.3169, 0.8779], 100.0]),
  ('control: boundary zero days', (0.5, 3, 5, 100, 5, 0), [[], 100.0]),
  ('control: invalid zero latency', (0.5, 0, 5, 100, 5, 5), None),
  ('control: invalid zero population', (0.5, 2, 5, 0, 0, 5), None),
  ('regression: fractional latency',
   (0.8, 1.5, 2.5, 300, 6, 7),
   [[4.0, 1.3333, 2.5351, 2.7755, 3.3698, 3.9741, 4.6871], 300.0]),
  ('regression: large seed',
   (0.9, 4, 3, 100, 60, 6),
   [[15.0, 11.25, 9.7875, 8.9949, 8.2544, 7.4237], 100.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)

prompt:
Newly symptomatic people recover in the same day they become infectious.

Daily forward-Euler SEIR with sigma=1/latent_days and gamma=1/infectious_days; only I transmits (beta*S*I/pop); seeds start in E and are part of pop; return [daily E->I onsets rounded to 4, total population rounded to 4], or None for non-positive durations or population.

split: open-access


broken_source:
"""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 / (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]),
  ('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None)],
 [('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]),
  ('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]),
  ('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: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
  ('regression: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
 [('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]),
  ('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])]]
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)

source:
"""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]),
  ('control: invalid efficacy zero', (1.0, 0.5, 0.2, 0.0, 0.0), None)],
 [('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]),
  ('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]),
  ('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: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
  ('regression: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
 [('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]),
  ('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])]]
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)

prompt:
R0 is overstated for pathogens with long latency in short-lived hosts.

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].

split: open-access


broken_source:
"""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)

source:
"""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)

prompt:
R0 ignores that hosts can die while infectious and is too high with vital dynamics.

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].

split: open-access


broken_source:
"""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))
    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]),
  ('control: 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]),
  ('regression: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
  ('control: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
  ('control: 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]),
  ('regression: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
  ('control: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
  ('control: 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),
  ('control: 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: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
  ('control: 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),
  ('control: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
  ('control: 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]),
  ('control: 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]),
  ('regression: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
  ('control: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
  ('control: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
 [('control: 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]),
  ('regression: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
  ('control: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
  ('control: 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)

source:
"""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, None]
    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]),
  ('control: 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]),
  ('regression: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
  ('control: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
  ('control: 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]),
  ('regression: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
  ('control: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
  ('control: 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),
  ('control: 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: subcritical with mortality', (0.3, 0.2, 0.25, 0.05, 0.9), [0.8, 0.0, 0.0]),
  ('control: 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),
  ('control: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
  ('control: 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]),
  ('control: 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]),
  ('regression: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
  ('control: perfect vaccine', (0.9, 0.25, 0.2, 0.001, 1.0), [4.459773, 0.775773, 0.775773]),
  ('control: long latency high mortality', (2.4, 0.05, 0.3, 0.04, 0.85), [3.921569, 0.745, 0.876471])],
 [('control: 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]),
  ('regression: boundary R0 exactly one', (1.0, 1.0, 1.0, 0.0, 0.8), [1.0, 0.0, 0.0]),
  ('control: infeasible coverage poor vaccine', (1.2, 0.3, 0.2, 0.01, 0.5), [5.529954, 0.819167, None]),
  ('control: 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)

prompt:
Subcritical pathogens report a negative herd-immunity threshold and negative coverage.

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].

split: open-access