FAILURE MAP
← Case archive

FA-93111 / EV charging session scheduling / Open access

Depot least-laxity-first charging: grant clamp to remaining · case 01

Vehicles end with negative remaining energy and capacity is wasted on them.

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

ROOT CAUSE

The per-slot grant is not limited by the energy the vehicle still needs.

VERIFIED REPAIR

Clamp each grant to max rate, remaining need and capacity left.

Unsuccessful approach: Clamping to the remaining need but not the capacity oversubscribes the site.

Case contract

fleet is [[id, need_units, depart_slot, max_units_per_slot]]. A vehicle is present in slots t < depart_slot. Each slot the site capacity site_units is granted in order of laxity (depart_slot - t - ceil(remaining/max_units)) ascending, ties by id; each vehicle gets min(max, remaining, capacity left). Return [[[id, remaining]] sorted by id, sorted ids with remaining > 0].

Why this case matters

Depot, workplace and public EV chargers schedule sessions against prices, circuit limits and departure deadlines; a wrong decision silently strands a driver or overloads a feeder.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(fleet, site_units, slots):
    rem = {v[0]: v[1] for v in fleet}
    for t in range(slots):
        present = [v for v in fleet if v[2] > t and rem[v[0]] > 0]
        def lax(v):
            need_slots = -(-rem[v[0]] // v[3])
            return (v[2] - t) - need_slots
        present.sort(key=lambda v: (lax(v), v[0]))
        cap = site_units
        for v in present:
            give = min(v[3], cap)
            rem[v[0]] -= give
            cap -= give
            if cap == 0:
                break
    missed = sorted(v[0] for v in fleet if rem[v[0]] > 0)
    return [[[k, rem[k]] for k in sorted(rem)], missed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 8, 6, 4], ['B1', 3, 8, 3], ['B3', 8, 6, 3], ['B0', 8, 9, 2], ['B4', 10, 3, 1]], 8, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0], ['B4', 7]], ['B4']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B2', 4, 8, 3], ['B0', 4, 7, 4], ['B1', 12, 4, 3]], 4, 4],
   [[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]],
  ['control 1', [[['B0', 4, 10, 3], ['B1', 4, 9, 3], ['B2', 1, 7, 3]], 7, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0]], []]],
  ['control 2', [[['B0', 1, 9, 4], ['B1', 13, 10, 4]], 7, 6], [[['B0', 0], ['B1', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 3, 8, 4], ['B0', 6, 2, 3], ['B1', 11, 2, 2]], 6, 10],
   [[['B0', 0], ['B1', 7], ['B2', 0]], ['B1']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B0', 3, 5, 4], ['B1', 9, 3, 1], ['B2', 14, 7, 2], ['B3', 9, 6, 4], ['B4', 11, 5, 2]], 5, 5],
   [[['B0', 0], ['B1', 6], ['B2', 6], ['B3', 8], ['B4', 1]], ['B1', 'B2', 'B3', 'B4']]],
  ['control 1', [[['B1', 9, 10, 4], ['B3', 1, 1, 4], ['B0', 4, 10, 3], ['B2', 6, 10, 3]], 6, 4],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['control 2', [[['B0', 3, 6, 1]], 7, 10], [[['B0', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining', [[['B1', 1, 9, 4], ['B0', 4, 1, 1]], 3, 6],
   [[['B0', 3], ['B1', 0]], ['B0']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B1', 7, 4, 3], ['B0', 14, 6, 2]], 3, 6], [[['B0', 2], ['B1', 3]], ['B0', 'B1']]],
  ['control 1', [[['B1', 10, 10, 4], ['B2', 9, 9, 4], ['B0', 9, 4, 1]], 6, 9],
   [[['B0', 5], ['B1', 0], ['B2', 0]], ['B0']]],
  ['control 2', [[['B0', 11, 5, 1]], 6, 4], [[['B0', 7]], ['B0']]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 6, 1, 2], ['B0', 6, 3, 3], ['B1', 8, 9, 4]], 3, 7],
   [[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B1', 12, 2, 3], ['B2', 11, 4, 2], ['B3', 13, 4, 4], ['B0', 7, 8, 4]], 4, 4],
   [[['B0', 7], ['B1', 6], ['B2', 5], ['B3', 9]], ['B0', 'B1', 'B2', 'B3']]],
  ['control 1', [[['B2', 2, 6, 3], ['B1', 0, 4, 3], ['B0', 10, 8, 1]], 2, 9],
   [[['B0', 2], ['B1', 0], ['B2', 0]], ['B0']]],
  ['control 2', [[['B2', 11, 5, 4], ['B0', 8, 10, 3], ['B1', 5, 5, 4]], 6, 9],
   [[['B0', 0], ['B1', 0], ['B2', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B1', 3, 9, 3], ['B2', 0, 5, 4], ['B3', 4, 6, 2], ['B0', 4, 9, 3]], 7, 6],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B0', 10, 8, 2], ['B1', 1, 2, 2], ['B2', 13, 3, 4], ['B4', 9, 8, 1], ['B3', 11, 8, 3]], 2,
    10],
   [[['B0', 6], ['B1', 1], ['B2', 8], ['B3', 9], ['B4', 4]], ['B0', 'B1', 'B2', 'B3', 'B4']]],
  ['control 1', [[['B0', 14, 4, 4], ['B2', 2, 9, 3], ['B3', 2, 10, 2], ['B1', 6, 6, 4]], 8, 9],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['control 2', [[['B1', 10, 5, 4], ['B0', 14, 10, 4], ['B2', 9, 3, 3], ['B3', 8, 10, 2]], 6, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 1]], ['B3']]]]]
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
boundary: departs at slot 1[[['A', 2], ['B', 0]], ['A']][[['A', 2], ['B', 0]], ['A']]Passed
boundary: exact capacity fit[[['A', 0], ['B', 0]], []][[['A', 0], ['B', 0]], []]Passed
boundary: empty fleet[[], []][[], []]Passed
regression: grant clamp to remaining[[['B0', 0], ['B1', 0], ['B2', -2], ['B3', -1], ['B4', 7]], ['B4']][[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0], ['B4', 7]], ['B4']]Failed
regression: grant clamp to remaining (partial repair)[[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']][[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]Passed
control 1[[['B0', 0], ['B1', -2], ['B2', -2]], []][[['B0', 0], ['B1', 0], ['B2', 0]], []]Failed
control 2[[['B0', -2], ['B1', -3]], []][[['B0', 0], ['B1', 0]], []]Failed

SHA-256 / 8dde4bb88cfa01db177fbc2b7379b3b0e0256b1a327a67bc25df59c866a8f144

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(fleet, site_units, slots):
    rem = {v[0]: v[1] for v in fleet}
    for t in range(slots):
        present = [v for v in fleet if v[2] > t and rem[v[0]] > 0]
        def lax(v):
            need_slots = -(-rem[v[0]] // v[3])
            return (v[2] - t) - need_slots
        present.sort(key=lambda v: (lax(v), v[0]))
        cap = site_units
        for v in present:
            give = min(v[3], rem[v[0]])
            rem[v[0]] -= give
            cap -= give
            if cap == 0:
                break
    missed = sorted(v[0] for v in fleet if rem[v[0]] > 0)
    return [[[k, rem[k]] for k in sorted(rem)], missed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 8, 6, 4], ['B1', 3, 8, 3], ['B3', 8, 6, 3], ['B0', 8, 9, 2], ['B4', 10, 3, 1]], 8, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0], ['B4', 7]], ['B4']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B2', 4, 8, 3], ['B0', 4, 7, 4], ['B1', 12, 4, 3]], 4, 4],
   [[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]],
  ['control 1', [[['B0', 4, 10, 3], ['B1', 4, 9, 3], ['B2', 1, 7, 3]], 7, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0]], []]],
  ['control 2', [[['B0', 1, 9, 4], ['B1', 13, 10, 4]], 7, 6], [[['B0', 0], ['B1', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 3, 8, 4], ['B0', 6, 2, 3], ['B1', 11, 2, 2]], 6, 10],
   [[['B0', 0], ['B1', 7], ['B2', 0]], ['B1']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B0', 3, 5, 4], ['B1', 9, 3, 1], ['B2', 14, 7, 2], ['B3', 9, 6, 4], ['B4', 11, 5, 2]], 5, 5],
   [[['B0', 0], ['B1', 6], ['B2', 6], ['B3', 8], ['B4', 1]], ['B1', 'B2', 'B3', 'B4']]],
  ['control 1', [[['B1', 9, 10, 4], ['B3', 1, 1, 4], ['B0', 4, 10, 3], ['B2', 6, 10, 3]], 6, 4],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['control 2', [[['B0', 3, 6, 1]], 7, 10], [[['B0', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining', [[['B1', 1, 9, 4], ['B0', 4, 1, 1]], 3, 6],
   [[['B0', 3], ['B1', 0]], ['B0']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B1', 7, 4, 3], ['B0', 14, 6, 2]], 3, 6], [[['B0', 2], ['B1', 3]], ['B0', 'B1']]],
  ['control 1', [[['B1', 10, 10, 4], ['B2', 9, 9, 4], ['B0', 9, 4, 1]], 6, 9],
   [[['B0', 5], ['B1', 0], ['B2', 0]], ['B0']]],
  ['control 2', [[['B0', 11, 5, 1]], 6, 4], [[['B0', 7]], ['B0']]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 6, 1, 2], ['B0', 6, 3, 3], ['B1', 8, 9, 4]], 3, 7],
   [[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B1', 12, 2, 3], ['B2', 11, 4, 2], ['B3', 13, 4, 4], ['B0', 7, 8, 4]], 4, 4],
   [[['B0', 7], ['B1', 6], ['B2', 5], ['B3', 9]], ['B0', 'B1', 'B2', 'B3']]],
  ['control 1', [[['B2', 2, 6, 3], ['B1', 0, 4, 3], ['B0', 10, 8, 1]], 2, 9],
   [[['B0', 2], ['B1', 0], ['B2', 0]], ['B0']]],
  ['control 2', [[['B2', 11, 5, 4], ['B0', 8, 10, 3], ['B1', 5, 5, 4]], 6, 9],
   [[['B0', 0], ['B1', 0], ['B2', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B1', 3, 9, 3], ['B2', 0, 5, 4], ['B3', 4, 6, 2], ['B0', 4, 9, 3]], 7, 6],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B0', 10, 8, 2], ['B1', 1, 2, 2], ['B2', 13, 3, 4], ['B4', 9, 8, 1], ['B3', 11, 8, 3]], 2,
    10],
   [[['B0', 6], ['B1', 1], ['B2', 8], ['B3', 9], ['B4', 4]], ['B0', 'B1', 'B2', 'B3', 'B4']]],
  ['control 1', [[['B0', 14, 4, 4], ['B2', 2, 9, 3], ['B3', 2, 10, 2], ['B1', 6, 6, 4]], 8, 9],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['control 2', [[['B1', 10, 5, 4], ['B0', 14, 10, 4], ['B2', 9, 3, 3], ['B3', 8, 10, 2]], 6, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 1]], ['B3']]]]]
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
boundary: departs at slot 1[[['A', 2], ['B', 0]], ['A']][[['A', 2], ['B', 0]], ['A']]Passed
boundary: exact capacity fit[[['A', 0], ['B', 0]], []][[['A', 0], ['B', 0]], []]Passed
boundary: empty fleet[[], []][[], []]Passed
regression: grant clamp to remaining[[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0], ['B4', 7]], ['B4']][[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0], ['B4', 7]], ['B4']]Passed
regression: grant clamp to remaining (partial repair)[[['B0', 0], ['B1', 0], ['B2', 0]], []][[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]Failed
control 1[[['B0', 0], ['B1', 0], ['B2', 0]], []][[['B0', 0], ['B1', 0], ['B2', 0]], []]Passed
control 2[[['B0', 0], ['B1', 0]], []][[['B0', 0], ['B1', 0]], []]Passed

SHA-256 / 7c80dc3c4fde931ed0e255f8b42db739a7ee4973cda5d1e2cd8cd8792865b9d2

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(fleet, site_units, slots):
    rem = {v[0]: v[1] for v in fleet}
    for t in range(slots):
        present = [v for v in fleet if v[2] > t and rem[v[0]] > 0]
        def lax(v):
            need_slots = -(-rem[v[0]] // v[3])
            return (v[2] - t) - need_slots
        present.sort(key=lambda v: (lax(v), v[0]))
        cap = site_units
        for v in present:
            give = min(v[3], rem[v[0]], cap)
            rem[v[0]] -= give
            cap -= give
            if cap == 0:
                break
    missed = sorted(v[0] for v in fleet if rem[v[0]] > 0)
    return [[[k, rem[k]] for k in sorted(rem)], missed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 8, 6, 4], ['B1', 3, 8, 3], ['B3', 8, 6, 3], ['B0', 8, 9, 2], ['B4', 10, 3, 1]], 8, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0], ['B4', 7]], ['B4']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B2', 4, 8, 3], ['B0', 4, 7, 4], ['B1', 12, 4, 3]], 4, 4],
   [[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]],
  ['control 1', [[['B0', 4, 10, 3], ['B1', 4, 9, 3], ['B2', 1, 7, 3]], 7, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0]], []]],
  ['control 2', [[['B0', 1, 9, 4], ['B1', 13, 10, 4]], 7, 6], [[['B0', 0], ['B1', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 3, 8, 4], ['B0', 6, 2, 3], ['B1', 11, 2, 2]], 6, 10],
   [[['B0', 0], ['B1', 7], ['B2', 0]], ['B1']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B0', 3, 5, 4], ['B1', 9, 3, 1], ['B2', 14, 7, 2], ['B3', 9, 6, 4], ['B4', 11, 5, 2]], 5, 5],
   [[['B0', 0], ['B1', 6], ['B2', 6], ['B3', 8], ['B4', 1]], ['B1', 'B2', 'B3', 'B4']]],
  ['control 1', [[['B1', 9, 10, 4], ['B3', 1, 1, 4], ['B0', 4, 10, 3], ['B2', 6, 10, 3]], 6, 4],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['control 2', [[['B0', 3, 6, 1]], 7, 10], [[['B0', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining', [[['B1', 1, 9, 4], ['B0', 4, 1, 1]], 3, 6],
   [[['B0', 3], ['B1', 0]], ['B0']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B1', 7, 4, 3], ['B0', 14, 6, 2]], 3, 6], [[['B0', 2], ['B1', 3]], ['B0', 'B1']]],
  ['control 1', [[['B1', 10, 10, 4], ['B2', 9, 9, 4], ['B0', 9, 4, 1]], 6, 9],
   [[['B0', 5], ['B1', 0], ['B2', 0]], ['B0']]],
  ['control 2', [[['B0', 11, 5, 1]], 6, 4], [[['B0', 7]], ['B0']]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B2', 6, 1, 2], ['B0', 6, 3, 3], ['B1', 8, 9, 4]], 3, 7],
   [[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B1', 12, 2, 3], ['B2', 11, 4, 2], ['B3', 13, 4, 4], ['B0', 7, 8, 4]], 4, 4],
   [[['B0', 7], ['B1', 6], ['B2', 5], ['B3', 9]], ['B0', 'B1', 'B2', 'B3']]],
  ['control 1', [[['B2', 2, 6, 3], ['B1', 0, 4, 3], ['B0', 10, 8, 1]], 2, 9],
   [[['B0', 2], ['B1', 0], ['B2', 0]], ['B0']]],
  ['control 2', [[['B2', 11, 5, 4], ['B0', 8, 10, 3], ['B1', 5, 5, 4]], 6, 9],
   [[['B0', 0], ['B1', 0], ['B2', 0]], []]]],
 [['boundary: departs at slot 1', [[['A', 4, 1, 2], ['B', 2, 5, 2]], 2, 3],
   [[['A', 2], ['B', 0]], ['A']]],
  ['boundary: exact capacity fit', [[['A', 2, 2, 1], ['B', 2, 2, 1]], 2, 3],
   [[['A', 0], ['B', 0]], []]],
  ['boundary: empty fleet', [[], 5, 3], [[], []]],
  ['regression: grant clamp to remaining',
   [[['B1', 3, 9, 3], ['B2', 0, 5, 4], ['B3', 4, 6, 2], ['B0', 4, 9, 3]], 7, 6],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['regression: grant clamp to remaining (partial repair)',
   [[['B0', 10, 8, 2], ['B1', 1, 2, 2], ['B2', 13, 3, 4], ['B4', 9, 8, 1], ['B3', 11, 8, 3]], 2,
    10],
   [[['B0', 6], ['B1', 1], ['B2', 8], ['B3', 9], ['B4', 4]], ['B0', 'B1', 'B2', 'B3', 'B4']]],
  ['control 1', [[['B0', 14, 4, 4], ['B2', 2, 9, 3], ['B3', 2, 10, 2], ['B1', 6, 6, 4]], 8, 9],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0]], []]],
  ['control 2', [[['B1', 10, 5, 4], ['B0', 14, 10, 4], ['B2', 9, 3, 3], ['B3', 8, 10, 2]], 6, 7],
   [[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 1]], ['B3']]]]]
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
boundary: departs at slot 1[[['A', 2], ['B', 0]], ['A']][[['A', 2], ['B', 0]], ['A']]Passed
boundary: exact capacity fit[[['A', 0], ['B', 0]], []][[['A', 0], ['B', 0]], []]Passed
boundary: empty fleet[[], []][[], []]Passed
regression: grant clamp to remaining[[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0], ['B4', 7]], ['B4']][[['B0', 0], ['B1', 0], ['B2', 0], ['B3', 0], ['B4', 7]], ['B4']]Passed
regression: grant clamp to remaining (partial repair)[[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']][[['B0', 0], ['B1', 0], ['B2', 4]], ['B2']]Passed
control 1[[['B0', 0], ['B1', 0], ['B2', 0]], []][[['B0', 0], ['B1', 0], ['B2', 0]], []]Passed
control 2[[['B0', 0], ['B1', 0]], []][[['B0', 0], ['B1', 0]], []]Passed

SHA-256 / 6ef4e4f38ed2ba2f3c683b49e98b17c7805684c9b90ad05bbe576bcef250fedf

Verification & scope

Deterministic stipulated toy contract for teaching; no claim of conformance with any standard, vendor protocol or production controller. 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:51:52.277798+00:00.

Case digest / 6c0756cc7d198dfd62a5f5890c94e75f20f7fcea3f649c72d13974e7da248164