FA-93251 / EV charging session scheduling / Open access
Contiguous cheap charging blocks: fallback count · case 01
Fallback adds more slots than were needed.
ROOT CAUSE
The fallback slice ignores slots already chosen from runs.
VERIFIED REPAIR
Add only need_slots - len(chosen) fallback slots.
Unsuccessful approach: Subtracting the number of runs confuses runs with slots.
Case contract
Slots with price <= threshold form runs of consecutive slots; runs shorter than min_len are ignored to avoid contactor cycling. Slots of qualifying runs are taken chronologically until need_slots are chosen. If still short, the remaining cheapest unchosen slots (ties: earlier) are added regardless of runs and fallback is True. Return [sorted slots, fallback].
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(prices, threshold, min_len, need_slots):
runs = []
cur = []
for i, p in enumerate(prices):
if p <= threshold:
cur.append(i)
else:
if cur:
runs.append(cur)
cur = []
if cur:
runs.append(cur)
chosen = []
for run in runs:
if len(run) >= min_len:
for i in run:
if len(chosen) < need_slots:
chosen.append(i)
fallback = False
if len(chosen) < need_slots:
fallback = True
rest = sorted((p, i) for i, p in enumerate(prices) if i not in chosen)
for p, i in rest[:need_slots]:
chosen.append(i)
return [sorted(chosen), fallback]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[-2, -2, 10, 8, 0, 5, -2, 8, 20, -2, -2], 0, 1, 7],
[[0, 1, 4, 5, 6, 9, 10], True]],
['regression: fallback count (partial repair)', [[30, 12, 0, 20, 12, 0], 8, 3, 6],
[[0, 1, 2, 3, 4, 5], True]],
['control 1', [[5, 20, 15, 10, -2], 10, 3, 5], [[0, 1, 2, 3, 4], True]],
['control 2', [[30, 30, 0, -2, 20, 8, 5, 20, 0, 20], 0, 4, 1], [[3], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count',
[[20, 5, 15, 12, 15, 30, 5, 20, 0, 20, 10, 0, 5, -2, 10], 12, 4, 6],
[[8, 10, 11, 12, 13, 14], True]],
['regression: fallback count (partial repair)', [[20, 8, 10, 30, -2, 0, 12, 20, 8, 8], 12, 4, 1],
[[4], True]],
['control 1', [[30, -2, 5, 12, 8, 20, 20, 20], 12, 1, 7], [[1, 2, 3, 4, 5, 6, 7], True]],
['control 2', [[30, 8, 15, 0, 15], 8, 2, 2], [[1, 3], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[30, 8, 12, 30, 30, 5, 5, 12], 8, 1, 5], [[1, 2, 5, 6, 7], True]],
['regression: fallback count (partial repair)',
[[20, 15, 10, 30, 12, 30, -2, 10, 15, 30, 5, 20], 12, 4, 2], [[6, 10], True]],
['control 1', [[20, -2, 10, 8, 15, 10, 0, 8, 12, 5, 8, 0, 8], 0, 1, 1], [[1], False]],
['control 2', [[-2, 8, 8, 12, -2, -2, -2, 10, 12, 15], 0, 2, 7], [[0, 1, 2, 4, 5, 6, 7], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[12, 15, 20, 30, 10, 0, 8], 8, 1, 4], [[0, 4, 5, 6], True]],
['regression: fallback count (partial repair)', [[12, 20, -2, 30, 0, 20], 10, 3, 5],
[[0, 1, 2, 4, 5], True]],
['control 1', [[-2, 12, 30, 10, 10, 10, 15, 0, 15, 10, -2, 20, 0], 12, 4, 5],
[[0, 3, 7, 10, 12], True]],
['control 2', [[10, 30, 15, 20, -2, 20, 10, 20, -2, 8, 5, 0, 20], 8, 3, 1], [[8], False]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[-2, 10, 30, 12, 8, 0, 8, 30, -2, 12, -2, 0, 12], 8, 2, 7],
[[0, 4, 5, 6, 8, 10, 11], True]],
['regression: fallback count (partial repair)',
[[0, 12, 15, 20, 5, 20, 10, -2, 15, 20, 12, 10, 12, 20, 15], 0, 3, 1], [[7], True]],
['control 1', [[20, 15, 8, 8, -2, 8, -2, 30, 12, 30, 10], 10, 2, 1], [[2], False]],
['control 2', [[5, 12, 20, 0, 15, -2], 12, 4, 6], [[0, 1, 2, 3, 4, 5], True]]]]
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: run ending at horizon | [[2, 3], False] | [[2, 3], False] | Passed |
| boundary: run exactly min_len | [[0, 1], False] | [[0, 1], False] | Passed |
| boundary: nothing needed | [[], False] | [[], False] | Passed |
| regression: fallback count | [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], True] | [[0, 1, 4, 5, 6, 9, 10], True] | Failed |
| regression: fallback count (partial repair) | [[0, 1, 2, 3, 4, 5], True] | [[0, 1, 2, 3, 4, 5], True] | Passed |
| control 1 | [[0, 1, 2, 3, 4], True] | [[0, 1, 2, 3, 4], True] | Passed |
| control 2 | [[3], True] | [[3], True] | Passed |
SHA-256 / a0050c47c51280fe3e1107acebcb305d6fe5521df71213af853b46d1a680d30e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(prices, threshold, min_len, need_slots):
runs = []
cur = []
for i, p in enumerate(prices):
if p <= threshold:
cur.append(i)
else:
if cur:
runs.append(cur)
cur = []
if cur:
runs.append(cur)
chosen = []
for run in runs:
if len(run) >= min_len:
for i in run:
if len(chosen) < need_slots:
chosen.append(i)
fallback = False
if len(chosen) < need_slots:
fallback = True
rest = sorted((p, i) for i, p in enumerate(prices) if i not in chosen)
for p, i in rest[:need_slots - len(runs)]:
chosen.append(i)
return [sorted(chosen), fallback]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[-2, -2, 10, 8, 0, 5, -2, 8, 20, -2, -2], 0, 1, 7],
[[0, 1, 4, 5, 6, 9, 10], True]],
['regression: fallback count (partial repair)', [[30, 12, 0, 20, 12, 0], 8, 3, 6],
[[0, 1, 2, 3, 4, 5], True]],
['control 1', [[5, 20, 15, 10, -2], 10, 3, 5], [[0, 1, 2, 3, 4], True]],
['control 2', [[30, 30, 0, -2, 20, 8, 5, 20, 0, 20], 0, 4, 1], [[3], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count',
[[20, 5, 15, 12, 15, 30, 5, 20, 0, 20, 10, 0, 5, -2, 10], 12, 4, 6],
[[8, 10, 11, 12, 13, 14], True]],
['regression: fallback count (partial repair)', [[20, 8, 10, 30, -2, 0, 12, 20, 8, 8], 12, 4, 1],
[[4], True]],
['control 1', [[30, -2, 5, 12, 8, 20, 20, 20], 12, 1, 7], [[1, 2, 3, 4, 5, 6, 7], True]],
['control 2', [[30, 8, 15, 0, 15], 8, 2, 2], [[1, 3], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[30, 8, 12, 30, 30, 5, 5, 12], 8, 1, 5], [[1, 2, 5, 6, 7], True]],
['regression: fallback count (partial repair)',
[[20, 15, 10, 30, 12, 30, -2, 10, 15, 30, 5, 20], 12, 4, 2], [[6, 10], True]],
['control 1', [[20, -2, 10, 8, 15, 10, 0, 8, 12, 5, 8, 0, 8], 0, 1, 1], [[1], False]],
['control 2', [[-2, 8, 8, 12, -2, -2, -2, 10, 12, 15], 0, 2, 7], [[0, 1, 2, 4, 5, 6, 7], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[12, 15, 20, 30, 10, 0, 8], 8, 1, 4], [[0, 4, 5, 6], True]],
['regression: fallback count (partial repair)', [[12, 20, -2, 30, 0, 20], 10, 3, 5],
[[0, 1, 2, 4, 5], True]],
['control 1', [[-2, 12, 30, 10, 10, 10, 15, 0, 15, 10, -2, 20, 0], 12, 4, 5],
[[0, 3, 7, 10, 12], True]],
['control 2', [[10, 30, 15, 20, -2, 20, 10, 20, -2, 8, 5, 0, 20], 8, 3, 1], [[8], False]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[-2, 10, 30, 12, 8, 0, 8, 30, -2, 12, -2, 0, 12], 8, 2, 7],
[[0, 4, 5, 6, 8, 10, 11], True]],
['regression: fallback count (partial repair)',
[[0, 12, 15, 20, 5, 20, 10, -2, 15, 20, 12, 10, 12, 20, 15], 0, 3, 1], [[7], True]],
['control 1', [[20, 15, 8, 8, -2, 8, -2, 30, 12, 30, 10], 10, 2, 1], [[2], False]],
['control 2', [[5, 12, 20, 0, 15, -2], 12, 4, 6], [[0, 1, 2, 3, 4, 5], True]]]]
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: run ending at horizon | [[2, 3], False] | [[2, 3], False] | Passed |
| boundary: run exactly min_len | [[0, 1], False] | [[0, 1], False] | Passed |
| boundary: nothing needed | [[], False] | [[], False] | Passed |
| regression: fallback count | [[0, 1, 3, 4, 5, 6, 7, 9, 10], True] | [[0, 1, 4, 5, 6, 9, 10], True] | Failed |
| regression: fallback count (partial repair) | [[1, 2, 4, 5], True] | [[0, 1, 2, 3, 4, 5], True] | Failed |
| control 1 | [[0, 3, 4], True] | [[0, 1, 2, 3, 4], True] | Failed |
| control 2 | [[0, 2, 3, 4, 5, 6, 7, 8, 9], True] | [[3], True] | Failed |
SHA-256 / 1e1411c1380b8ae9df88c49a4b42fc64bbc4f18b206875f3dbb3e9685fda4c92
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(prices, threshold, min_len, need_slots):
runs = []
cur = []
for i, p in enumerate(prices):
if p <= threshold:
cur.append(i)
else:
if cur:
runs.append(cur)
cur = []
if cur:
runs.append(cur)
chosen = []
for run in runs:
if len(run) >= min_len:
for i in run:
if len(chosen) < need_slots:
chosen.append(i)
fallback = False
if len(chosen) < need_slots:
fallback = True
rest = sorted((p, i) for i, p in enumerate(prices) if i not in chosen)
for p, i in rest[:need_slots - len(chosen)]:
chosen.append(i)
return [sorted(chosen), fallback]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[-2, -2, 10, 8, 0, 5, -2, 8, 20, -2, -2], 0, 1, 7],
[[0, 1, 4, 5, 6, 9, 10], True]],
['regression: fallback count (partial repair)', [[30, 12, 0, 20, 12, 0], 8, 3, 6],
[[0, 1, 2, 3, 4, 5], True]],
['control 1', [[5, 20, 15, 10, -2], 10, 3, 5], [[0, 1, 2, 3, 4], True]],
['control 2', [[30, 30, 0, -2, 20, 8, 5, 20, 0, 20], 0, 4, 1], [[3], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count',
[[20, 5, 15, 12, 15, 30, 5, 20, 0, 20, 10, 0, 5, -2, 10], 12, 4, 6],
[[8, 10, 11, 12, 13, 14], True]],
['regression: fallback count (partial repair)', [[20, 8, 10, 30, -2, 0, 12, 20, 8, 8], 12, 4, 1],
[[4], True]],
['control 1', [[30, -2, 5, 12, 8, 20, 20, 20], 12, 1, 7], [[1, 2, 3, 4, 5, 6, 7], True]],
['control 2', [[30, 8, 15, 0, 15], 8, 2, 2], [[1, 3], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[30, 8, 12, 30, 30, 5, 5, 12], 8, 1, 5], [[1, 2, 5, 6, 7], True]],
['regression: fallback count (partial repair)',
[[20, 15, 10, 30, 12, 30, -2, 10, 15, 30, 5, 20], 12, 4, 2], [[6, 10], True]],
['control 1', [[20, -2, 10, 8, 15, 10, 0, 8, 12, 5, 8, 0, 8], 0, 1, 1], [[1], False]],
['control 2', [[-2, 8, 8, 12, -2, -2, -2, 10, 12, 15], 0, 2, 7], [[0, 1, 2, 4, 5, 6, 7], True]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[12, 15, 20, 30, 10, 0, 8], 8, 1, 4], [[0, 4, 5, 6], True]],
['regression: fallback count (partial repair)', [[12, 20, -2, 30, 0, 20], 10, 3, 5],
[[0, 1, 2, 4, 5], True]],
['control 1', [[-2, 12, 30, 10, 10, 10, 15, 0, 15, 10, -2, 20, 0], 12, 4, 5],
[[0, 3, 7, 10, 12], True]],
['control 2', [[10, 30, 15, 20, -2, 20, 10, 20, -2, 8, 5, 0, 20], 8, 3, 1], [[8], False]]],
[['boundary: run ending at horizon', [[20, 20, 5, 5], 8, 2, 2], [[2, 3], False]],
['boundary: run exactly min_len', [[5, 5, 20, 5], 8, 2, 2], [[0, 1], False]],
['boundary: nothing needed', [[5, 5, 5], 8, 1, 0], [[], False]],
['regression: fallback count', [[-2, 10, 30, 12, 8, 0, 8, 30, -2, 12, -2, 0, 12], 8, 2, 7],
[[0, 4, 5, 6, 8, 10, 11], True]],
['regression: fallback count (partial repair)',
[[0, 12, 15, 20, 5, 20, 10, -2, 15, 20, 12, 10, 12, 20, 15], 0, 3, 1], [[7], True]],
['control 1', [[20, 15, 8, 8, -2, 8, -2, 30, 12, 30, 10], 10, 2, 1], [[2], False]],
['control 2', [[5, 12, 20, 0, 15, -2], 12, 4, 6], [[0, 1, 2, 3, 4, 5], True]]]]
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: run ending at horizon | [[2, 3], False] | [[2, 3], False] | Passed |
| boundary: run exactly min_len | [[0, 1], False] | [[0, 1], False] | Passed |
| boundary: nothing needed | [[], False] | [[], False] | Passed |
| regression: fallback count | [[0, 1, 4, 5, 6, 9, 10], True] | [[0, 1, 4, 5, 6, 9, 10], True] | Passed |
| regression: fallback count (partial repair) | [[0, 1, 2, 3, 4, 5], True] | [[0, 1, 2, 3, 4, 5], True] | Passed |
| control 1 | [[0, 1, 2, 3, 4], True] | [[0, 1, 2, 3, 4], True] | Passed |
| control 2 | [[3], True] | [[3], True] | Passed |
SHA-256 / 56d69158648f49bf244b099db76bc5669d7bbd9076b9e8fe0529c04a59c1d518
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:53.594017+00:00.
Case digest / 9fc434b60ef1e1daa9e46ce4cdaeeaf91c1dbb590f9b7417b2c8096833ceaf2e