FA-68236 / Traffic signal timing plans / Open access
Loop detector count and occupancy binning: occupied time is measured from vehicle arrival rather than bin start · case 01
Loop detector count and occupancy binning returns a wrong result when occupied time is measured from vehicle arrival rather than bin start.
ROOT CAUSE
The overlap subtracts the on time instead of the later of on time and bin start, over-counting later bins.
VERIFIED REPAIR
Restore the occupancy overlap rule so that the step reads `min(off, hi) - max(on, lo)`.
Unsuccessful approach: Capping duration at the interval is not an overlap and credits every bin with the whole presence.
Case contract
Input {interval s, bins, events: [[on, off]] seconds relative to period start (on may be negative), max_presence, no_activity}. A vehicle is counted in the bin of its on time if inside the period; occupied time is split across bins by overlap; occupancy percent is floor(occupied*100/interval). Status is 'stuck-on' if any presence lasts >= max_presence, 'no-activity' if there are no events and the period (bins*interval) is >= no_activity, else 'ok'. Return {counts, occ_pct, status}.
Why this case matters
Signal timing arithmetic is exact and integer or rational; a wrong rule silently produces unsafe or inefficient timing plans.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
I = x['interval']
B = x['bins']
counts = [0] * B
occ = [0] * B
status = 'ok'
for on, off in sorted(x['events']):
b = on // I
if 0 <= b < B:
counts[b] += 1
if off - on >= x['max_presence']:
status = 'stuck-on'
for k in range(B):
lo, hi = k * I, (k + 1) * I
occ[k] += max(0, min(off, hi) - on)
if not x['events'] and B * I >= x['no_activity']:
status = 'no-activity'
return {'counts': counts, 'occ_pct': [o * 100 // I for o in occ], 'status': status}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 2, 'events': [[-10, -9], [10, 50], [80, 88], [122, 127], [153, 156], [157, 197], [218, 258], [262, 267]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 4], 'occ_pct': [40, 58], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 4, 'events': [[151, 153], [50, 58], [109, 111], [93, 101], [175, 178], [191, 199], [-1, 39]], 'max_presence': 100, 'no_activity': 240}, {'counts': [3, 3, 0, 0], 'occ_pct': [47, 10, 0, 0], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 240}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[-1, 0], [59, 424], [-18, -10], [23, 31]], 'max_presence': 240, 'no_activity': 60}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [57, 100, 100, 53, 0], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-8, 0], [13, 15], [45, 53], [58, 63], [68, 71], [92, 93]], 'max_presence': 240, 'no_activity': 240}, {'counts': [3, 2], 'occ_pct': [20, 11], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[5, 45], [60, 61], [96, 99], [120, 384], [387, 392]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 1, 1], 'occ_pct': [83, 50, 3, 10], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 5, 'events': [[-9, -4], [2, 214], [235, 237]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 0, 0, 0], 'occ_pct': [98, 80, 0, 0, 0], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'})], [({'interval': 120, 'bins': 3, 'events': [[-5, -2], [5, 7]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [1, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 5, 'events': [[85, 86], [8, 48]], 'max_presence': 180, 'no_activity': 600}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [34, 0, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'})], [({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[10, 150], [170, 172], [177, 217]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 0], 'occ_pct': [83, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 2, 'events': [[8, 16], [26, 34], [55, 95], [97, 137], [160, 162], [165, 504], [524, 532], [547, 550]], 'max_presence': 240, 'no_activity': 120}, {'counts': [2, 1], 'occ_pct': [40, 30], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 3, 'events': [[-1, 0]], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check('timing oracle' + ' %d' % i, 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 |
|---|---|---|---|
| timing oracle 0 | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 200, 300, 400], 'status': 'stuck-on'} | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'} | Failed |
| timing oracle 1 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 2 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'counts': [2, 4], 'occ_pct': [40, 99], 'status': 'ok'} | {'counts': [2, 4], 'occ_pct': [40, 58], 'status': 'ok'} | Failed |
| timing oracle 4 | {'counts': [1, 1], 'occ_pct': [16, 23], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Failed |
| timing oracle 5 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'} | Passed |
| timing oracle 6 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 7 | {'counts': [3, 3, 0, 0], 'occ_pct': [48, 59, 59, 59], 'status': 'ok'} | {'counts': [3, 3, 0, 0], 'occ_pct': [47, 10, 0, 0], 'status': 'ok'} | Failed |
SHA-256 / 3bf26ef46c567693ccb9498293941a5428195102e91973299f1f9d19f18f1376
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
I = x['interval']
B = x['bins']
counts = [0] * B
occ = [0] * B
status = 'ok'
for on, off in sorted(x['events']):
b = on // I
if 0 <= b < B:
counts[b] += 1
if off - on >= x['max_presence']:
status = 'stuck-on'
for k in range(B):
lo, hi = k * I, (k + 1) * I
occ[k] += max(0, min(off - on, I))
if not x['events'] and B * I >= x['no_activity']:
status = 'no-activity'
return {'counts': counts, 'occ_pct': [o * 100 // I for o in occ], 'status': status}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 2, 'events': [[-10, -9], [10, 50], [80, 88], [122, 127], [153, 156], [157, 197], [218, 258], [262, 267]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 4], 'occ_pct': [40, 58], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 4, 'events': [[151, 153], [50, 58], [109, 111], [93, 101], [175, 178], [191, 199], [-1, 39]], 'max_presence': 100, 'no_activity': 240}, {'counts': [3, 3, 0, 0], 'occ_pct': [47, 10, 0, 0], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 240}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[-1, 0], [59, 424], [-18, -10], [23, 31]], 'max_presence': 240, 'no_activity': 60}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [57, 100, 100, 53, 0], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-8, 0], [13, 15], [45, 53], [58, 63], [68, 71], [92, 93]], 'max_presence': 240, 'no_activity': 240}, {'counts': [3, 2], 'occ_pct': [20, 11], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[5, 45], [60, 61], [96, 99], [120, 384], [387, 392]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 1, 1], 'occ_pct': [83, 50, 3, 10], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 5, 'events': [[-9, -4], [2, 214], [235, 237]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 0, 0, 0], 'occ_pct': [98, 80, 0, 0, 0], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'})], [({'interval': 120, 'bins': 3, 'events': [[-5, -2], [5, 7]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [1, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 5, 'events': [[85, 86], [8, 48]], 'max_presence': 180, 'no_activity': 600}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [34, 0, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'})], [({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[10, 150], [170, 172], [177, 217]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 0], 'occ_pct': [83, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 2, 'events': [[8, 16], [26, 34], [55, 95], [97, 137], [160, 162], [165, 504], [524, 532], [547, 550]], 'max_presence': 240, 'no_activity': 120}, {'counts': [2, 1], 'occ_pct': [40, 30], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 3, 'events': [[-1, 0]], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check('timing oracle' + ' %d' % i, 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 |
|---|---|---|---|
| timing oracle 0 | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'} | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'} | Passed |
| timing oracle 1 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 2 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'counts': [2, 4], 'occ_pct': [118, 118], 'status': 'ok'} | {'counts': [2, 4], 'occ_pct': [40, 58], 'status': 'ok'} | Failed |
| timing oracle 4 | {'counts': [1, 1], 'occ_pct': [23, 23], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Failed |
| timing oracle 5 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'} | Passed |
| timing oracle 6 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 7 | {'counts': [3, 3, 0, 0], 'occ_pct': [59, 59, 59, 59], 'status': 'ok'} | {'counts': [3, 3, 0, 0], 'occ_pct': [47, 10, 0, 0], 'status': 'ok'} | Failed |
SHA-256 / 497beffb6c6894183f3dd2965b9fa16acacf6e06fd9e0e205c7cb3fe8a7dbaa9
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
I = x['interval']
B = x['bins']
counts = [0] * B
occ = [0] * B
status = 'ok'
for on, off in sorted(x['events']):
b = on // I
if 0 <= b < B:
counts[b] += 1
if off - on >= x['max_presence']:
status = 'stuck-on'
for k in range(B):
lo, hi = k * I, (k + 1) * I
occ[k] += max(0, min(off, hi) - max(on, lo))
if not x['events'] and B * I >= x['no_activity']:
status = 'no-activity'
return {'counts': counts, 'occ_pct': [o * 100 // I for o in occ], 'status': status}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 2, 'events': [[-10, -9], [10, 50], [80, 88], [122, 127], [153, 156], [157, 197], [218, 258], [262, 267]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 4], 'occ_pct': [40, 58], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 4, 'events': [[151, 153], [50, 58], [109, 111], [93, 101], [175, 178], [191, 199], [-1, 39]], 'max_presence': 100, 'no_activity': 240}, {'counts': [3, 3, 0, 0], 'occ_pct': [47, 10, 0, 0], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 240}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[-1, 0], [59, 424], [-18, -10], [23, 31]], 'max_presence': 240, 'no_activity': 60}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [57, 100, 100, 53, 0], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-8, 0], [13, 15], [45, 53], [58, 63], [68, 71], [92, 93]], 'max_presence': 240, 'no_activity': 240}, {'counts': [3, 2], 'occ_pct': [20, 11], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[5, 45], [60, 61], [96, 99], [120, 384], [387, 392]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 1, 1], 'occ_pct': [83, 50, 3, 10], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 5, 'events': [[-9, -4], [2, 214], [235, 237]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 0, 0, 0], 'occ_pct': [98, 80, 0, 0, 0], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'})], [({'interval': 120, 'bins': 3, 'events': [[-5, -2], [5, 7]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [1, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 5, 'events': [[85, 86], [8, 48]], 'max_presence': 180, 'no_activity': 600}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [34, 0, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'})], [({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[10, 150], [170, 172], [177, 217]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 0], 'occ_pct': [83, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 2, 'events': [[8, 16], [26, 34], [55, 95], [97, 137], [160, 162], [165, 504], [524, 532], [547, 550]], 'max_presence': 240, 'no_activity': 120}, {'counts': [2, 1], 'occ_pct': [40, 30], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 3, 'events': [[-1, 0]], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check('timing oracle' + ' %d' % i, 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 |
|---|---|---|---|
| timing oracle 0 | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'} | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'} | Passed |
| timing oracle 1 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 2 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'counts': [2, 4], 'occ_pct': [40, 58], 'status': 'ok'} | {'counts': [2, 4], 'occ_pct': [40, 58], 'status': 'ok'} | Passed |
| timing oracle 4 | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Passed |
| timing oracle 5 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'} | Passed |
| timing oracle 6 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 7 | {'counts': [3, 3, 0, 0], 'occ_pct': [47, 10, 0, 0], 'status': 'ok'} | {'counts': [3, 3, 0, 0], 'occ_pct': [47, 10, 0, 0], 'status': 'ok'} | Passed |
SHA-256 / 4d2de55f63cee2bf77e844949218b8052d513daba9ee8e2041c49001c9beb9be
Verification & scope
A deterministic, bounded toy model with a stipulated contract; it makes no claim of conformance to any agency manual or standard. 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:48:00.284462+00:00.
Case digest / a20aed9eb071cc987ad2234050c05874ae753500bc7809bf2ff790788cd32878