FA-68256 / Traffic signal timing plans / Open access
Loop detector count and occupancy binning: vehicles present before period start are counted in the last bin · case 01
Loop detector count and occupancy binning returns a wrong result when vehicles present before period start are counted in the last bin.
ROOT CAUSE
A negative bin index wraps to the last bin, counting a vehicle that arrived before the period.
VERIFIED REPAIR
Restore the count period range rule so that the step reads `if 0 <= b < B:`.
Unsuccessful approach: Excluding bin zero drops every vehicle arriving in the first bin.
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 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': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 4, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 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': 120, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': [[-15, -14], [11, 19]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 0, 0], 'occ_pct': [13, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[-14, 26], [43, 46], [71, 73]], 'max_presence': 180, 'no_activity': 240}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [25, 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': [[-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': [[-2, 1], [37, 77], [91, 99], [130, 135]], 'max_presence': 180, 'no_activity': 60}, {'counts': [2, 1, 0], 'occ_pct': [40, 4, 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': 100, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 5, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 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': 60, 'bins': 3, 'events': [[-2, 0], [1, 2], [36, 44], [74, 114], [143, 183], [203, 208], [246, 251]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 1, 1], 'occ_pct': [15, 66, 61], 'status': 'ok'})], [({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': 30, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[-10, 30], [34, 35], [51, 52]], 'max_presence': 240, 'no_activity': 120}, {'counts': [2, 0, 0], 'occ_pct': [53, 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': 60, 'bins': 4, 'events': [[-14, 26], [34, 37], [49, 446], [455, 458], [489, 490]], 'max_presence': 100, 'no_activity': 120}, {'counts': [2, 0, 0, 0], 'occ_pct': [66, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'})], [({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'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': 60, 'bins': 3, 'events': [], 'max_presence': 240, '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': [[-4, -3], [34, 39], [74, 114], [136, 141], [164, 169], [183, 191], [224, 229]], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 1, 1, 0], 'occ_pct': [0, 16, 53, 80], 'status': 'ok'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 240}, {'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': 30, 'bins': 2, 'events': [[-8, 32], [68, 69], [90, 130], [132, 134], [165, 205], [216, 219], [243, 246], [269, 274]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [100, 6], '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': 30, 'bins': 4, 'events': [], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[-1, 7], [39, 79], [101, 103], [118, 121], [157, 158], [173, 178], [208, 248], [288, 293]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 2, 2], 'occ_pct': [46, 38, 11], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [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': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [[-10, 114], [147, 152], [-18, -16]], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 1], 'occ_pct': [100, 90, 8], 'status': 'stuck-on'})]]
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': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 1 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 2 | {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'counts': [1, 2], 'occ_pct': [8, 6], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Failed |
| timing oracle 4 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 5 | {'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 6 | {'counts': [1, 0, 1], 'occ_pct': [13, 0, 0], 'status': 'ok'} | {'counts': [1, 0, 0], 'occ_pct': [13, 0, 0], 'status': 'ok'} | Failed |
| timing oracle 7 | {'counts': [2, 0, 0, 0, 1], 'occ_pct': [25, 0, 0, 0, 0], 'status': 'ok'} | {'counts': [2, 0, 0, 0, 0], 'occ_pct': [25, 0, 0, 0, 0], 'status': 'ok'} | Failed |
SHA-256 / f3826ef0e1de4621b5e76460cf1c5a9d094be206fad78ec08abb3dbd52c0cd68
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, 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': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 4, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 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': 120, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': [[-15, -14], [11, 19]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 0, 0], 'occ_pct': [13, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[-14, 26], [43, 46], [71, 73]], 'max_presence': 180, 'no_activity': 240}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [25, 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': [[-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': [[-2, 1], [37, 77], [91, 99], [130, 135]], 'max_presence': 180, 'no_activity': 60}, {'counts': [2, 1, 0], 'occ_pct': [40, 4, 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': 100, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 5, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 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': 60, 'bins': 3, 'events': [[-2, 0], [1, 2], [36, 44], [74, 114], [143, 183], [203, 208], [246, 251]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 1, 1], 'occ_pct': [15, 66, 61], 'status': 'ok'})], [({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': 30, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[-10, 30], [34, 35], [51, 52]], 'max_presence': 240, 'no_activity': 120}, {'counts': [2, 0, 0], 'occ_pct': [53, 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': 60, 'bins': 4, 'events': [[-14, 26], [34, 37], [49, 446], [455, 458], [489, 490]], 'max_presence': 100, 'no_activity': 120}, {'counts': [2, 0, 0, 0], 'occ_pct': [66, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'})], [({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'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': 60, 'bins': 3, 'events': [], 'max_presence': 240, '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': [[-4, -3], [34, 39], [74, 114], [136, 141], [164, 169], [183, 191], [224, 229]], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 1, 1, 0], 'occ_pct': [0, 16, 53, 80], 'status': 'ok'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 240}, {'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': 30, 'bins': 2, 'events': [[-8, 32], [68, 69], [90, 130], [132, 134], [165, 205], [216, 219], [243, 246], [269, 274]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [100, 6], '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': 30, 'bins': 4, 'events': [], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[-1, 7], [39, 79], [101, 103], [118, 121], [157, 158], [173, 178], [208, 248], [288, 293]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 2, 2], 'occ_pct': [46, 38, 11], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [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': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [[-10, 114], [147, 152], [-18, -16]], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 1], 'occ_pct': [100, 90, 8], 'status': 'stuck-on'})]]
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': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 1 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 2 | {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'counts': [0, 1], 'occ_pct': [8, 6], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Failed |
| timing oracle 4 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 5 | {'counts': [0, 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'} | Failed |
| timing oracle 6 | {'counts': [0, 0, 0], 'occ_pct': [13, 0, 0], 'status': 'ok'} | {'counts': [1, 0, 0], 'occ_pct': [13, 0, 0], 'status': 'ok'} | Failed |
| timing oracle 7 | {'counts': [0, 0, 0, 0, 0], 'occ_pct': [25, 0, 0, 0, 0], 'status': 'ok'} | {'counts': [2, 0, 0, 0, 0], 'occ_pct': [25, 0, 0, 0, 0], 'status': 'ok'} | Failed |
SHA-256 / 9b80f59592bc342692434d7d212cca3b671672db3ec0def4a91460b9daf942ae
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': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 4, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 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': 120, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': [[-15, -14], [11, 19]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 0, 0], 'occ_pct': [13, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[-14, 26], [43, 46], [71, 73]], 'max_presence': 180, 'no_activity': 240}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [25, 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': [[-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': [[-2, 1], [37, 77], [91, 99], [130, 135]], 'max_presence': 180, 'no_activity': 60}, {'counts': [2, 1, 0], 'occ_pct': [40, 4, 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': 100, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 5, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 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': 60, 'bins': 3, 'events': [[-2, 0], [1, 2], [36, 44], [74, 114], [143, 183], [203, 208], [246, 251]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 1, 1], 'occ_pct': [15, 66, 61], 'status': 'ok'})], [({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': 30, 'bins': 3, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[-10, 30], [34, 35], [51, 52]], 'max_presence': 240, 'no_activity': 120}, {'counts': [2, 0, 0], 'occ_pct': [53, 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': 60, 'bins': 4, 'events': [[-14, 26], [34, 37], [49, 446], [455, 458], [489, 490]], 'max_presence': 100, 'no_activity': 120}, {'counts': [2, 0, 0, 0], 'occ_pct': [66, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'})], [({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 240}, {'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': 60, 'bins': 3, 'events': [], 'max_presence': 240, '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': [[-4, -3], [34, 39], [74, 114], [136, 141], [164, 169], [183, 191], [224, 229]], 'max_presence': 240, 'no_activity': 60}, {'counts': [0, 1, 1, 0], 'occ_pct': [0, 16, 53, 80], 'status': 'ok'}), ({'interval': 120, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 240}, {'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': 30, 'bins': 2, 'events': [[-8, 32], [68, 69], [90, 130], [132, 134], [165, 205], [216, 219], [243, 246], [269, 274]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [100, 6], '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': 30, 'bins': 4, 'events': [], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[-1, 7], [39, 79], [101, 103], [118, 121], [157, 158], [173, 178], [208, 248], [288, 293]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 2, 2], 'occ_pct': [46, 38, 11], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 240, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [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': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 3, 'events': [[-10, 114], [147, 152], [-18, -16]], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 1], 'occ_pct': [100, 90, 8], 'status': 'stuck-on'})]]
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': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 1 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 2 | {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Passed |
| timing oracle 4 | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 5 | {'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 6 | {'counts': [1, 0, 0], 'occ_pct': [13, 0, 0], 'status': 'ok'} | {'counts': [1, 0, 0], 'occ_pct': [13, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 7 | {'counts': [2, 0, 0, 0, 0], 'occ_pct': [25, 0, 0, 0, 0], 'status': 'ok'} | {'counts': [2, 0, 0, 0, 0], 'occ_pct': [25, 0, 0, 0, 0], 'status': 'ok'} | Passed |
SHA-256 / cdcff2ce62a0389c536a24027dcb4eba1bf3d08da460592168a8140c3e5c8788
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.498944+00:00.
Case digest / 844e23fb92f120b08b1ad2923994411969274da291efdb5cbb4e83a92154c7d5