FA-93271 / EV charging session scheduling / Open access
Arrival charger matching: duration rounding · case 01
Some sessions are reported as finishing a minute early.
ROOT CAUSE
The duration is truncated instead of rounded up.
VERIFIED REPAIR
Round the minutes up.
Unsuccessful approach: Rounding hours up before converting to minutes badly overestimates durations.
Case contract
chargers are [id, kw, free_at]; kw > 22 is DC (usable only if dc_ok, full kw), otherwise AC limited to the vehicle onboard max_ac. vehicle is [need_kwh, depart, max_ac, dc_ok]. Finish = max(now, free_at) + ceil(need*60/power) minutes. Among chargers finishing by depart pick the lowest power, then earliest finish, then id; otherwise the earliest finish (then id) with status 'late'. Return [id, finish, status] or None when no charger is usable.
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
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
need, depart, max_ac, dc_ok = vehicle
opts = []
for cid, kw, free_at in chargers:
if kw > 22:
if not dc_ok:
continue
pw = kw
else:
pw = min(kw, max_ac)
start = max(now, free_at)
finish = start + int(need * 60 / pw)
opts.append([pw, finish, cid])
if not opts:
return None
ok = [o for o in opts if o[1] <= depart]
if ok:
pw, finish, cid = min(ok)
return [cid, finish, 'ok']
pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
return [cid, finish, 'late']
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 150, 10], [2, 22, 120], [3, 150, 30], [4, 3.7, 120]], [20, 111, 3.7, False], 6],
[2, 445, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 11, 0], [2, 150, 120], [3, 22, 10], [4, 3.7, 0]], [5, 101, 7.4, False], 31],
[1, 72, 'ok']],
['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 11, 0], [2, 3.7, 0], [3, 22, 0], [4, 7.4, 60], [5, 150, 10]], [5, 326, 11, True], 13],
[2, 95, 'ok']],
['regression: duration rounding (partial repair)',
[[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
['control 2',
[[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
45],
[5, 174, 'ok']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 11, 60], [2, 150, 30], [3, 7.4, 0], [4, 3.7, 0], [5, 7.4, 60]], [10, 35, 3.7, False], 25],
[3, 188, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 22, 120], [2, 7.4, 30]], [45, 240, 3.7, False], 22], [2, 760, 'late']],
['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
[4, 33, 'ok']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
[2, 200, 'ok']],
['regression: duration rounding (partial repair)',
[[[1, 7.4, 0], [2, 150, 0]], [5, 263, 11, True], 56], [1, 97, 'ok']],
['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
[1, 790, 'late']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding', [[[1, 3.7, 0]], [45, 358, 3.7, False], 15], [1, 745, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 50, 0], [2, 50, 30]], [10, 89, 7.4, True], 45], [1, 57, 'ok']],
['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, 'ok']]]]
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: 22 kW AC charger | [1, 60, 'ok'] | [1, 60, 'ok'] | Passed |
| boundary: finish exactly at departure | [1, 300, 'ok'] | [1, 300, 'ok'] | Passed |
| boundary: only DC and no DC support | None | None | Passed |
| regression: duration rounding | [2, 444, 'late'] | [2, 445, 'late'] | Failed |
| regression: duration rounding (partial repair) | [1, 71, 'ok'] | [1, 72, 'ok'] | Failed |
| control 1 | [1, 87, 'ok'] | [1, 88, 'ok'] | Failed |
| control 2 | None | None | Passed |
SHA-256 / f0c463842e6a3481000d8b818e0d986045ef55f66d6f9286e066dc707e96c6e9
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
need, depart, max_ac, dc_ok = vehicle
opts = []
for cid, kw, free_at in chargers:
if kw > 22:
if not dc_ok:
continue
pw = kw
else:
pw = min(kw, max_ac)
start = max(now, free_at)
finish = start + math.ceil(need / pw) * 60
opts.append([pw, finish, cid])
if not opts:
return None
ok = [o for o in opts if o[1] <= depart]
if ok:
pw, finish, cid = min(ok)
return [cid, finish, 'ok']
pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
return [cid, finish, 'late']
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 150, 10], [2, 22, 120], [3, 150, 30], [4, 3.7, 120]], [20, 111, 3.7, False], 6],
[2, 445, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 11, 0], [2, 150, 120], [3, 22, 10], [4, 3.7, 0]], [5, 101, 7.4, False], 31],
[1, 72, 'ok']],
['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 11, 0], [2, 3.7, 0], [3, 22, 0], [4, 7.4, 60], [5, 150, 10]], [5, 326, 11, True], 13],
[2, 95, 'ok']],
['regression: duration rounding (partial repair)',
[[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
['control 2',
[[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
45],
[5, 174, 'ok']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 11, 60], [2, 150, 30], [3, 7.4, 0], [4, 3.7, 0], [5, 7.4, 60]], [10, 35, 3.7, False], 25],
[3, 188, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 22, 120], [2, 7.4, 30]], [45, 240, 3.7, False], 22], [2, 760, 'late']],
['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
[4, 33, 'ok']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
[2, 200, 'ok']],
['regression: duration rounding (partial repair)',
[[[1, 7.4, 0], [2, 150, 0]], [5, 263, 11, True], 56], [1, 97, 'ok']],
['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
[1, 790, 'late']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding', [[[1, 3.7, 0]], [45, 358, 3.7, False], 15], [1, 745, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 50, 0], [2, 50, 30]], [10, 89, 7.4, True], 45], [1, 57, 'ok']],
['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, 'ok']]]]
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: 22 kW AC charger | [1, 60, 'ok'] | [1, 60, 'ok'] | Passed |
| boundary: finish exactly at departure | [1, 300, 'ok'] | [1, 300, 'ok'] | Passed |
| boundary: only DC and no DC support | None | None | Passed |
| regression: duration rounding | [2, 480, 'late'] | [2, 445, 'late'] | Failed |
| regression: duration rounding (partial repair) | [1, 91, 'ok'] | [1, 72, 'ok'] | Failed |
| control 1 | [1, 120, 'ok'] | [1, 88, 'ok'] | Failed |
| control 2 | None | None | Passed |
SHA-256 / acc4ab793f4665bcf6158079cad04385c34cd1106da5237927376164b0521922
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
need, depart, max_ac, dc_ok = vehicle
opts = []
for cid, kw, free_at in chargers:
if kw > 22:
if not dc_ok:
continue
pw = kw
else:
pw = min(kw, max_ac)
start = max(now, free_at)
finish = start + math.ceil(need * 60 / pw)
opts.append([pw, finish, cid])
if not opts:
return None
ok = [o for o in opts if o[1] <= depart]
if ok:
pw, finish, cid = min(ok)
return [cid, finish, 'ok']
pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
return [cid, finish, 'late']
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 150, 10], [2, 22, 120], [3, 150, 30], [4, 3.7, 120]], [20, 111, 3.7, False], 6],
[2, 445, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 11, 0], [2, 150, 120], [3, 22, 10], [4, 3.7, 0]], [5, 101, 7.4, False], 31],
[1, 72, 'ok']],
['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 11, 0], [2, 3.7, 0], [3, 22, 0], [4, 7.4, 60], [5, 150, 10]], [5, 326, 11, True], 13],
[2, 95, 'ok']],
['regression: duration rounding (partial repair)',
[[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
['control 2',
[[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
45],
[5, 174, 'ok']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 11, 60], [2, 150, 30], [3, 7.4, 0], [4, 3.7, 0], [5, 7.4, 60]], [10, 35, 3.7, False], 25],
[3, 188, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 22, 120], [2, 7.4, 30]], [45, 240, 3.7, False], 22], [2, 760, 'late']],
['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
[4, 33, 'ok']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding',
[[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
[2, 200, 'ok']],
['regression: duration rounding (partial repair)',
[[[1, 7.4, 0], [2, 150, 0]], [5, 263, 11, True], 56], [1, 97, 'ok']],
['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
[1, 790, 'late']]],
[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
[1, 300, 'ok']],
['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
['regression: duration rounding', [[[1, 3.7, 0]], [45, 358, 3.7, False], 15], [1, 745, 'late']],
['regression: duration rounding (partial repair)',
[[[1, 50, 0], [2, 50, 30]], [10, 89, 7.4, True], 45], [1, 57, 'ok']],
['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, 'ok']]]]
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: 22 kW AC charger | [1, 60, 'ok'] | [1, 60, 'ok'] | Passed |
| boundary: finish exactly at departure | [1, 300, 'ok'] | [1, 300, 'ok'] | Passed |
| boundary: only DC and no DC support | None | None | Passed |
| regression: duration rounding | [2, 445, 'late'] | [2, 445, 'late'] | Passed |
| regression: duration rounding (partial repair) | [1, 72, 'ok'] | [1, 72, 'ok'] | Passed |
| control 1 | [1, 88, 'ok'] | [1, 88, 'ok'] | Passed |
| control 2 | None | None | Passed |
SHA-256 / b3bbcec48668d10f9e444c8fff75e4914b8882fd9e4e257811b5a15f4724a25d
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.615739+00:00.
Case digest / 1685ea2cc078e610e8d69974b7df4b842f9340fab27d257c954273573998ada6