broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(lambdas, n0, threshold):
    if not lambdas or min(lambdas) <= 0 or n0 <= 0:
        return None
    logs = [math.log(x) for x in lambdas]
    geo = math.exp(sum(logs) / len(logs))
    arith = sum(lambdas) / len(lambdas)
    n = float(n0)
    traj = []
    hit = None
    for t, lam in enumerate(lambdas, start=1):
        n *= lam
        traj.append(round(n, 4))
        if n < threshold:
            hit = t
    trend = 'declining' if geo < 1 else ('stable' if geo == 1 else 'growing')
    return [round(geo, 6), round(arith, 6), traj, hit, trend]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('control: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('control: balanced doubling halving', ([2.0, 0.5], 100, 10), [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('control: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining'])],
 [('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('control: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('control: high variance decline',
   ([3.0, 0.3, 3.0, 0.3], 100, 5),
   [0.948683, 1.65, [300.0, 90.0, 270.0, 81.0], None, 'declining']),
  ('regression: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining'])],
 [('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('control: high variance decline',
   ([3.0, 0.3, 3.0, 0.3], 100, 5),
   [0.948683, 1.65, [300.0, 90.0, 270.0, 81.0], None, 'declining']),
  ('regression: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining']),
  ('control: slow decline',
   ([0.95, 1.02, 0.9, 1.05, 0.93], 80, 60),
   [0.968384, 0.97, [76.0, 77.52, 69.768, 73.2564, 68.1285], None, 'declining'])],
 [('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('control: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('control: balanced doubling halving', ([2.0, 0.5], 100, 10), [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('regression: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining']),
  ('control: slow decline',
   ([0.95, 1.02, 0.9, 1.05, 0.93], 80, 60),
   [0.968384, 0.97, [76.0, 77.52, 69.768, 73.2564, 68.1285], None, 'declining'])],
 [('control: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('control: balanced doubling halving', ([2.0, 0.5], 100, 10), [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('control: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining'])]]
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(lambdas, n0, threshold):
    if not lambdas or min(lambdas) <= 0 or n0 <= 0:
        return None
    logs = [math.log(x) for x in lambdas]
    geo = math.exp(sum(logs) / len(logs))
    arith = sum(lambdas) / len(lambdas)
    n = float(n0)
    traj = []
    hit = None
    for t, lam in enumerate(lambdas, start=1):
        n *= lam
        traj.append(round(n, 4))
        if hit is None and n < threshold and t > 1:
            hit = t
    trend = 'declining' if geo < 1 else ('stable' if geo == 1 else 'growing')
    return [round(geo, 6), round(arith, 6), traj, hit, trend]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('control: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('control: balanced doubling halving', ([2.0, 0.5], 100, 10), [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('control: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining'])],
 [('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('control: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('control: high variance decline',
   ([3.0, 0.3, 3.0, 0.3], 100, 5),
   [0.948683, 1.65, [300.0, 90.0, 270.0, 81.0], None, 'declining']),
  ('regression: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining'])],
 [('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('control: high variance decline',
   ([3.0, 0.3, 3.0, 0.3], 100, 5),
   [0.948683, 1.65, [300.0, 90.0, 270.0, 81.0], None, 'declining']),
  ('regression: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining']),
  ('control: slow decline',
   ([0.95, 1.02, 0.9, 1.05, 0.93], 80, 60),
   [0.968384, 0.97, [76.0, 77.52, 69.768, 73.2564, 68.1285], None, 'declining'])],
 [('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('control: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('control: balanced doubling halving', ([2.0, 0.5], 100, 10), [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('regression: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining']),
  ('control: slow decline',
   ([0.95, 1.02, 0.9, 1.05, 0.93], 80, 60),
   [0.968384, 0.97, [76.0, 77.52, 69.768, 73.2564, 68.1285], None, 'declining'])],
 [('control: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('control: balanced doubling halving', ([2.0, 0.5], 100, 10), [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('control: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('regression: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('regression: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining'])]]
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:
Quasi-extinction time reports the last dip instead of the first.

Geometric mean growth exp(mean ln lambda) determines trend (declining <1, stable ==1, growing >1); arithmetic mean reported alongside; trajectory multiplies N by each lambda; quasi-extinction time is the first 1-based year with N < threshold or None; return [geo, arith, trajectory, hit, trend]; None for empty, non-positive lambdas or N0<=0.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(lambdas, n0, threshold):
    if not lambdas or min(lambdas) <= 0 or n0 <= 0:
        return None
    logs = [math.log(x) for x in lambdas]
    geo = math.exp(sum(logs) / len(logs))
    arith = sum(lambdas) / len(lambdas)
    n = float(n0)
    traj = []
    hit = None
    for t, lam in enumerate(lambdas, start=1):
        n *= lam
        traj.append(round(n, 4))
        if hit is None and n < threshold:
            hit = t
    trend = 'declining' if geo < 1 else 'growing'
    return [round(geo, 6), round(arith, 6), traj, hit, trend]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('regression: balanced doubling halving',
   ([2.0, 0.5], 100, 10),
   [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('regression: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('control: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None)],
 [('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('regression: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('control: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('control: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('control: high variance decline',
   ([3.0, 0.3, 3.0, 0.3], 100, 5),
   [0.948683, 1.65, [300.0, 90.0, 270.0, 81.0], None, 'declining'])],
 [('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('regression: balanced doubling halving',
   ([2.0, 0.5], 100, 10),
   [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('control: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('control: high variance decline',
   ([3.0, 0.3, 3.0, 0.3], 100, 5),
   [0.948683, 1.65, [300.0, 90.0, 270.0, 81.0], None, 'declining']),
  ('control: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining']),
  ('control: slow decline',
   ([0.95, 1.02, 0.9, 1.05, 0.93], 80, 60),
   [0.968384, 0.97, [76.0, 77.52, 69.768, 73.2564, 68.1285], None, 'declining'])],
 [('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('regression: balanced doubling halving',
   ([2.0, 0.5], 100, 10),
   [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('regression: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('control: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining']),
  ('control: slow decline',
   ([0.95, 1.02, 0.9, 1.05, 0.93], 80, 60),
   [0.968384, 0.97, [76.0, 77.52, 69.768, 73.2564, 68.1285], None, 'declining'])],
 [('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('regression: balanced doubling halving',
   ([2.0, 0.5], 100, 10),
   [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('regression: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('control: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('control: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining'])]]
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(lambdas, n0, threshold):
    if not lambdas or min(lambdas) <= 0 or n0 <= 0:
        return None
    logs = [math.log(x) for x in lambdas]
    geo = math.exp(sum(logs) / len(logs))
    arith = sum(lambdas) / len(lambdas)
    n = float(n0)
    traj = []
    hit = None
    for t, lam in enumerate(lambdas, start=1):
        n *= lam
        traj.append(round(n, 4))
        if hit is None and n < threshold:
            hit = t
    trend = 'declining' if geo < 1 else ('stable' if arith == 1 else 'growing')
    return [round(geo, 6), round(arith, 6), traj, hit, trend]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('regression: balanced doubling halving',
   ([2.0, 0.5], 100, 10),
   [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('regression: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('control: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None)],
 [('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('regression: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('control: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('control: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('control: high variance decline',
   ([3.0, 0.3, 3.0, 0.3], 100, 5),
   [0.948683, 1.65, [300.0, 90.0, 270.0, 81.0], None, 'declining'])],
 [('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('regression: balanced doubling halving',
   ([2.0, 0.5], 100, 10),
   [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('control: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining']),
  ('control: high variance decline',
   ([3.0, 0.3, 3.0, 0.3], 100, 5),
   [0.948683, 1.65, [300.0, 90.0, 270.0, 81.0], None, 'declining']),
  ('control: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining']),
  ('control: slow decline',
   ([0.95, 1.02, 0.9, 1.05, 0.93], 80, 60),
   [0.968384, 0.97, [76.0, 77.52, 69.768, 73.2564, 68.1285], None, 'declining'])],
 [('control: boom and bust',
   ([1.5, 0.5, 1.5, 0.5], 100, 20),
   [0.866025, 1.0, [150.0, 75.0, 112.5, 56.25], None, 'declining']),
  ('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('regression: balanced doubling halving',
   ([2.0, 0.5], 100, 10),
   [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('regression: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('control: fractional dip', ([0.496, 1.2], 100, 50), [0.771492, 0.848, [49.6, 59.52], 1, 'declining']),
  ('control: slow decline',
   ([0.95, 1.02, 0.9, 1.05, 0.93], 80, 60),
   [0.968384, 0.97, [76.0, 77.52, 69.768, 73.2564, 68.1285], None, 'declining'])],
 [('regression: exact halving to threshold',
   ([0.5, 1.0, 2.0], 100, 50),
   [1.0, 1.166667, [50.0, 50.0, 100.0], None, 'stable']),
  ('regression: balanced doubling halving',
   ([2.0, 0.5], 100, 10),
   [1.0, 1.25, [200.0, 100.0], None, 'stable']),
  ('control: steady growth',
   ([1.1, 1.2, 1.05], 50, 10),
   [1.114947, 1.116667, [55.0, 66.0, 69.3], None, 'growing']),
  ('regression: constant', ([1.0, 1.0, 1.0], 30, 5), [1.0, 1.0, [30.0, 30.0, 30.0], None, 'stable']),
  ('control: dip and recovery',
   ([0.4, 0.8, 3.0, 2.0], 100, 50),
   [1.177132, 1.55, [40.0, 32.0, 96.0, 192.0], 1, 'growing']),
  ('control: invalid zero lambda', ([1.0, 0.0], 10, 1), None),
  ('control: first year crash',
   ([0.1, 1.5, 1.5], 100, 20),
   [0.60822, 1.033333, [10.0, 15.0, 22.5], 1, 'declining'])]]
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 population whose long-run growth is exactly one is called growing.

Geometric mean growth exp(mean ln lambda) determines trend (declining <1, stable ==1, growing >1); arithmetic mean reported alongside; trajectory multiplies N by each lambda; quasi-extinction time is the first 1-based year with N < threshold or None; return [geo, arith, trajectory, hit, trend]; None for empty, non-positive lambdas or N0<=0.

split: open-access


prompt:
The sink patch is allowed to fill to the source ceiling.

Each year each patch grows by its lambda and is capped at its own ceiling, then fraction disperse of each post-growth patch moves to the other simultaneously; return yearly [N1, N2] rounded 4.

split: open-access


prompt:
Excess recruits above the ceiling disperse into the other patch.

Each year each patch grows by its lambda and is capped at its own ceiling, then fraction disperse of each post-growth patch moves to the other simultaneously; return yearly [N1, N2] rounded 4.

split: open-access


prompt:
Dispersal creates individuals.

Each year each patch grows by its lambda and is capped at its own ceiling, then fraction disperse of each post-growth patch moves to the other simultaneously; return yearly [N1, N2] rounded 4.

split: open-access


prompt:
Dispersal numbers ignore this year's reproduction.

Each year each patch grows by its lambda and is capped at its own ceiling, then fraction disperse of each post-growth patch moves to the other simultaneously; return yearly [N1, N2] rounded 4.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(c1, c2):
    if c1 < 0 or c2 < 0:
        return None
    if c1 <= c2:
        return [None, None, None]
    n_hat = c1 * c2 / (c1 - c2)
    p_hat = (c1 - c2) / c1
    var = c1 ** 2 * c2 ** 2 * (c1 + c2) / (c1 - c2) ** 4
    return [round(n_hat, 2), round(p_hat, 4), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])]]
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(c1, c2):
    if c1 < 0 or c2 < 0:
        return None
    if c1 <= c2:
        return [None, None, None]
    n_hat = c1 * c1 / (c1 + c2)
    p_hat = (c1 - c2) / c1
    var = c1 ** 2 * c2 ** 2 * (c1 + c2) / (c1 - c2) ** 4
    return [round(n_hat, 2), round(p_hat, 4), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])]]
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:
Abundance is underestimated and becomes zero when the second pass is empty.

N = c1^2/(c1-c2), p = (c1-c2)/c1, var = c1^2*c2^2*(c1+c2)/(c1-c2)^4 rounded [2, 4, 2]; [None, None, None] when c1<=c2; None for negative catches.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(c1, c2):
    if c1 < 0 or c2 < 0:
        return None
    if c1 <= c2:
        return [None, None, None]
    n_hat = c1 * c1 / (c1 - c2)
    p_hat = c2 / c1
    var = c1 ** 2 * c2 ** 2 * (c1 + c2) / (c1 - c2) ** 4
    return [round(n_hat, 2), round(p_hat, 4), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])]]
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(c1, c2):
    if c1 < 0 or c2 < 0:
        return None
    if c1 <= c2:
        return [None, None, None]
    n_hat = c1 * c1 / (c1 - c2)
    p_hat = (c1 - c2) / (c1 + c2)
    var = c1 ** 2 * c2 ** 2 * (c1 + c2) / (c1 - c2) ** 4
    return [round(n_hat, 2), round(p_hat, 4), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('regression: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])]]
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:
Capture probability falls as depletion gets stronger.

N = c1^2/(c1-c2), p = (c1-c2)/c1, var = c1^2*c2^2*(c1+c2)/(c1-c2)^4 rounded [2, 4, 2]; [None, None, None] when c1<=c2; None for negative catches.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(c1, c2):
    if c1 < 0 or c2 < 0:
        return None
    if c1 <= c2:
        return [None, None, None]
    n_hat = c1 * c1 / (c1 - c2)
    p_hat = (c1 - c2) / c1
    var = c1 ** 2 * c2 ** 2 * (c1 + c2) / (c1 - c2) ** 2
    return [round(n_hat, 2), round(p_hat, 4), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])]]
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(c1, c2):
    if c1 < 0 or c2 < 0:
        return None
    if c1 <= c2:
        return [None, None, None]
    n_hat = c1 * c1 / (c1 - c2)
    p_hat = (c1 - c2) / c1
    var = c1 ** 2 * c2 ** 2 * (c1 + c2) / (c1 - c2) ** 3
    return [round(n_hat, 2), round(p_hat, 4), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('regression: efficient first pass', (90, 10), [101.25, 0.8889, 1.98]),
  ('regression: weak depletion', (40, 32), [200.0, 0.2, 28800.0]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None])],
 [('regression: stream electrofishing', (60, 25), [102.86, 0.5833, 127.45]),
  ('control: no depletion', (30, 30), [None, None, None]),
  ('control: second pass empty', (45, 0), [45.0, 1.0, 0.0]),
  ('control: negative catch', (-1, 3), None),
  ('control: increasing catch', (20, 25), [None, None, None]),
  ('regression: small stream', (12, 5), [20.57, 0.5833, 25.49]),
  ('regression: large lake', (300, 140), [562.5, 0.5333, 1184.33])]]
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:
Variance estimates explode for strongly depleted streams.

N = c1^2/(c1-c2), p = (c1-c2)/c1, var = c1^2*c2^2*(c1+c2)/(c1-c2)^4 rounded [2, 4, 2]; [None, None, None] when c1<=c2; None for negative catches.

split: open-access


prompt:
Oscillations are weaker than the stated delay produces.

hist[0]=N0; N[t+1] = max(0, N[t] + r*N[t]*(1 - N[t-lag]/K)) where values before time 0 equal N0; return [history rounded 4, overshoot max(0, max(history)-K) rounded 4].

split: open-access


prompt:
Early growth explodes because the population is assumed absent before time 0.

hist[0]=N0; N[t+1] = max(0, N[t] + r*N[t]*(1 - N[t-lag]/K)) where values before time 0 equal N0; return [history rounded 4, overshoot max(0, max(history)-K) rounded 4].

split: open-access


prompt:
Recruitment tracks the lagged population instead of current breeders.

hist[0]=N0; N[t+1] = max(0, N[t] + r*N[t]*(1 - N[t-lag]/K)) where values before time 0 equal N0; return [history rounded 4, overshoot max(0, max(history)-K) rounded 4].

split: open-access


prompt:
Overshoot is measured from the initial density instead of carrying capacity.

hist[0]=N0; N[t+1] = max(0, N[t] + r*N[t]*(1 - N[t-lag]/K)) where values before time 0 equal N0; return [history rounded 4, overshoot max(0, max(history)-K) rounded 4].

split: open-access


prompt:
Remote islands receive more immigrants than near ones.

I0 = imax*exp(-distance/d0); E0 = emax*a0/area; S* = I0*P/(I0+E0); turnover = I0*E0/(I0+E0); return [S*, turnover, I0, E0] rounded 4; None for non-positive parameters or negative distance.

split: open-access


prompt:
Large islands lose species faster than small ones.

I0 = imax*exp(-distance/d0); E0 = emax*a0/area; S* = I0*P/(I0+E0); turnover = I0*E0/(I0+E0); return [S*, turnover, I0, E0] rounded 4; None for non-positive parameters or negative distance.

split: open-access


prompt:
Predicted richness can exceed the mainland pool.

I0 = imax*exp(-distance/d0); E0 = emax*a0/area; S* = I0*P/(I0+E0); turnover = I0*E0/(I0+E0); return [S*, turnover, I0, E0] rounded 4; None for non-positive parameters or negative distance.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(n0, monthly_survival, fecundity, breed_start, breed_end, start_month, months, cap):
    n = float(n0)
    traj = []
    for t in range(months):
        month = (start_month + t) % 12
        if breed_start <= breed_end:
            breeding = breed_start <= month <= breed_end
        else:
            breeding = month >= breed_start or month <= breed_end
        n *= monthly_survival
        if breeding:
            n += fecundity * n * max(0.0, 1 - n / cap)
        traj.append(round(n, 4))
    return traj
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: southern winter breeding wraps',
   (50, 0.95, 0.3, 11, 2, 10, 6, 300),
   [47.5, 56.6262, 67.0395, 78.7377, 91.6459, 87.0636]),
  ('regression: december start', (80, 0.98, 0.25, 12, 1, 12, 3, 500), [94.9267, 111.9581, 109.7189]),
  ('regression: single month window end', (60, 0.9, 0.5, 4, 4, 3, 3, 200), [54.0, 66.9951, 60.2956]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407])],
 [('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: single month window end', (60, 0.9, 0.5, 4, 4, 3, 3, 200), [54.0, 66.9951, 60.2956]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: full year',
   (30, 0.96, 0.2, 3, 5, 1, 12, 100),
   [28.8, 27.648, 30.4415, 33.3606, 36.38, 34.9248, 33.5278, 32.1867, 30.8993, 29.6633, 28.4768, 27.3377]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407]),
  ('regression: start inside wrap',
   (70, 0.93, 0.35, 10, 3, 1, 4, 250),
   [81.9518, 94.7582, 108.0965, 100.5297])],
 [('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: southern winter breeding wraps',
   (50, 0.95, 0.3, 11, 2, 10, 6, 300),
   [47.5, 56.6262, 67.0395, 78.7377, 91.6459, 87.0636]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: full year',
   (30, 0.96, 0.2, 3, 5, 1, 12, 100),
   [28.8, 27.648, 30.4415, 33.3606, 36.38, 34.9248, 33.5278, 32.1867, 30.8993, 29.6633, 28.4768, 27.3377]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407]),
  ('regression: start inside wrap',
   (70, 0.93, 0.35, 10, 3, 1, 4, 250),
   [81.9518, 94.7582, 108.0965, 100.5297])],
 [('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: southern winter breeding wraps',
   (50, 0.95, 0.3, 11, 2, 10, 6, 300),
   [47.5, 56.6262, 67.0395, 78.7377, 91.6459, 87.0636]),
  ('regression: december start', (80, 0.98, 0.25, 12, 1, 12, 3, 500), [94.9267, 111.9581, 109.7189]),
  ('regression: single month window end', (60, 0.9, 0.5, 4, 4, 3, 3, 200), [54.0, 66.9951, 60.2956]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407])],
 [('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: single month window end', (60, 0.9, 0.5, 4, 4, 3, 3, 200), [54.0, 66.9951, 60.2956]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: full year',
   (30, 0.96, 0.2, 3, 5, 1, 12, 100),
   [28.8, 27.648, 30.4415, 33.3606, 36.38, 34.9248, 33.5278, 32.1867, 30.8993, 29.6633, 28.4768, 27.3377]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407]),
  ('regression: start inside wrap',
   (70, 0.93, 0.35, 10, 3, 1, 4, 250),
   [81.9518, 94.7582, 108.0965, 100.5297])]]
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(n0, monthly_survival, fecundity, breed_start, breed_end, start_month, months, cap):
    n = float(n0)
    traj = []
    for t in range(months):
        month = (start_month + t - 1) % 12
        if breed_start <= breed_end:
            breeding = breed_start <= month <= breed_end
        else:
            breeding = month >= breed_start or month <= breed_end
        n *= monthly_survival
        if breeding:
            n += fecundity * n * max(0.0, 1 - n / cap)
        traj.append(round(n, 4))
    return traj
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: southern winter breeding wraps',
   (50, 0.95, 0.3, 11, 2, 10, 6, 300),
   [47.5, 56.6262, 67.0395, 78.7377, 91.6459, 87.0636]),
  ('regression: december start', (80, 0.98, 0.25, 12, 1, 12, 3, 500), [94.9267, 111.9581, 109.7189]),
  ('regression: single month window end', (60, 0.9, 0.5, 4, 4, 3, 3, 200), [54.0, 66.9951, 60.2956]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407])],
 [('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: single month window end', (60, 0.9, 0.5, 4, 4, 3, 3, 200), [54.0, 66.9951, 60.2956]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: full year',
   (30, 0.96, 0.2, 3, 5, 1, 12, 100),
   [28.8, 27.648, 30.4415, 33.3606, 36.38, 34.9248, 33.5278, 32.1867, 30.8993, 29.6633, 28.4768, 27.3377]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407]),
  ('regression: start inside wrap',
   (70, 0.93, 0.35, 10, 3, 1, 4, 250),
   [81.9518, 94.7582, 108.0965, 100.5297])],
 [('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: southern winter breeding wraps',
   (50, 0.95, 0.3, 11, 2, 10, 6, 300),
   [47.5, 56.6262, 67.0395, 78.7377, 91.6459, 87.0636]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: full year',
   (30, 0.96, 0.2, 3, 5, 1, 12, 100),
   [28.8, 27.648, 30.4415, 33.3606, 36.38, 34.9248, 33.5278, 32.1867, 30.8993, 29.6633, 28.4768, 27.3377]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407]),
  ('regression: start inside wrap',
   (70, 0.93, 0.35, 10, 3, 1, 4, 250),
   [81.9518, 94.7582, 108.0965, 100.5297])],
 [('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: southern winter breeding wraps',
   (50, 0.95, 0.3, 11, 2, 10, 6, 300),
   [47.5, 56.6262, 67.0395, 78.7377, 91.6459, 87.0636]),
  ('regression: december start', (80, 0.98, 0.25, 12, 1, 12, 3, 500), [94.9267, 111.9581, 109.7189]),
  ('regression: single month window end', (60, 0.9, 0.5, 4, 4, 3, 3, 200), [54.0, 66.9951, 60.2956]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407])],
 [('regression: deer spring births',
   (100, 0.97, 0.4, 5, 6, 3, 6, 400),
   [97.0, 94.09, 119.4445, 148.7818, 144.3184, 139.9888]),
  ('regression: single month window end', (60, 0.9, 0.5, 4, 4, 3, 3, 200), [54.0, 66.9951, 60.2956]),
  ('control: above cap no births', (500, 0.99, 0.3, 1, 12, 1, 3, 400), [495.0, 490.05, 485.1495]),
  ('control: no breeding months reached', (40, 0.95, 0.3, 8, 9, 1, 4, 200), [38.0, 36.1, 34.295, 32.5802]),
  ('regression: full year',
   (30, 0.96, 0.2, 3, 5, 1, 12, 100),
   [28.8, 27.648, 30.4415, 33.3606, 36.38, 34.9248, 33.5278, 32.1867, 30.8993, 29.6633, 28.4768, 27.3377]),
  ('regression: late-autumn window through december',
   (80, 0.98, 0.3, 11, 12, 10, 4, 500),
   [78.4, 96.3397, 117.3885, 115.0407]),
  ('regression: start inside wrap',
   (70, 0.93, 0.35, 10, 3, 1, 4, 250),
   [81.9518, 94.7582, 108.0965, 100.5297])]]
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:
December is treated as month 0 and every month is shifted.

