FA-65211 / Epidemic compartment models / Open access
Hospital occupancy from delayed admissions: rounding stage · case 01
Fractional admissions round to zero and small waves report empty wards.
ROOT CAUSE
Admissions are rounded to whole patients before summation.
VERIFIED REPAIR
Restore the rounding stage rule: `occ.append(round(sum(adm[lo:t + 1]), 4))`.
Unsuccessful approach: Rounding occupancy to integers breaks the 4-decimal contract.
Case contract
admissions[t] = hosp_frac*infections[t-delay] (0 before the delay); each admission occupies a bed on days t..t+los-1; return [admissions rounded 4, occupancy rounded 4, earliest peak day].
Why this case matters
Compartmental epidemic calculations drive outbreak forecasts, vaccine targets and hospital planning; a single wrong flow, rate conversion or boundary silently changes every downstream number.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(infections, hosp_frac, delay, los):
n = len(infections)
adm = [hosp_frac * infections[t - delay] if t - delay >= 0 else 0.0 for t in range(n)]
occ = []
for t in range(n):
lo = max(0, t - los + 1)
occ.append(round(sum(round(a) for a in adm[lo:t + 1]), 4))
peak = max(range(n), key=lambda t: (occ[t], -t)) if n else None
return [[round(a, 4) for a in adm], occ, peak]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: wave with 3 day delay | [[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0, 0, 0, 1, 3, 7, 13, 17, 18], 8] | [[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8] | Passed |
| control: no delay one day stay | [[1.0, 2.0, 3.0, 2.0, 1.0], [1, 2, 3, 2, 1], 2] | [[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2] | Passed |
| regression: plateau tie | [[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0, 0, 0, 0, 0, 0, 0], 0] | [[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3] | Failed |
| regression: long stay | [[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0, 0, 3, 5, 7, 8, 9, 9], 6] | [[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7] | Failed |
| control: delay beyond series | [[0.0, 0.0, 0.0], [0, 0, 0], 0] | [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0] | Passed |
| control: empty series | [[], [], None] | [[], [], None] | Passed |
| control: twin peaks | [[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0, 0, 3, 3, 0, 3, 3, 0], 2] | [[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2] | Passed |
SHA-256 / 5ccdff955be8b9068fae3722b3d271afa92fc7df4aa51acb4cb394abbf248552
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(infections, hosp_frac, delay, los):
n = len(infections)
adm = [hosp_frac * infections[t - delay] if t - delay >= 0 else 0.0 for t in range(n)]
occ = []
for t in range(n):
lo = max(0, t - los + 1)
occ.append(round(sum(adm[lo:t + 1])))
peak = max(range(n), key=lambda t: (occ[t], -t)) if n else None
return [[round(a, 4) for a in adm], occ, peak]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: wave with 3 day delay | [[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0, 0, 0, 1, 3, 7, 13, 17, 18], 8] | [[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8] | Passed |
| control: no delay one day stay | [[1.0, 2.0, 3.0, 2.0, 1.0], [1, 2, 3, 2, 1], 2] | [[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2] | Passed |
| regression: plateau tie | [[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0, 0, 1, 2, 2, 2, 2], 3] | [[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3] | Failed |
| regression: long stay | [[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0, 0, 3, 5, 7, 8, 9, 9], 6] | [[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7] | Failed |
| control: delay beyond series | [[0.0, 0.0, 0.0], [0, 0, 0], 0] | [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0] | Passed |
| control: empty series | [[], [], None] | [[], [], None] | Passed |
| control: twin peaks | [[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0, 0, 3, 3, 0, 3, 3, 0], 2] | [[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2] | Passed |
SHA-256 / bebd322ffc0c0c0b1659e150c00c9cae13151e5bc3e5a9347a12e8cd6ac102f8
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(infections, hosp_frac, delay, los):
n = len(infections)
adm = [hosp_frac * infections[t - delay] if t - delay >= 0 else 0.0 for t in range(n)]
occ = []
for t in range(n):
lo = max(0, t - los + 1)
occ.append(round(sum(adm[lo:t + 1]), 4))
peak = max(range(n), key=lambda t: (occ[t], -t)) if n else None
return [[round(a, 4) for a in adm], occ, peak]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('control: no delay one day stay',
([5, 10, 15, 10, 5], 0.2, 0, 1),
[[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2]),
('regression: plateau tie',
([10, 10, 10, 10, 10, 10, 10], 0.05, 1, 3),
[[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2])],
[('control: wave with 3 day delay',
([10, 20, 40, 60, 50, 30, 20, 10, 5], 0.1, 3, 4),
[[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8]),
('regression: long stay',
([100, 80, 60, 40, 20, 10, 5, 0], 0.03, 2, 6),
[[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7]),
('control: delay beyond series', ([1, 2, 3], 0.5, 5, 2), [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0]),
('control: empty series', ([], 0.1, 1, 3), [[], [], None]),
('control: twin peaks',
([0, 30, 0, 0, 30, 0, 0, 0], 0.1, 1, 2),
[[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2]),
('regression: rising',
([1, 3, 7, 12, 20, 33], 0.08, 2, 5),
[[0.0, 0.0, 0.08, 0.24, 0.56, 0.96], [0.0, 0.0, 0.08, 0.32, 0.88, 1.84], 5]),
('regression: near-tie peaks',
([10, 12, 10, 0, 11.8, 12.1, 0, 0], 0.5, 0, 1),
[[5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], [5.0, 6.0, 5.0, 0.0, 5.9, 6.05, 0.0, 0.0], 5])]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control: wave with 3 day delay | [[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8] | [[0.0, 0.0, 0.0, 1.0, 2.0, 4.0, 6.0, 5.0, 3.0], [0.0, 0.0, 0.0, 1.0, 3.0, 7.0, 13.0, 17.0, 18.0], 8] | Passed |
| control: no delay one day stay | [[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2] | [[1.0, 2.0, 3.0, 2.0, 1.0], [1.0, 2.0, 3.0, 2.0, 1.0], 2] | Passed |
| regression: plateau tie | [[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3] | [[0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5], [0.0, 0.5, 1.0, 1.5, 1.5, 1.5, 1.5], 3] | Passed |
| regression: long stay | [[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7] | [[0.0, 0.0, 3.0, 2.4, 1.8, 1.2, 0.6, 0.3], [0.0, 0.0, 3.0, 5.4, 7.2, 8.4, 9.0, 9.3], 7] | Passed |
| control: delay beyond series | [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0] | [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 0] | Passed |
| control: empty series | [[], [], None] | [[], [], None] | Passed |
| control: twin peaks | [[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2] | [[0.0, 0.0, 3.0, 0.0, 0.0, 3.0, 0.0, 0.0], [0.0, 0.0, 3.0, 3.0, 0.0, 3.0, 3.0, 0.0], 2] | Passed |
SHA-256 / ea52b889780290fb0a15bfb36d753f35c1fb232ab07ed690f18c00da09f4765b
Verification & scope
Deterministic bounded teaching model with a stipulated contract; not a validated scientific or public-health modelling library. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:47:31.985058+00:00.
Case digest / 990792e52e7d8d20600a5cbf3abc8795a660599d1eba9e15024a96a1ae0787c9