FAILURE MAP
← Case archive

FA-65811 / Ecological population dynamics / Open access

Rosenzweig-MacArthur equilibrium and enrichment stability: Hopf boundary · case 01

The exact Hopf bifurcation point is labelled stable.

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

ROOT CAUSE

The stability test includes equality.

VERIFIED REPAIR

Restore the Hopf boundary rule: `if ns > hump:`.

Unsuccessful approach: Rounding before comparing misclassifies points just above the hump.

Case contract

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.

Why this case matters

Population projections set harvest quotas, conservation status and pest-control timing; a wrong update order, boundary or rate conversion silently changes management advice.

1 / The failure

Exit 1
"""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)) / 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]]),
  ('control: 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: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('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),
  ('control: 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]]),
  ('control: 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: 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]]),
  ('control: 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]])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: exact hopf point['stable', [4.0, 1.8]]['hopf', [4.0, 1.8]]Failed
control: enriched cycles['cycles', [4.0, 2.7]]['cycles', [4.0, 2.7]]Passed
control: poor habitat stable['stable', [4.0, 1.5]]['stable', [4.0, 1.5]]Passed
control: just above hump['cycles', [4.0, 1.807157]]['cycles', [4.0, 1.807157]]Passed
regression: just below enrichment threshold['stable', [4.0, 1.792757]]['stable', [4.0, 1.792757]]Passed
control: inefficient predator['predator-extinct', [50.0, 0.0]]['predator-extinct', [50.0, 0.0]]Passed
control: predator cannot persist capacity['predator-extinct', [3.0, 0.0]]['predator-extinct', [3.0, 0.0]]Passed

SHA-256 / 6c2d22e5a98753b6a9bddc2dcc847d9269946b058e2f03a5caa9bf163706f986

2 / The unsuccessful fix

Exit 1
"""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)) / 2 if h > 0 else -1.0
    if round(ns, 1) > round(hump, 1):
        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]]),
  ('control: 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: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('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),
  ('control: 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]]),
  ('control: 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: 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]]),
  ('control: 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]])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: exact hopf point['hopf', [4.0, 1.8]]['hopf', [4.0, 1.8]]Passed
control: enriched cycles['cycles', [4.0, 2.7]]['cycles', [4.0, 2.7]]Passed
control: poor habitat stable['stable', [4.0, 1.5]]['stable', [4.0, 1.5]]Passed
control: just above hump['cycles', [4.0, 1.807157]]['cycles', [4.0, 1.807157]]Passed
regression: just below enrichment threshold['cycles', [4.0, 1.792757]]['stable', [4.0, 1.792757]]Failed
control: inefficient predator['predator-extinct', [50.0, 0.0]]['predator-extinct', [50.0, 0.0]]Passed
control: predator cannot persist capacity['predator-extinct', [3.0, 0.0]]['predator-extinct', [3.0, 0.0]]Passed

SHA-256 / 849681278e8790f32cb111e66b1bdaeb3dd853b43953dffcdbd56cc7d4f36f68

3 / The verified repair

Exit 0
"""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)) / 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]]),
  ('control: 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: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('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),
  ('control: 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]]),
  ('control: 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: 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]]),
  ('control: 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]])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: exact hopf point['hopf', [4.0, 1.8]]['hopf', [4.0, 1.8]]Passed
control: enriched cycles['cycles', [4.0, 2.7]]['cycles', [4.0, 2.7]]Passed
control: poor habitat stable['stable', [4.0, 1.5]]['stable', [4.0, 1.5]]Passed
control: just above hump['cycles', [4.0, 1.807157]]['cycles', [4.0, 1.807157]]Passed
regression: just below enrichment threshold['stable', [4.0, 1.792757]]['stable', [4.0, 1.792757]]Passed
control: inefficient predator['predator-extinct', [50.0, 0.0]]['predator-extinct', [50.0, 0.0]]Passed
control: predator cannot persist capacity['predator-extinct', [3.0, 0.0]]['predator-extinct', [3.0, 0.0]]Passed

SHA-256 / 71833b0857171a2a980ec276f46b65eb13d54d3d404f881c56cce5774f44b83c

Verification & scope

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

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

Case digest / dee1e4bfeabbcc1ec3629d6b5d4e1e551ef46080e35ddada9e6a828f49ab0ef2