FA-65576 / Ecological population dynamics / Open access
Levins metapopulation with habitat destruction: habitat loss in colonisation · case 01
Destroyed patches are still colonised.
ROOT CAUSE
Colonisation targets all empty patches including destroyed ones.
VERIFIED REPAIR
Restore the habitat loss in colonisation rule: `c * p * (1 - destroyed - p)`.
Unsuccessful approach: Scaling colonisation by 1-D does not remove destroyed patches from the target pool.
Case contract
Occupancy p: p += c*p*(1-D-p) - e*p each year, clamped to [0, 1-D]; equilibrium max(0, 1-D-e/c); return [equilibrium rounded 6, trajectory rounded 6]; None for c<=0, e<0 or D outside [0,1).
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(c, e, destroyed, p0, years):
if c <= 0 or e < 0 or not 0 <= destroyed < 1:
return None
eq = max(0.0, 1 - destroyed - e / c)
p = p0
traj = []
for _ in range(years):
p = p + c * p * (1 - p) - e * p
p = min(max(p, 0.0), 1 - destroyed)
traj.append(round(p, 6))
return [round(eq, 6), traj]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: butterfly network | [0.6, [0.135, 0.179888, 0.235663, 0.302159, 0.377373, 0.457117]] | [0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]] | Failed |
| control: intact habitat | [0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]] | [0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]] | Passed |
| regression: heavy destruction extinction | [0.0, [0.303, 0.305757, 0.308287, 0.310603, 0.312721, 0.314655]] | [0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]] | Failed |
| regression: overshoot clamp | [0.68, [0.7, 0.7, 0.7]] | [0.68, [0.7, 0.665, 0.689937]] | Failed |
| regression: no extinction | [0.9, [0.296, 0.42103, 0.567289, 0.714572]] | [0.9, [0.284, 0.388966, 0.508231, 0.627697]] | Failed |
| control: invalid destruction | None | None | Passed |
| control: empty network | [0.6, [0.0, 0.0, 0.0]] | [0.6, [0.0, 0.0, 0.0]] | Passed |
SHA-256 / 9d5d6fa5b0db6e2e4de59f7846c1b1666232c052becde6f1bc20330b4b351155
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(c, e, destroyed, p0, years):
if c <= 0 or e < 0 or not 0 <= destroyed < 1:
return None
eq = max(0.0, 1 - destroyed - e / c)
p = p0
traj = []
for _ in range(years):
p = p + c * p * (1 - p) * (1 - destroyed) - e * p
p = min(max(p, 0.0), 1 - destroyed)
traj.append(round(p, 6))
return [round(eq, 6), traj]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: butterfly network | [0.6, [0.126, 0.15745, 0.194768, 0.238025, 0.28677, 0.339906]] | [0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]] | Failed |
| control: intact habitat | [0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]] | [0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]] | Passed |
| regression: heavy destruction extinction | [0.0, [0.2715, 0.246868, 0.225383, 0.206494, 0.189774, 0.174883]] | [0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]] | Failed |
| regression: overshoot clamp | [0.68, [0.7, 0.7, 0.7]] | [0.68, [0.7, 0.665, 0.689937]] | Failed |
| regression: no extinction | [0.9, [0.2864, 0.396763, 0.526007, 0.660642]] | [0.9, [0.284, 0.388966, 0.508231, 0.627697]] | Failed |
| control: invalid destruction | None | None | Passed |
| control: empty network | [0.6, [0.0, 0.0, 0.0]] | [0.6, [0.0, 0.0, 0.0]] | Passed |
SHA-256 / 6a143a9d25b02f4171e22db593fe976b12fdef540a211390799212dc67158fa9
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(c, e, destroyed, p0, years):
if c <= 0 or e < 0 or not 0 <= destroyed < 1:
return None
eq = max(0.0, 1 - destroyed - e / c)
p = p0
traj = []
for _ in range(years):
p = p + c * p * (1 - destroyed - p) - e * p
p = min(max(p, 0.0), 1 - destroyed)
traj.append(round(p, 6))
return [round(eq, 6), traj]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: overshoot clamp', (2.5, 0.05, 0.3, 0.6, 3), [0.68, [0.7, 0.665, 0.689937]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])],
[('regression: butterfly network',
(0.5, 0.1, 0.2, 0.1, 6),
[0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]]),
('control: intact habitat',
(0.4, 0.1, 0.0, 0.05, 5),
[0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]]),
('regression: heavy destruction extinction',
(0.3, 0.2, 0.5, 0.3, 6),
[0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]]),
('regression: no extinction', (0.6, 0.0, 0.1, 0.2, 4), [0.9, [0.284, 0.388966, 0.508231, 0.627697]]),
('control: invalid destruction', (0.5, 0.1, 1.0, 0.1, 3), None),
('control: empty network', (0.5, 0.1, 0.2, 0.0, 3), [0.6, [0.0, 0.0, 0.0]]),
('regression: high turnover',
(1.2, 0.8, 0.25, 0.4, 5),
[0.083333, [0.248, 0.198995, 0.171376, 0.15327, 0.140407]])]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: butterfly network | [0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]] | [0.6, [0.125, 0.154687, 0.18913, 0.227984, 0.27039, 0.314952]] | Passed |
| control: intact habitat | [0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]] | [0.75, [0.064, 0.081562, 0.103369, 0.130106, 0.162367]] | Passed |
| regression: heavy destruction extinction | [0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]] | [0.0, [0.258, 0.225131, 0.198669, 0.176895, 0.158663, 0.143177]] | Passed |
| regression: overshoot clamp | [0.68, [0.7, 0.665, 0.689937]] | [0.68, [0.7, 0.665, 0.689937]] | Passed |
| regression: no extinction | [0.9, [0.284, 0.388966, 0.508231, 0.627697]] | [0.9, [0.284, 0.388966, 0.508231, 0.627697]] | Passed |
| control: invalid destruction | None | None | Passed |
| control: empty network | [0.6, [0.0, 0.0, 0.0]] | [0.6, [0.0, 0.0, 0.0]] | Passed |
SHA-256 / 12a4edf58c8258450fd7b9b977b8de459903628d8b2925bd34b6aef7732ebe6a
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:35.304770+00:00.
Case digest / d0757399ba52d13d59a726382fef2bf967c6632a03b3af26944bf7d0b27d99c4