FAILURE MAP
← Case archive

FA-93286 / EV charging session scheduling / Open access

Arrival charger matching: late fallback ranking · case 01

When nothing can finish in time the vehicle is sent to the slowest charger.

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

ROOT CAUSE

The late fallback reuses the lowest-power ranking instead of earliest finish.

VERIFIED REPAIR

Pick the earliest finish, ties by id.

Unsuccessful approach: Breaking finish ties by highest power instead of id differs from the contract.

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 + 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)
    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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 10], [2, 3.7, 10], [3, 7.4, 60], [4, 3.7, 10], [5, 22, 60]], [45, 74, 7.4, False], 19],
   [1, 384, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 3.7, 10], [2, 3.7, 0], [3, 3.7, 0], [4, 150, 30]], [45, 37, 7.4, True], 24],
   [4, 48, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 7.4, 10], [3, 150, 60], [4, 3.7, 30], [5, 7.4, 60]], [45, 336, 11, False], 2],
   [1, 367, '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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 0], [2, 7.4, 30], [3, 50, 60], [4, 3.7, 30]], [30, 129, 7.4, False], 26],
   [1, 270, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 3.7, 60], [3, 3.7, 0], [4, 7.4, 0]], [30, 244, 11, True], 29],
   [1, 273, 'late']],
  ['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 fixtureActualExpectedOutcome
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 supportNoneNonePassed
regression: late tie on finish time[1, 82, 'late'][1, 82, 'late']Passed
regression: late fallback ranking[2, 749, 'late'][1, 384, 'late']Failed
control 1[1, 88, 'ok'][1, 88, 'ok']Passed
control 2NoneNonePassed

SHA-256 / 57f087936394a9512eeacf79be9f4b8f99798a0a59f87181e35a63ab41def6b2

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 * 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[0]))
    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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 10], [2, 3.7, 10], [3, 7.4, 60], [4, 3.7, 10], [5, 22, 60]], [45, 74, 7.4, False], 19],
   [1, 384, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 3.7, 10], [2, 3.7, 0], [3, 3.7, 0], [4, 150, 30]], [45, 37, 7.4, True], 24],
   [4, 48, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 7.4, 10], [3, 150, 60], [4, 3.7, 30], [5, 7.4, 60]], [45, 336, 11, False], 2],
   [1, 367, '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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 0], [2, 7.4, 30], [3, 50, 60], [4, 3.7, 30]], [30, 129, 7.4, False], 26],
   [1, 270, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 3.7, 60], [3, 3.7, 0], [4, 7.4, 0]], [30, 244, 11, True], 29],
   [1, 273, 'late']],
  ['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 fixtureActualExpectedOutcome
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 supportNoneNonePassed
regression: late tie on finish time[2, 82, 'late'][1, 82, 'late']Failed
regression: late fallback ranking[1, 384, 'late'][1, 384, 'late']Passed
control 1[1, 88, 'ok'][1, 88, 'ok']Passed
control 2NoneNonePassed

SHA-256 / 108a067c014471564047cf4c26147db8af9b6ac1119b0e675c7b6f89b0c4eaa4

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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 10], [2, 3.7, 10], [3, 7.4, 60], [4, 3.7, 10], [5, 22, 60]], [45, 74, 7.4, False], 19],
   [1, 384, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 3.7, 10], [2, 3.7, 0], [3, 3.7, 0], [4, 150, 30]], [45, 37, 7.4, True], 24],
   [4, 48, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 7.4, 10], [3, 150, 60], [4, 3.7, 30], [5, 7.4, 60]], [45, 336, 11, False], 2],
   [1, 367, '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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 0], [2, 7.4, 30], [3, 50, 60], [4, 3.7, 30]], [30, 129, 7.4, False], 26],
   [1, 270, 'late']],
  ['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: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 3.7, 60], [3, 3.7, 0], [4, 7.4, 0]], [30, 244, 11, True], 29],
   [1, 273, 'late']],
  ['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 fixtureActualExpectedOutcome
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 supportNoneNonePassed
regression: late tie on finish time[1, 82, 'late'][1, 82, 'late']Passed
regression: late fallback ranking[1, 384, 'late'][1, 384, 'late']Passed
control 1[1, 88, 'ok'][1, 88, 'ok']Passed
control 2NoneNonePassed

SHA-256 / 8f26612ae93e3e91730b07d57aee9dbbd2688398a5174de0d580842af320985e

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.730985+00:00.

Case digest / db93336c13a7fbd7aa9c329e0d1b66233bf1fcd466585f0632484d55f3a90064