FA-93226 / EV charging session scheduling / Open access
Contiguous cheap charging blocks: threshold inclusivity · case 01
Slots priced exactly at the threshold are not treated as cheap.
ROOT CAUSE
The cheap-slot test is strict.
THE FAILURE
The cheap-slot test is strict.
Unsuccessful approach: Excluding zero and negative prices discards the cheapest slots of all.
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 - 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: threshold inclusivity',
[[20, 12, 10, 20, 0, 20, 15, 5, -2, 10, 30, 12, 0, 30, 12], 10, 3, 4], [[4, 7, 8, 9], True]],
['regression: threshold inclusivity (partial repair)',
[[0, 30, 5, 0, 20, 12, 0, 5, -2, 5, -2, 30, 30, 20, 8, 5], 12, 1, 4], [[0, 2, 3, 5], False]],
['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: threshold inclusivity',
[[-2, 10, 5, 8, 8, 0, 20, 12, 8, 12, -2, 15, -2, 8, 0, 0], 10, 4, 3], [[0, 1, 2], False]],
['regression: threshold inclusivity (partial repair)',
[[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]],
['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: threshold inclusivity', [[5, 15, 8, 12, 15, 20, 10, 15, 30, 15], 10, 1, 3],
[[0, 2, 6], False]],
['regression: threshold inclusivity (partial repair)',
[[5, 0, -2, 5, 30, 0, 30, -2, 8, 10, 5, 8, 20, 5], 8, 2, 4], [[0, 1, 2, 3], False]],
['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: threshold inclusivity',
[[10, 8, 8, 8, 15, 12, 30, -2, 15, -2, 8, 12, 5, 15], 10, 4, 3], [[0, 1, 2], False]],
['regression: threshold inclusivity (partial repair)',
[[12, 20, 10, 15, 8, 12, 8, 5, 0, -2, 10, 15, 8, 15, 20], 0, 1, 1], [[8], False]],
['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: threshold inclusivity',
[[10, 12, 8, 12, -2, 8, 12, 12, 30, 8, 12, 0, 0, 15, -2, 15], 12, 2, 7],
[[0, 1, 2, 3, 4, 5, 6], False]],
['regression: threshold inclusivity (partial repair)',
[[30, 0, -2, 12, 5, 0, 0, -2, 10, 5, 30, 15, 15], 8, 2, 1], [[1], False]],
['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: threshold inclusivity | [[4, 7, 8, 12], True] | [[4, 7, 8, 9], True] | Failed |
| regression: threshold inclusivity (partial repair) | [[0, 2, 3, 6], False] | [[0, 2, 3, 5], False] | Failed |
| control 1 | [[0, 1, 2, 3, 4], True] | [[0, 1, 2, 3, 4], True] | Passed |
| control 2 | [[3], True] | [[3], True] | Passed |
SHA-256 / 3faa4c6755006100957acf024a5f6bb1a9813dab38b688d920899ea4dcaf392c
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 and p > 0:
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: threshold inclusivity',
[[20, 12, 10, 20, 0, 20, 15, 5, -2, 10, 30, 12, 0, 30, 12], 10, 3, 4], [[4, 7, 8, 9], True]],
['regression: threshold inclusivity (partial repair)',
[[0, 30, 5, 0, 20, 12, 0, 5, -2, 5, -2, 30, 30, 20, 8, 5], 12, 1, 4], [[0, 2, 3, 5], False]],
['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: threshold inclusivity',
[[-2, 10, 5, 8, 8, 0, 20, 12, 8, 12, -2, 15, -2, 8, 0, 0], 10, 4, 3], [[0, 1, 2], False]],
['regression: threshold inclusivity (partial repair)',
[[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]],
['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: threshold inclusivity', [[5, 15, 8, 12, 15, 20, 10, 15, 30, 15], 10, 1, 3],
[[0, 2, 6], False]],
['regression: threshold inclusivity (partial repair)',
[[5, 0, -2, 5, 30, 0, 30, -2, 8, 10, 5, 8, 20, 5], 8, 2, 4], [[0, 1, 2, 3], False]],
['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: threshold inclusivity',
[[10, 8, 8, 8, 15, 12, 30, -2, 15, -2, 8, 12, 5, 15], 10, 4, 3], [[0, 1, 2], False]],
['regression: threshold inclusivity (partial repair)',
[[12, 20, 10, 15, 8, 12, 8, 5, 0, -2, 10, 15, 8, 15, 20], 0, 1, 1], [[8], False]],
['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: threshold inclusivity',
[[10, 12, 8, 12, -2, 8, 12, 12, 30, 8, 12, 0, 0, 15, -2, 15], 12, 2, 7],
[[0, 1, 2, 3, 4, 5, 6], False]],
['regression: threshold inclusivity (partial repair)',
[[30, 0, -2, 12, 5, 0, 0, -2, 10, 5, 30, 15, 15], 8, 2, 1], [[1], False]],
['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: threshold inclusivity | [[4, 7, 8, 12], True] | [[4, 7, 8, 9], True] | Failed |
| regression: threshold inclusivity (partial repair) | [[2, 5, 7, 9], False] | [[0, 2, 3, 5], False] | Failed |
| control 1 | [[0, 1, 2, 3, 4], True] | [[0, 1, 2, 3, 4], True] | Passed |
| control 2 | [[3], True] | [[3], True] | Passed |
SHA-256 / 601dafde394a61864a12a0ad035d434c530bf6de424ead1fcdecfcb208c3b274
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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.158109+00:00.
Case digest / d568d7cb7967b41d868f9ec4e30ad5b2a2fd53c07e6dba17d1da951d00400949