FAILURE MAP
← Case archive

FA-65006 / Epidemic compartment models / Open access

Two-group next-generation matrix R0: infector infectious period · case 01

R0 is wrong whenever the groups recover at different rates.

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

ROOT CAUSE

The infectious period of the infectee group is used instead of that of the infector.

VERIFIED REPAIR

Restore the infector infectious period rule: `/ gamma[j] for j`.

Unsuccessful approach: Averaging the two recovery rates erases the group difference.

Case contract

K[i][j] = contact[i][j]*sizes[i]/sum(sizes)/gamma[j] (infections in group i caused by one infective in j); R0 is the dominant eigenvalue of the 2x2 K; lead group is the larger component of its eigenvector (ties and decoupled ties to group 0); return [flattened K rounded 6, R0 rounded 6, lead] or None for empty population or non-positive gamma.

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(contact, sizes, gamma):
    total = sum(sizes)
    if total <= 0 or min(gamma) <= 0:
        return None
    k = [[contact[i][j] * sizes[i] / total / gamma[i] for j in range(2)] for i in range(2)]
    tr = k[0][0] + k[1][1]
    det = k[0][0] * k[1][1] - k[0][1] * k[1][0]
    disc = max(tr * tr - 4 * det, 0.0)
    r0 = (tr + math.sqrt(disc)) / 2
    if abs(k[0][1]) > 1e-12:
        v = [k[0][1], r0 - k[0][0]]
    elif abs(k[1][0]) > 1e-12:
        v = [r0 - k[1][1], k[1][0]]
    else:
        v = [1.0, 0.0] if k[0][0] >= k[1][1] else [0.0, 1.0]
    lead = 0 if abs(v[0]) >= abs(v[1]) else 1
    return [[round(x, 6) for row in k for x in row], round(r0, 6), lead]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None)],
 [('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None),
  ('control: homogeneous mixing',
   ([[1.2, 1.2], [1.2, 1.2]], [250, 750], [0.4, 0.4]),
   [[0.75, 0.75, 2.25, 2.25], 3.0, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0])],
 [('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None),
  ('control: homogeneous mixing',
   ([[1.2, 1.2], [1.2, 1.2]], [250, 750], [0.4, 0.4]),
   [[0.75, 0.75, 2.25, 2.25], 3.0, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0]),
  ('regression: only cross contacts',
   ([[0.0, 2.0], [1.0, 0.0]], [300, 300], [0.25, 0.5]),
   [[0.0, 2.0, 2.0, 0.0], 2.0, 0])],
 [('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0]),
  ('regression: only cross contacts',
   ([[0.0, 2.0], [1.0, 0.0]], [300, 300], [0.25, 0.5]),
   [[0.0, 2.0, 2.0, 0.0], 2.0, 0])],
 [('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None)]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: children and adults[[2.4, 0.6, 1.75, 3.5], 4.11297, 1][[2.4, 0.75, 1.4, 3.5], 4.11297, 1]Failed
regression: asymmetric core group[[1.333333, 0.066667, 4.5, 1.35], 1.889453, 1][[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]Failed
control: decoupled equal groups tie[[1.0, 0.0, 0.0, 1.0], 1.0, 0][[1.0, 0.0, 0.0, 1.0], 1.0, 0]Passed
control: decoupled first dominant smaller group[[1.8, 0.0, 0.0, 0.7], 1.8, 0][[1.8, 0.0, 0.0, 0.7], 1.8, 0]Passed
control: decoupled second dominant[[0.4, 0.0, 0.0, 3.6], 3.6, 1][[0.4, 0.0, 0.0, 3.6], 3.6, 1]Passed
regression: one-way coupling[[1.0, 0.0, 4.0, 3.0], 3.0, 1][[1.0, 0.0, 8.0, 3.0], 3.0, 1]Failed
control: empty populationNoneNonePassed

SHA-256 / 7c2636197f87be2db1d034decec32cd29cd434912e0963c161cd55200e5ced45

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(contact, sizes, gamma):
    total = sum(sizes)
    if total <= 0 or min(gamma) <= 0:
        return None
    k = [[contact[i][j] * sizes[i] / total / ((gamma[0] + gamma[1]) / 2) for j in range(2)] for i in range(2)]
    tr = k[0][0] + k[1][1]
    det = k[0][0] * k[1][1] - k[0][1] * k[1][0]
    disc = max(tr * tr - 4 * det, 0.0)
    r0 = (tr + math.sqrt(disc)) / 2
    if abs(k[0][1]) > 1e-12:
        v = [k[0][1], r0 - k[0][0]]
    elif abs(k[1][0]) > 1e-12:
        v = [r0 - k[1][1], k[1][0]]
    else:
        v = [1.0, 0.0] if k[0][0] >= k[1][1] else [0.0, 1.0]
    lead = 0 if abs(v[0]) >= abs(v[1]) else 1
    return [[round(x, 6) for row in k for x in row], round(r0, 6), lead]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None)],
 [('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None),
  ('control: homogeneous mixing',
   ([[1.2, 1.2], [1.2, 1.2]], [250, 750], [0.4, 0.4]),
   [[0.75, 0.75, 2.25, 2.25], 3.0, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0])],
 [('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None),
  ('control: homogeneous mixing',
   ([[1.2, 1.2], [1.2, 1.2]], [250, 750], [0.4, 0.4]),
   [[0.75, 0.75, 2.25, 2.25], 3.0, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0]),
  ('regression: only cross contacts',
   ([[0.0, 2.0], [1.0, 0.0]], [300, 300], [0.25, 0.5]),
   [[0.0, 2.0, 2.0, 0.0], 2.0, 0])],
 [('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0]),
  ('regression: only cross contacts',
   ([[0.0, 2.0], [1.0, 0.0]], [300, 300], [0.25, 0.5]),
   [[0.0, 2.0, 2.0, 0.0], 2.0, 0])],
 [('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None)]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: children and adults[[2.666667, 0.666667, 1.555556, 3.111111], 3.931204, 1][[2.4, 0.75, 1.4, 3.5], 4.11297, 1]Failed
regression: asymmetric core group[[1.6, 0.08, 3.6, 1.08], 1.936322, 1][[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]Failed
control: decoupled equal groups tie[[1.0, 0.0, 0.0, 1.0], 1.0, 0][[1.0, 0.0, 0.0, 1.0], 1.0, 0]Passed
control: decoupled first dominant smaller group[[1.8, 0.0, 0.0, 0.7], 1.8, 0][[1.8, 0.0, 0.0, 0.7], 1.8, 0]Passed
control: decoupled second dominant[[0.4, 0.0, 0.0, 3.6], 3.6, 1][[0.4, 0.0, 0.0, 3.6], 3.6, 1]Passed
regression: one-way coupling[[0.666667, 0.0, 5.333333, 4.0], 4.0, 1][[1.0, 0.0, 8.0, 3.0], 3.0, 1]Failed
control: empty populationNoneNonePassed

SHA-256 / be491ae6746ddca10c5ddee220f25d1f83dd1bc32a1ab08277eb82254effd4c6

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(contact, sizes, gamma):
    total = sum(sizes)
    if total <= 0 or min(gamma) <= 0:
        return None
    k = [[contact[i][j] * sizes[i] / total / gamma[j] for j in range(2)] for i in range(2)]
    tr = k[0][0] + k[1][1]
    det = k[0][0] * k[1][1] - k[0][1] * k[1][0]
    disc = max(tr * tr - 4 * det, 0.0)
    r0 = (tr + math.sqrt(disc)) / 2
    if abs(k[0][1]) > 1e-12:
        v = [k[0][1], r0 - k[0][0]]
    elif abs(k[1][0]) > 1e-12:
        v = [r0 - k[1][1], k[1][0]]
    else:
        v = [1.0, 0.0] if k[0][0] >= k[1][1] else [0.0, 1.0]
    lead = 0 if abs(v[0]) >= abs(v[1]) else 1
    return [[round(x, 6) for row in k for x in row], round(r0, 6), lead]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None)],
 [('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None),
  ('control: homogeneous mixing',
   ([[1.2, 1.2], [1.2, 1.2]], [250, 750], [0.4, 0.4]),
   [[0.75, 0.75, 2.25, 2.25], 3.0, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0])],
 [('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None),
  ('control: homogeneous mixing',
   ([[1.2, 1.2], [1.2, 1.2]], [250, 750], [0.4, 0.4]),
   [[0.75, 0.75, 2.25, 2.25], 3.0, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0]),
  ('regression: only cross contacts',
   ([[0.0, 2.0], [1.0, 0.0]], [300, 300], [0.25, 0.5]),
   [[0.0, 2.0, 2.0, 0.0], 2.0, 0])],
 [('regression: children and adults',
   ([[2.0, 0.5], [0.5, 1.0]], [300, 700], [0.25, 0.2]),
   [[2.4, 0.75, 1.4, 3.5], 4.11297, 1]),
  ('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: unequal recovery',
   ([[0.8, 0.6], [0.3, 0.9]], [600, 400], [0.1, 0.5]),
   [[4.8, 0.72, 1.2, 0.72], 5.001785, 0]),
  ('regression: only cross contacts',
   ([[0.0, 2.0], [1.0, 0.0]], [300, 300], [0.25, 0.5]),
   [[0.0, 2.0, 2.0, 0.0], 2.0, 0])],
 [('regression: asymmetric core group',
   ([[4.0, 0.2], [1.0, 0.3]], [100, 900], [0.3, 0.2]),
   [[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]),
  ('control: decoupled equal groups tie',
   ([[1.0, 0.0], [0.0, 1.0]], [500, 500], [0.5, 0.5]),
   [[1.0, 0.0, 0.0, 1.0], 1.0, 0]),
  ('control: decoupled first dominant smaller group',
   ([[3.0, 0.0], [0.0, 0.5]], [300, 700], [0.5, 0.5]),
   [[1.8, 0.0, 0.0, 0.7], 1.8, 0]),
  ('control: decoupled second dominant',
   ([[0.5, 0.0], [0.0, 3.0]], [400, 600], [0.5, 0.5]),
   [[0.4, 0.0, 0.0, 3.6], 3.6, 1]),
  ('regression: one-way coupling',
   ([[1.0, 0.0], [2.0, 1.5]], [200, 800], [0.2, 0.4]),
   [[1.0, 0.0, 8.0, 3.0], 3.0, 1]),
  ('control: empty population', ([[1.0, 1.0], [1.0, 1.0]], [0, 0], [0.2, 0.2]), None),
  ('control: invalid gamma', ([[1.0, 1.0], [1.0, 1.0]], [10, 10], [0.0, 0.2]), None)]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: children and adults[[2.4, 0.75, 1.4, 3.5], 4.11297, 1][[2.4, 0.75, 1.4, 3.5], 4.11297, 1]Passed
regression: asymmetric core group[[1.333333, 0.1, 3.0, 1.35], 1.889453, 1][[1.333333, 0.1, 3.0, 1.35], 1.889453, 1]Passed
control: decoupled equal groups tie[[1.0, 0.0, 0.0, 1.0], 1.0, 0][[1.0, 0.0, 0.0, 1.0], 1.0, 0]Passed
control: decoupled first dominant smaller group[[1.8, 0.0, 0.0, 0.7], 1.8, 0][[1.8, 0.0, 0.0, 0.7], 1.8, 0]Passed
control: decoupled second dominant[[0.4, 0.0, 0.0, 3.6], 3.6, 1][[0.4, 0.0, 0.0, 3.6], 3.6, 1]Passed
regression: one-way coupling[[1.0, 0.0, 8.0, 3.0], 3.0, 1][[1.0, 0.0, 8.0, 3.0], 3.0, 1]Passed
control: empty populationNoneNonePassed

SHA-256 / 0e516881940d9fa795dfbea113b15f6e1b8d49cd0ce652b19e9bb76e118e9ed6

Verification & scope

Deterministic bounded teaching model with a stipulated contract; not a validated scientific or public-health modelling library. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:47:30.084310+00:00.

Case digest / 91a3fcc8ae8ff4020617349e0867dc3073dec7d330bb300492f350efe5e64de8