FAILURE MAP
← Case archive

FA-93336 / EV charging session scheduling / Open access

Site power profile from charge plans: closing zero point · case 01

Profiles that already end at zero get a duplicate zero change point.

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

ROOT CAUSE

The closing zero is appended unconditionally.

VERIFIED REPAIR

Append the closing zero only when the last level is not already zero.

Unsuccessful approach: Closing one minute after the last breakpoint treats interval ends as inclusive.

Case contract

plan holds [start, end, kw] charging intervals ([start, end), zero-length ignored). Build the site profile as change points [[t, total_kw]] over the interval breakpoints, merging equal consecutive levels, and close with [last breakpoint, 0] unless the profile already ends at 0. Also return the start points of segments whose total exceeds site_max. Return [profile, overloads].

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(plan, site_max):
    pts = sorted({t for s, e, _ in plan for t in (s, e) if e > s})
    out = []
    over = []
    for a, b in zip(pts, pts[1:]):
        kw = sum(k for s, e, k in plan if s <= a and b <= e)
        if out and out[-1][1] == kw:
            continue
        out.append([a, kw])
        if kw > site_max:
            over.append(a)
    if pts:
        out.append([pts[-1], 0])
    return [out, over]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[4, 14, 11], [0, 2, 0], [16, 18, 0]], 11],
   [[[0, 0], [4, 11], [14, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[23, 28, 11], [8, 13, 0], [15, 20, 0], [24, 24, 4], [16, 16, 0]], 15],
   [[[8, 0], [23, 11], [28, 0]], []]],
  ['control 1', [[[23, 38, 0], [0, 5, 4], [18, 18, 11]], 15], [[[0, 4], [5, 0]], []]],
  ['control 2', [[[6, 8, 7]], 22], [[[6, 7], [8, 0]], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[11, 13, 4], [13, 28, 0], [17, 22, 0], [9, 11, 4]], 22],
   [[[9, 4], [13, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[11, 16, 0], [11, 16, 7], [19, 21, 11], [8, 18, 11], [16, 16, 0]], 15],
   [[[8, 11], [11, 18], [16, 11], [18, 0], [19, 11], [21, 0]], [11]]],
  ['control 1', [[[12, 12, 4], [7, 12, 11], [27, 37, 4]], 22],
   [[[7, 11], [12, 0], [27, 4], [37, 0]], []]],
  ['control 2', [[], 18], [[], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[9, 11, 0], [4, 4, 11]], 18], [[[9, 0]], []]],
  ['regression: closing zero point (partial repair)', [[[2, 17, 7]], 11], [[[2, 7], [17, 0]], []]],
  ['control 1', [[[21, 31, 11], [23, 33, 7], [0, 10, 7], [25, 25, 0], [28, 43, 7]], 15],
   [[[0, 7], [10, 0], [21, 11], [23, 18], [28, 25], [31, 14], [33, 7], [43, 0]], [23, 28]]],
  ['control 2', [[[17, 27, 11], [22, 37, 11], [10, 10, 7], [19, 29, 11]], 7],
   [[[17, 11], [19, 22], [22, 33], [27, 22], [29, 11], [37, 0]], [17, 19, 22, 27, 29]]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[14, 14, 11], [25, 40, 0], [5, 20, 7]], 15],
   [[[5, 7], [20, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[10, 12, 7], [3, 8, 0], [29, 39, 11], [6, 11, 7], [13, 23, 7]], 11],
   [[[3, 0], [6, 7], [10, 14], [11, 7], [12, 0], [13, 7], [23, 0], [29, 11], [39, 0]], [10]]],
  ['control 1', [[], 22], [[], []]], ['control 2', [[], 22], [[], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[30, 32, 0], [6, 16, 11], [18, 28, 7]], 11],
   [[[6, 11], [16, 0], [18, 7], [28, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[15, 25, 11], [27, 27, 0], [26, 26, 11]], 22], [[[15, 11], [25, 0]], []]],
  ['control 1', [[[8, 8, 11], [0, 0, 11], [7, 17, 7]], 7], [[[7, 7], [17, 0]], []]],
  ['control 2', [[[22, 22, 11], [5, 5, 4], [10, 15, 11], [22, 32, 11], [14, 14, 0]], 11],
   [[[10, 11], [15, 0], [22, 11], [32, 0]], []]]]]
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: zero-length interval before plan[[[10, 11], [20, 0]], []][[[10, 11], [20, 0]], []]Passed
boundary: exact site limit[[[0, 11], [10, 0]], []][[[0, 11], [10, 0]], []]Passed
boundary: empty plan[[], []][[], []]Passed
regression: closing zero point[[[0, 0], [4, 11], [14, 0], [18, 0]], []][[[0, 0], [4, 11], [14, 0]], []]Failed
regression: closing zero point (partial repair)[[[8, 0], [23, 11], [28, 0]], []][[[8, 0], [23, 11], [28, 0]], []]Passed
control 1[[[0, 4], [5, 0], [38, 0]], []][[[0, 4], [5, 0]], []]Failed
control 2[[[6, 7], [8, 0]], []][[[6, 7], [8, 0]], []]Passed