Calendar month of step t is ((start_month-1+t) mod 12)+1; the breeding window is inclusive and may wrap across the new year (start > end); each month survival is applied first, then in breeding months births fecundity*N*max(0,1-N/cap); return monthly N rounded 4.

split: open-access


prompt:
Breeding seasons that span the new year never occur.

Calendar month of step t is ((start_month-1+t) mod 12)+1; the breeding window is inclusive and may wrap across the new year (start > end); each month survival is applied first, then in breeding months births fecundity*N*max(0,1-N/cap); return monthly N rounded 4.

split: open-access


prompt:
The last breeding month produces no births.

Calendar month of step t is ((start_month-1+t) mod 12)+1; the breeding window is inclusive and may wrap across the new year (start > end); each month survival is applied first, then in breeding months births fecundity*N*max(0,1-N/cap); return monthly N rounded 4.

split: open-access


prompt:
Newborns are subjected to the month's mortality.

Calendar month of step t is ((start_month-1+t) mod 12)+1; the breeding window is inclusive and may wrap across the new year (start > end); each month survival is applied first, then in breeding months births fecundity*N*max(0,1-N/cap); return monthly N rounded 4.

split: open-access


prompt:
Populations above the cap lose animals through negative births.

Calendar month of step t is ((start_month-1+t) mod 12)+1; the breeding window is inclusive and may wrap across the new year (start > end); each month survival is applied first, then in breeding months births fecundity*N*max(0,1-N/cap); return monthly N rounded 4.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * e)
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * h * ns)
    hump = (k - 1 / (a * h)) / 2 if h > 0 else -1.0
    if ns > hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('regression: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('regression: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('regression: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('regression: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])]]
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(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (e - h * m)
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * h * ns)
    hump = (k - 1 / (a * h)) / 2 if h > 0 else -1.0
    if ns > hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('regression: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('regression: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('regression: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('regression: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])]]
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 prey equilibrium ignores handling time.

