FAILURE MAP
← Case archive

FA-93011 / EV charging session scheduling / Open access

PV surplus following with hysteresis: counter reset at start · case 01

Charging stops shortly after starting even though the sun never dipped.

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

ROOT CAUSE

The start-qualification streak is not cleared, so it is reused as a stop streak.

THE FAILURE

The start-qualification streak is not cleared, so it is reused as a stop streak.

Unsuccessful approach: Resetting to 1 still pre-loads the stop streak by one sample.

Case contract

samples are per-minute PV surplus watts. Charging starts on the sample completing start_delay consecutive samples >= start_w, and stops on the sample completing stop_delay consecutive samples < stop_w; counters reset on each transition and on any interrupting sample. While charging the power is the surplus clamped to [1380, 3680] W, else 0. Return [powers, number of starts].

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(samples, start_w, stop_w, start_delay, stop_delay):
    on = False
    run = 0
    out = []
    starts = 0
    for s in samples:
        if not on:
            run = run + 1 if s >= start_w else 0
            if run >= start_delay:
                on = True
                starts += 1
        else:
            run = run + 1 if s < stop_w else 0
            if run >= stop_delay:
                on = False
                run = 0
        out.append(min(max(s, 1380), 3680) if on else 0)
    return [out, starts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[0, 0, 0, 2234, 3394, 627, 3397, 1759, 0, 0], 1400, 1000, 2, 3],
   [[0, 0, 0, 0, 3394, 1380, 3397, 1759, 1380, 1380], 1]],
  ['regression: counter reset at start (partial repair)',
   [[1618, 3368, 2209, 511, 2948, 3903], 2000, 1000, 2, 2], [[0, 0, 2209, 1380, 2948, 3680], 1]],
  ['control 1', [[1632, 1402, 0, 1011, 1056, 2204, 0, 0, 0, 0, 0, 2059, 0], 1400, 1400, 3, 1],
   [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0]],
  ['control 2',
   [[5160, 1495, 4246, 2693, 3633, 943, 5200, 3902, 2959, 1685, 2602], 1400, 800, 3, 2],
   [[0, 0, 3680, 2693, 3633, 1380, 3680, 3680, 2959, 1685, 2602], 1]]],
 [['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[1283, 1515, 791, 674, 0, 1870, 4247, 28, 63, 4379, 4026, 478, 2145, 2164, 68, 3763], 1400,
    1400, 1, 2],
   [[0, 1515, 1380, 0, 0, 1870, 3680, 1380, 0, 3680, 3680, 1380, 2145, 2164, 1380, 3680], 3]],
  ['regression: counter reset at start (partial repair)',
   [[0, 1856, 308, 1830, 1153, 1726, 988, 1225, 2991, 0, 0, 1512, 514, 0], 2500, 1000, 1, 2],
   [[0, 0, 0, 0, 0, 0, 0, 0, 2991, 1380, 0, 0, 0, 0], 1]],
  ['control 1', [[2491, 6454, 5581, 5791, 7280, 4927, 5591, 6410], 1400, 1000, 1, 1],
   [[2491, 3680, 3680, 3680, 3680, 3680, 3680, 3680], 1]],
  ['control 2', [[3110, 2987, 3876, 6142, 2422, 5132, 2143, 6887, 4896, 4908], 2000, 1000, 3, 2],
   [[0, 0, 3680, 3680, 2422, 3680, 2143, 3680, 3680, 3680], 1]]],
 [['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[2567, 1353, 0, 2085, 0, 0, 116, 324, 1725, 810], 1400, 1400, 1, 2],
   [[2567, 1380, 0, 2085, 1380, 0, 0, 0, 1725, 1380], 3]],
  ['regression: counter reset at start (partial repair)',
   [[0, 648, 863, 1974, 0, 469, 446, 1914, 0, 1549, 0, 2215, 0, 0], 1400, 1400, 1, 3],
   [[0, 0, 0, 1974, 1380, 1380, 0, 1914, 1380, 1549, 1380, 2215, 1380, 1380], 2]],
  ['control 1', [[5534, 5945, 5877, 6991, 3580, 5525, 6786, 5530, 2720, 6795], 2000, 800, 1, 1],
   [[3680, 3680, 3680, 3680, 3580, 3680, 3680, 3680, 2720, 3680], 1]],
  ['control 2',
   [[3289, 1459, 5221, 3468, 1247, 4575, 1243, 1923, 2108, 3912, 3417, 2756, 1675, 1378, 5487],
    2000, 1400, 3, 2],
   [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3417, 2756, 1675, 1380, 3680], 1]]],
 [['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[818, 2003, 0, 1823, 0, 0, 1074, 2432, 0, 3612, 0, 2403, 0, 1431, 3028], 2000, 800, 1, 2],
   [[0, 2003, 1380, 1823, 1380, 0, 0, 2432, 1380, 3612, 1380, 2403, 1380, 1431, 3028], 2]],
  ['regression: counter reset at start (partial repair)',
   [[0, 0, 1767, 2146, 0, 0, 0, 0, 2178], 2000, 1000, 1, 3],
   [[0, 0, 0, 2146, 1380, 1380, 0, 0, 2178], 2]],
  ['control 1', [[2567, 1353, 0, 2085, 0, 0, 116, 324, 1725, 810], 1400, 1400, 1, 2],
   [[2567, 1380, 0, 2085, 1380, 0, 0, 0, 1725, 1380], 3]],
  ['control 2',
   [[3612, 3481, 805, 1117, 2494, 200, 653, 4188, 280, 752, 4261, 4604], 1400, 1000, 1, 1],
   [[3612, 3481, 0, 0, 2494, 0, 0, 3680, 0, 0, 3680, 3680], 4]]],
 [['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[391, 1113, 0, 2478, 0, 0, 0, 0, 0, 0, 2459], 2000, 800, 1, 3],
   [[0, 0, 0, 2478, 1380, 1380, 0, 0, 0, 0, 2459], 2]],
  ['regression: counter reset at start (partial repair)',
   [[1603, 1297, 804, 1832, 1636, 2617, 676, 607, 1830, 1479], 2000, 800, 1, 2],
   [[0, 0, 0, 0, 0, 2617, 1380, 0, 0, 0], 1]],
  ['control 1', [[1756, 0, 1045, 0, 1278, 3133, 2829, 2511, 2201, 3176, 1898], 2000, 1400, 3, 3],
   [[0, 0, 0, 0, 0, 0, 0, 2511, 2201, 3176, 1898], 1]],
  ['control 2', [[3627, 2896, 3017, 2824, 6221, 3547, 1687, 5138], 1400, 800, 2, 2],
   [[0, 2896, 3017, 2824, 3680, 3547, 1687, 3680], 1]]]]
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: surplus exactly at start threshold[[0, 2000, 2000, 0], 1][[0, 2000, 2000, 0], 1]Passed
boundary: never enough sun[[0, 0, 0, 0, 0, 0], 0][[0, 0, 0, 0, 0, 0], 0]Passed
boundary: cloud dip shorter than stop delay[[3000, 3000, 1380, 3000, 1380, 0, 3000], 2][[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]Passed
regression: counter reset at start[[0, 0, 0, 0, 3394, 0, 0, 1759, 0, 0], 2][[0, 0, 0, 0, 3394, 1380, 3397, 1759, 1380, 1380], 1]Failed
regression: counter reset at start (partial repair)[[0, 0, 2209, 0, 0, 3680], 2][[0, 0, 2209, 1380, 2948, 3680], 1]Failed
control 1[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0][[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0]Passed
control 2[[0, 0, 3680, 2693, 3633, 1380, 3680, 3680, 2959, 1685, 2602], 1][[0, 0, 3680, 2693, 3633, 1380, 3680, 3680, 2959, 1685, 2602], 1]Passed

SHA-256 / f4a1fc1c56c8f7c40d455ff94eba98379509f708e9f24ef271fd708e85262a72

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(samples, start_w, stop_w, start_delay, stop_delay):
    on = False
    run = 0
    out = []
    starts = 0
    for s in samples:
        if not on:
            run = run + 1 if s >= start_w else 0
            if run >= start_delay:
                on = True
                starts += 1
                run = 1
        else:
            run = run + 1 if s < stop_w else 0
            if run >= stop_delay:
                on = False
                run = 0
        out.append(min(max(s, 1380), 3680) if on else 0)
    return [out, starts]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[0, 0, 0, 2234, 3394, 627, 3397, 1759, 0, 0], 1400, 1000, 2, 3],
   [[0, 0, 0, 0, 3394, 1380, 3397, 1759, 1380, 1380], 1]],
  ['regression: counter reset at start (partial repair)',
   [[1618, 3368, 2209, 511, 2948, 3903], 2000, 1000, 2, 2], [[0, 0, 2209, 1380, 2948, 3680], 1]],
  ['control 1', [[1632, 1402, 0, 1011, 1056, 2204, 0, 0, 0, 0, 0, 2059, 0], 1400, 1400, 3, 1],
   [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0]],
  ['control 2',
   [[5160, 1495, 4246, 2693, 3633, 943, 5200, 3902, 2959, 1685, 2602], 1400, 800, 3, 2],
   [[0, 0, 3680, 2693, 3633, 1380, 3680, 3680, 2959, 1685, 2602], 1]]],
 [['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[1283, 1515, 791, 674, 0, 1870, 4247, 28, 63, 4379, 4026, 478, 2145, 2164, 68, 3763], 1400,
    1400, 1, 2],
   [[0, 1515, 1380, 0, 0, 1870, 3680, 1380, 0, 3680, 3680, 1380, 2145, 2164, 1380, 3680], 3]],
  ['regression: counter reset at start (partial repair)',
   [[0, 1856, 308, 1830, 1153, 1726, 988, 1225, 2991, 0, 0, 1512, 514, 0], 2500, 1000, 1, 2],
   [[0, 0, 0, 0, 0, 0, 0, 0, 2991, 1380, 0, 0, 0, 0], 1]],
  ['control 1', [[2491, 6454, 5581, 5791, 7280, 4927, 5591, 6410], 1400, 1000, 1, 1],
   [[2491, 3680, 3680, 3680, 3680, 3680, 3680, 3680], 1]],
  ['control 2', [[3110, 2987, 3876, 6142, 2422, 5132, 2143, 6887, 4896, 4908], 2000, 1000, 3, 2],
   [[0, 0, 3680, 3680, 2422, 3680, 2143, 3680, 3680, 3680], 1]]],
 [['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[2567, 1353, 0, 2085, 0, 0, 116, 324, 1725, 810], 1400, 1400, 1, 2],
   [[2567, 1380, 0, 2085, 1380, 0, 0, 0, 1725, 1380], 3]],
  ['regression: counter reset at start (partial repair)',
   [[0, 648, 863, 1974, 0, 469, 446, 1914, 0, 1549, 0, 2215, 0, 0], 1400, 1400, 1, 3],
   [[0, 0, 0, 1974, 1380, 1380, 0, 1914, 1380, 1549, 1380, 2215, 1380, 1380], 2]],
  ['control 1', [[5534, 5945, 5877, 6991, 3580, 5525, 6786, 5530, 2720, 6795], 2000, 800, 1, 1],
   [[3680, 3680, 3680, 3680, 3580, 3680, 3680, 3680, 2720, 3680], 1]],
  ['control 2',
   [[3289, 1459, 5221, 3468, 1247, 4575, 1243, 1923, 2108, 3912, 3417, 2756, 1675, 1378, 5487],
    2000, 1400, 3, 2],
   [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3417, 2756, 1675, 1380, 3680], 1]]],
 [['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[818, 2003, 0, 1823, 0, 0, 1074, 2432, 0, 3612, 0, 2403, 0, 1431, 3028], 2000, 800, 1, 2],
   [[0, 2003, 1380, 1823, 1380, 0, 0, 2432, 1380, 3612, 1380, 2403, 1380, 1431, 3028], 2]],
  ['regression: counter reset at start (partial repair)',
   [[0, 0, 1767, 2146, 0, 0, 0, 0, 2178], 2000, 1000, 1, 3],
   [[0, 0, 0, 2146, 1380, 1380, 0, 0, 2178], 2]],
  ['control 1', [[2567, 1353, 0, 2085, 0, 0, 116, 324, 1725, 810], 1400, 1400, 1, 2],
   [[2567, 1380, 0, 2085, 1380, 0, 0, 0, 1725, 1380], 3]],
  ['control 2',
   [[3612, 3481, 805, 1117, 2494, 200, 653, 4188, 280, 752, 4261, 4604], 1400, 1000, 1, 1],
   [[3612, 3481, 0, 0, 2494, 0, 0, 3680, 0, 0, 3680, 3680], 4]]],
 [['boundary: surplus exactly at start threshold', [[2000, 2000, 2000, 500], 2000, 1000, 2, 1],
   [[0, 2000, 2000, 0], 1]],
  ['boundary: never enough sun', [[100, 200, 300, 400, 500, 600], 1400, 800, 1, 1],
   [[0, 0, 0, 0, 0, 0], 0]],
  ['boundary: cloud dip shorter than stop delay',
   [[3000, 3000, 500, 3000, 500, 500, 3000], 1400, 800, 1, 2],
   [[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]],
  ['regression: counter reset at start',
   [[391, 1113, 0, 2478, 0, 0, 0, 0, 0, 0, 2459], 2000, 800, 1, 3],
   [[0, 0, 0, 2478, 1380, 1380, 0, 0, 0, 0, 2459], 2]],
  ['regression: counter reset at start (partial repair)',
   [[1603, 1297, 804, 1832, 1636, 2617, 676, 607, 1830, 1479], 2000, 800, 1, 2],
   [[0, 0, 0, 0, 0, 2617, 1380, 0, 0, 0], 1]],
  ['control 1', [[1756, 0, 1045, 0, 1278, 3133, 2829, 2511, 2201, 3176, 1898], 2000, 1400, 3, 3],
   [[0, 0, 0, 0, 0, 0, 0, 2511, 2201, 3176, 1898], 1]],
  ['control 2', [[3627, 2896, 3017, 2824, 6221, 3547, 1687, 5138], 1400, 800, 2, 2],
   [[0, 2896, 3017, 2824, 3680, 3547, 1687, 3680], 1]]]]
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: surplus exactly at start threshold[[0, 2000, 2000, 0], 1][[0, 2000, 2000, 0], 1]Passed
boundary: never enough sun[[0, 0, 0, 0, 0, 0], 0][[0, 0, 0, 0, 0, 0], 0]Passed
boundary: cloud dip shorter than stop delay[[3000, 3000, 1380, 3000, 1380, 0, 3000], 2][[3000, 3000, 1380, 3000, 1380, 0, 3000], 2]Passed
regression: counter reset at start[[0, 0, 0, 0, 3394, 1380, 3397, 1759, 1380, 1380], 1][[0, 0, 0, 0, 3394, 1380, 3397, 1759, 1380, 1380], 1]Passed
regression: counter reset at start (partial repair)[[0, 0, 2209, 0, 0, 3680], 2][[0, 0, 2209, 1380, 2948, 3680], 1]Failed
control 1[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0][[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0]Passed
control 2[[0, 0, 3680, 2693, 3633, 1380, 3680, 3680, 2959, 1685, 2602], 1][[0, 0, 3680, 2693, 3633, 1380, 3680, 3680, 2959, 1685, 2602], 1]Passed

SHA-256 / ef1337338b1f1c2c01dc57af55cf266d9d25dc273342f89b7cd63b79d682f185

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

Case digest / 1207536d8bc2f1284531800081fe98f5f75775d644722bde6c07fdc93c87458a