SHA-256 / 09932fb04509b836cf2c47975f5158f104ce10a89c4cf92780177d260b6796f6

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(plan, site_max):
    pts = sorted({t for s, e, _ in plan for t in (s, e) if e > s})
    out = []
    over = []
    for a, b in zip(pts, pts[1:]):
        kw = sum(k for s, e, k in plan if s <= a and b <= e)
        if out and out[-1][1] == kw:
            continue
        out.append([a, kw])
        if kw > site_max:
            over.append(a)
    if pts:
        if not out or out[-1][1] != 0:
            out.append([pts[-1] + 1, 0])
    return [out, over]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[4, 14, 11], [0, 2, 0], [16, 18, 0]], 11],
   [[[0, 0], [4, 11], [14, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[23, 28, 11], [8, 13, 0], [15, 20, 0], [24, 24, 4], [16, 16, 0]], 15],
   [[[8, 0], [23, 11], [28, 0]], []]],
  ['control 1', [[[23, 38, 0], [0, 5, 4], [18, 18, 11]], 15], [[[0, 4], [5, 0]], []]],
  ['control 2', [[[6, 8, 7]], 22], [[[6, 7], [8, 0]], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[11, 13, 4], [13, 28, 0], [17, 22, 0], [9, 11, 4]], 22],
   [[[9, 4], [13, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[11, 16, 0], [11, 16, 7], [19, 21, 11], [8, 18, 11], [16, 16, 0]], 15],
   [[[8, 11], [11, 18], [16, 11], [18, 0], [19, 11], [21, 0]], [11]]],
  ['control 1', [[[12, 12, 4], [7, 12, 11], [27, 37, 4]], 22],
   [[[7, 11], [12, 0], [27, 4], [37, 0]], []]],
  ['control 2', [[], 18], [[], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[9, 11, 0], [4, 4, 11]], 18], [[[9, 0]], []]],
  ['regression: closing zero point (partial repair)', [[[2, 17, 7]], 11], [[[2, 7], [17, 0]], []]],
  ['control 1', [[[21, 31, 11], [23, 33, 7], [0, 10, 7], [25, 25, 0], [28, 43, 7]], 15],
   [[[0, 7], [10, 0], [21, 11], [23, 18], [28, 25], [31, 14], [33, 7], [43, 0]], [23, 28]]],
  ['control 2', [[[17, 27, 11], [22, 37, 11], [10, 10, 7], [19, 29, 11]], 7],
   [[[17, 11], [19, 22], [22, 33], [27, 22], [29, 11], [37, 0]], [17, 19, 22, 27, 29]]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[14, 14, 11], [25, 40, 0], [5, 20, 7]], 15],
   [[[5, 7], [20, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[10, 12, 7], [3, 8, 0], [29, 39, 11], [6, 11, 7], [13, 23, 7]], 11],
   [[[3, 0], [6, 7], [10, 14], [11, 7], [12, 0], [13, 7], [23, 0], [29, 11], [39, 0]], [10]]],
  ['control 1', [[], 22], [[], []]], ['control 2', [[], 22], [[], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[30, 32, 0], [6, 16, 11], [18, 28, 7]], 11],
   [[[6, 11], [16, 0], [18, 7], [28, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[15, 25, 11], [27, 27, 0], [26, 26, 11]], 22], [[[15, 11], [25, 0]], []]],
  ['control 1', [[[8, 8, 11], [0, 0, 11], [7, 17, 7]], 7], [[[7, 7], [17, 0]], []]],
  ['control 2', [[[22, 22, 11], [5, 5, 4], [10, 15, 11], [22, 32, 11], [14, 14, 0]], 11],
   [[[10, 11], [15, 0], [22, 11], [32, 0]], []]]]]
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: zero-length interval before plan[[[10, 11], [21, 0]], []][[[10, 11], [20, 0]], []]Failed
boundary: exact site limit[[[0, 11], [11, 0]], []][[[0, 11], [10, 0]], []]Failed
boundary: empty plan[[], []][[], []]Passed
regression: closing zero point[[[0, 0], [4, 11], [14, 0]], []][[[0, 0], [4, 11], [14, 0]], []]Passed
regression: closing zero point (partial repair)[[[8, 0], [23, 11], [29, 0]], []][[[8, 0], [23, 11], [28, 0]], []]Failed
control 1[[[0, 4], [5, 0]], []][[[0, 4], [5, 0]], []]Passed
control 2[[[6, 7], [9, 0]], []][[[6, 7], [8, 0]], []]Failed