Type II predator-prey: N* = m/(a(e-hm)) requires e>hm and N*<K else ['predator-extinct', [K, 0]]; P* = (r/a)(1-N*/K)(1+ahN*); hump = (K-1/(ah))/2 for h>0 else -1; stable if N*>hump, 'hopf' if equal, else 'cycles'; values rounded 6; None for invalid parameters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * (e - h * m))
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * h * ns)
    hump = (k - 1 / (a * h)) / 2 if h > 0 else -1.0
    if ns > hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])]]
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(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e * a <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * (e - h * m))
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * h * ns)
    hump = (k - 1 / (a * h)) / 2 if h > 0 else -1.0
    if ns > hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])]]
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:
Predators that cannot convert prey fast enough are reported as persisting, or vice versa.

Type II predator-prey: N* = m/(a(e-hm)) requires e>hm and N*<K else ['predator-extinct', [K, 0]]; P* = (r/a)(1-N*/K)(1+ahN*); hump = (K-1/(ah))/2 for h>0 else -1; stable if N*>hump, 'hopf' if equal, else 'cycles'; values rounded 6; None for invalid parameters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * (e - h * m))
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + h * ns)
    hump = (k - 1 / (a * h)) / 2 if h > 0 else -1.0
    if ns > hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])]]
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(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * (e - h * m))
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * ns)
    hump = (k - 1 / (a * h)) / 2 if h > 0 else -1.0
    if ns > hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('regression: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]])]]
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:
Predator equilibrium is understated for slow handlers.

Type II predator-prey: N* = m/(a(e-hm)) requires e>hm and N*<K else ['predator-extinct', [K, 0]]; P* = (r/a)(1-N*/K)(1+ahN*); hump = (K-1/(ah))/2 for h>0 else -1; stable if N*>hump, 'hopf' if equal, else 'cycles'; values rounded 6; None for invalid parameters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * (e - h * m))
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * h * ns)
    hump = (k - 1 / (a * h)) if h > 0 else -1.0
    if ns > hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None)],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]])]]
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(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * (e - h * m))
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * h * ns)
    hump = k / 2 if h > 0 else -1.0
    if ns > hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None)],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('regression: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('regression: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]])]]
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 enrichment threshold is placed at twice its true density.

Type II predator-prey: N* = m/(a(e-hm)) requires e>hm and N*<K else ['predator-extinct', [K, 0]]; P* = (r/a)(1-N*/K)(1+ahN*); hump = (K-1/(ah))/2 for h>0 else -1; stable if N*>hump, 'hopf' if equal, else 'cycles'; values rounded 6; None for invalid parameters.

split: open-access