FA-93081 / EV charging session scheduling / Open access
Round-robin port rotation: completion before quantum expiry · case 01
A vehicle that finishes exactly at its quantum boundary is requeued and never reported done.
ROOT CAUSE
The quantum-expiry branch is tested before the completion branch.
VERIFIED REPAIR
Check completion first, then quantum expiry.
Unsuccessful approach: Making the checks independent still leaves finished vehicles on their port or requeues them.
Case contract
vehicles is [[id, need_slots]] in arrival order. Each slot, free ports are filled from the FIFO queue; a vehicle holds its port for quantum slots or until done, then goes to the back of the queue. Return [timeline of sorted charging ids per slot, [[id, finish]] sorted by id] where finish is the slot index after its last charging slot, 0 when nothing was needed, None if unfinished.
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(vehicles, ports, slots, quantum):
queue = [[vid, need] for vid, need in vehicles if need > 0]
done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
active = []
timeline = []
for t in range(slots):
while len(active) < ports and queue:
v = queue.pop(0)
active.append([v[0], v[1], quantum])
timeline.append(sorted(a[0] for a in active))
nxt = []
for a in active:
a[1] -= 1
a[2] -= 1
if a[2] == 0:
queue.append([a[0], a[1]])
elif a[1] == 0:
done[a[0]] = t + 1
else:
nxt.append(a)
active = nxt
return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
[['V0', 3], ['V1', 1], ['V2', 3]]]],
['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
[[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
[['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
[[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
[['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 4], ['V1', 6]], 3, 12, 1],
[[['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V1'], ['V1'], [], [], [], [], [],
[]],
[['V0', 4], ['V1', 6]]]],
['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
[[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
[['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
[[['V0'], ['V0'], ['V1']],
[['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
[[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
[['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
[[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
[['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
[[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
[['V0', 0], ['V1', 6], ['V2', 4]]]],
['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
[[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 4]], 2, 9, 3],
[[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V3'], ['V1', 'V3'], ['V1', 'V3'], ['V3'], [],
[]],
[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 7]]]],
['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 3, 8, 2],
[[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
[['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
[['V0', 2], ['V1', None], ['V2', None]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
[['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 2, 9, 1],
[[['V0'], ['V0'], ['V0'], [], [], [], [], [], []], [['V0', 3]]]],
['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
[['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
[[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
[['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
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 |
|---|---|---|---|
| boundary: vehicle needing nothing | [[['B'], ['B'], ['B']], [['A', 0], ['B', None]]] | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | Failed |
| boundary: finishes exactly at quantum end | [[['A'], ['A'], ['B'], ['B'], ['A']], [['A', None], ['B', None]]] | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | Failed |
| boundary: more ports than vehicles | [[['A'], ['A'], ['A'], ['A']], [['A', None]]] | [[['A'], ['A'], ['A'], []], [['A', 3]]] | Failed |
| regression: completion before quantum expiry | [[['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2']], [['V0', None], ['V1', 0], ['V2', None]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Failed |
| regression: completion before quantum expiry (partial repair) | [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2']], [['V0', None], ['V1', 1], ['V2', None]]] | [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 3], ['V1', 1], ['V2', 3]]] | Failed |
| control 1 | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]] | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | Failed |
| control 2 | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', None]]] | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | Failed |
SHA-256 / 71dc38acc94338db9a7d93e31b9dd17dad5f4a01a765e93e1e964455d4b5e1cf
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
queue = [[vid, need] for vid, need in vehicles if need > 0]
done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
active = []
timeline = []
for t in range(slots):
while len(active) < ports and queue:
v = queue.pop(0)
active.append([v[0], v[1], quantum])
timeline.append(sorted(a[0] for a in active))
nxt = []
for a in active:
a[1] -= 1
a[2] -= 1
if a[1] == 0:
done[a[0]] = t + 1
if a[2] == 0:
queue.append([a[0], a[1]])
else:
nxt.append(a)
active = nxt
return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
[['V0', 3], ['V1', 1], ['V2', 3]]]],
['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
[[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
[['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
[[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
[['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 4], ['V1', 6]], 3, 12, 1],
[[['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V1'], ['V1'], [], [], [], [], [],
[]],
[['V0', 4], ['V1', 6]]]],
['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
[[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
[['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
[[['V0'], ['V0'], ['V1']],
[['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
[[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
[['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
[[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
[['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
[[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
[['V0', 0], ['V1', 6], ['V2', 4]]]],
['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
[[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 4]], 2, 9, 3],
[[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V3'], ['V1', 'V3'], ['V1', 'V3'], ['V3'], [],
[]],
[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 7]]]],
['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 3, 8, 2],
[[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
[['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
[['V0', 2], ['V1', None], ['V2', None]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
[['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 2, 9, 1],
[[['V0'], ['V0'], ['V0'], [], [], [], [], [], []], [['V0', 3]]]],
['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
[['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
[[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
[['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
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 |
|---|---|---|---|
| boundary: vehicle needing nothing | [[['B'], ['B'], ['B']], [['A', 0], ['B', 2]]] | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | Failed |
| boundary: finishes exactly at quantum end | [[['A'], ['A'], ['B'], ['B'], ['A']], [['A', 2], ['B', 4]]] | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | Failed |
| boundary: more ports than vehicles | [[['A'], ['A'], ['A'], ['A']], [['A', 3]]] | [[['A'], ['A'], ['A'], []], [['A', 3]]] | Failed |
| regression: completion before quantum expiry | [[['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2'], ['V0', 'V2']], [['V0', 2], ['V1', 0], ['V2', 3]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Failed |
| regression: completion before quantum expiry (partial repair) | [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']], [['V0', 3], ['V1', 1], ['V2', 3]]] | [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 3], ['V1', 1], ['V2', 3]]] | Failed |
| control 1 | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 8], ['V4', None], ['V5', None]]] | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | Failed |
| control 2 | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | Passed |
SHA-256 / 6a90c5b9700e5501741802015fa3401f526156d6282530b0fbe0adf39aeea004
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
queue = [[vid, need] for vid, need in vehicles if need > 0]
done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
active = []
timeline = []
for t in range(slots):
while len(active) < ports and queue:
v = queue.pop(0)
active.append([v[0], v[1], quantum])
timeline.append(sorted(a[0] for a in active))
nxt = []
for a in active:
a[1] -= 1
a[2] -= 1
if a[1] == 0:
done[a[0]] = t + 1
elif a[2] == 0:
queue.append([a[0], a[1]])
else:
nxt.append(a)
active = nxt
return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
[['V0', 3], ['V1', 1], ['V2', 3]]]],
['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
[[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
[['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
[[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
[['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 4], ['V1', 6]], 3, 12, 1],
[[['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V1'], ['V1'], [], [], [], [], [],
[]],
[['V0', 4], ['V1', 6]]]],
['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
[[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
[['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
[[['V0'], ['V0'], ['V1']],
[['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
[[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
[['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
['regression: completion before quantum expiry (partial repair)',
[[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
[[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
[['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
[[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
[['V0', 0], ['V1', 6], ['V2', 4]]]],
['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
[[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 4]], 2, 9, 3],
[[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V3'], ['V1', 'V3'], ['V1', 'V3'], ['V3'], [],
[]],
[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 7]]]],
['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 3, 8, 2],
[[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
[['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
[['V0', 2], ['V1', None], ['V2', None]]]]],
[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
[[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
[[['A'], ['A'], ['A'], []], [['A', 3]]]],
['regression: completion before quantum expiry',
[[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
[['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 2, 9, 1],
[[['V0'], ['V0'], ['V0'], [], [], [], [], [], []], [['V0', 3]]]],
['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
[['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
[[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
[['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
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 |
|---|---|---|---|
| boundary: vehicle needing nothing | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | Passed |
| boundary: finishes exactly at quantum end | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | Passed |
| boundary: more ports than vehicles | [[['A'], ['A'], ['A'], []], [['A', 3]]] | [[['A'], ['A'], ['A'], []], [['A', 3]]] | Passed |
| regression: completion before quantum expiry | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Passed |
| regression: completion before quantum expiry (partial repair) | [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 3], ['V1', 1], ['V2', 3]]] | [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 3], ['V1', 1], ['V2', 3]]] | Passed |
| control 1 | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | Passed |
| control 2 | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | Passed |
SHA-256 / 08e58a844867788afeb56808988769e980aa71d8664d74886490ce8203deb023
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:51.810412+00:00.
Case digest / 895e24408ec15e033aef358ab96a276b4e75691cfea8b1f931a97887ccbcdbfe