SHA-256 / 9896f077d402e33c47e74b613e1db492633631ff0f0823e954ab8ea9a19bc17e

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(plan, site_max):
    pts = sorted({t for s, e, _ in plan for t in (s, e) if e > s})
    out = []
    over = []
    for a, b in zip(pts, pts[1:]):
        kw = sum(k for s, e, k in plan if s <= a and b <= e)
        if out and out[-1][1] == kw:
            continue
        out.append([a, kw])
        if kw > site_max:
            over.append(a)
    if pts:
        if not out or out[-1][1] != 0:
            out.append([pts[-1], 0])
    return [out, over]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[4, 14, 11], [0, 2, 0], [16, 18, 0]], 11],
   [[[0, 0], [4, 11], [14, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[23, 28, 11], [8, 13, 0], [15, 20, 0], [24, 24, 4], [16, 16, 0]], 15],
   [[[8, 0], [23, 11], [28, 0]], []]],
  ['control 1', [[[23, 38, 0], [0, 5, 4], [18, 18, 11]], 15], [[[0, 4], [5, 0]], []]],
  ['control 2', [[[6, 8, 7]], 22], [[[6, 7], [8, 0]], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[11, 13, 4], [13, 28, 0], [17, 22, 0], [9, 11, 4]], 22],
   [[[9, 4], [13, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[11, 16, 0], [11, 16, 7], [19, 21, 11], [8, 18, 11], [16, 16, 0]], 15],
   [[[8, 11], [11, 18], [16, 11], [18, 0], [19, 11], [21, 0]], [11]]],
  ['control 1', [[[12, 12, 4], [7, 12, 11], [27, 37, 4]], 22],
   [[[7, 11], [12, 0], [27, 4], [37, 0]], []]],
  ['control 2', [[], 18], [[], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[9, 11, 0], [4, 4, 11]], 18], [[[9, 0]], []]],
  ['regression: closing zero point (partial repair)', [[[2, 17, 7]], 11], [[[2, 7], [17, 0]], []]],
  ['control 1', [[[21, 31, 11], [23, 33, 7], [0, 10, 7], [25, 25, 0], [28, 43, 7]], 15],
   [[[0, 7], [10, 0], [21, 11], [23, 18], [28, 25], [31, 14], [33, 7], [43, 0]], [23, 28]]],
  ['control 2', [[[17, 27, 11], [22, 37, 11], [10, 10, 7], [19, 29, 11]], 7],
   [[[17, 11], [19, 22], [22, 33], [27, 22], [29, 11], [37, 0]], [17, 19, 22, 27, 29]]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[14, 14, 11], [25, 40, 0], [5, 20, 7]], 15],
   [[[5, 7], [20, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[10, 12, 7], [3, 8, 0], [29, 39, 11], [6, 11, 7], [13, 23, 7]], 11],
   [[[3, 0], [6, 7], [10, 14], [11, 7], [12, 0], [13, 7], [23, 0], [29, 11], [39, 0]], [10]]],
  ['control 1', [[], 22], [[], []]], ['control 2', [[], 22], [[], []]]],
 [['boundary: zero-length interval before plan', [[[5, 5, 7], [10, 20, 11]], 11],
   [[[10, 11], [20, 0]], []]],
  ['boundary: exact site limit', [[[0, 10, 7], [0, 10, 4]], 11], [[[0, 11], [10, 0]], []]],
  ['boundary: empty plan', [[], 11], [[], []]],
  ['regression: closing zero point', [[[30, 32, 0], [6, 16, 11], [18, 28, 7]], 11],
   [[[6, 11], [16, 0], [18, 7], [28, 0]], []]],
  ['regression: closing zero point (partial repair)',
   [[[15, 25, 11], [27, 27, 0], [26, 26, 11]], 22], [[[15, 11], [25, 0]], []]],
  ['control 1', [[[8, 8, 11], [0, 0, 11], [7, 17, 7]], 7], [[[7, 7], [17, 0]], []]],
  ['control 2', [[[22, 22, 11], [5, 5, 4], [10, 15, 11], [22, 32, 11], [14, 14, 0]], 11],
   [[[10, 11], [15, 0], [22, 11], [32, 0]], []]]]]
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: zero-length interval before plan[[[10, 11], [20, 0]], []][[[10, 11], [20, 0]], []]Passed
boundary: exact site limit[[[0, 11], [10, 0]], []][[[0, 11], [10, 0]], []]Passed
boundary: empty plan[[], []][[], []]Passed
regression: closing zero point[[[0, 0], [4, 11], [14, 0]], []][[[0, 0], [4, 11], [14, 0]], []]Passed
regression: closing zero point (partial repair)[[[8, 0], [23, 11], [28, 0]], []][[[8, 0], [23, 11], [28, 0]], []]Passed
control 1[[[0, 4], [5, 0]], []][[[0, 4], [5, 0]], []]Passed
control 2[[[6, 7], [8, 0]], []][[[6, 7], [8, 0]], []]Passed

SHA-256 / 613858e55e1dd090b281242bceb63151768046c8e82932dfca7d828f917bcea3

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

Case digest / 97d6f302e715a2ac919c23a0dd66f41060fbba80fd98b5a32d9379406700cb82