FA-67731 / Elevator dispatch scheduling / Open access
Hospital code blue car selection: service mode filter · case 01
A car under fire service or independent service is sent to the code blue.
ROOT CAUSE
Car modes are not checked.
VERIFIED REPAIR
Only consider cars in normal mode.
Unsuccessful approach: Excluding only fire service still dispatches an independent-service car.
Case contract
Only cars in normal mode can answer a code blue at floor call. An idle car or one moving towards (or at) the call floor costs the floor distance. A car moving away first runs to its turn floor (the extreme of its calls and its floor in its direction) and back: |turn-floor| + |turn-call|. Lowest cost wins, ties to the lowest id. The winner cancels its car calls (reported sorted) and announces if it carries passengers.
Why this case matters
Lift group controllers make these decisions many times per minute; a wrong answer strands passengers, wastes trips or overrides a safety rule.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
best = None
for c in sorted(x['cars'], key=lambda c: c['id']):
if False:
continue
f = c['floor']
if c['dir'] == 'idle' or (c['dir'] == 'up' and x['call'] >= f) or (c['dir'] == 'down' and x['call'] <= f):
cost = abs(x['call'] - f)
else:
turn = max(c['calls'] + [f]) if c['dir'] == 'up' else min(c['calls'] + [f])
cost = abs(turn - f) + abs(turn - x['call'])
if best is None or cost < best[0]:
best = (cost, c)
if best is None:
return {'car': None, 'cancelled_calls': [], 'announce': False}
c = best[1]
return {'car': c['id'], 'cancelled_calls': sorted(c['calls']), 'announce': c['load'] > 0}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 2', {'call': 13, 'cars': [{'id': 'H2', 'floor': 5, 'dir': 'down', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 12, 'dir': 'up', 'calls': [4, 14, 5], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 1, 'dir': 'idle', 'calls': [10, 5], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 13, 'dir': 'down', 'calls': [8, 11], 'mode': 'fire', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 5, 14], 'announce': False}), ('sampled regression 8', {'call': 13, 'cars': [{'id': 'H2', 'floor': 12, 'dir': 'down', 'calls': [7, 2, 0], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [6], 'mode': 'fire', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'idle', 'calls': [12, 7], 'mode': 'independent', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [0, 2, 7], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 1', {'call': 6, 'cars': [{'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'fire', 'load': 0}, {'id': 'H3', 'floor': 12, 'dir': 'idle', 'calls': [6, 10], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 3, 'dir': 'idle', 'calls': [11], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [11], 'announce': True}), ('control 4', {'call': 3, 'cars': [{'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [2], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [11, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3, 6, 4], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [3, 4, 6], 'announce': False}), ('control 7', {'call': 3, 'cars': [{'id': 'H1', 'floor': 2, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 13, 'dir': 'up', 'calls': [12, 1, 9], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [7], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False})], [('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 20', {'call': 6, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [13, 11], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('sampled regression 21', {'call': 4, 'cars': [{'id': 'H1', 'floor': 3, 'dir': 'idle', 'calls': [9, 14], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 3, 'dir': 'idle', 'calls': [10, 4, 8], 'mode': 'normal', 'load': 80}, {'id': 'H3', 'floor': 9, 'dir': 'up', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [4, 8, 10], 'announce': True}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 12', {'call': 8, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [4, 9], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 4, 'dir': 'idle', 'calls': [6, 3], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [5, 2], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 9], 'announce': False}), ('control 15', {'call': 12, 'cars': [{'id': 'H3', 'floor': 1, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 14, 'dir': 'down', 'calls': [5, 3, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [3, 5, 9], 'announce': True}), ('sampled regression 18', {'call': 14, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [10, 6, 7], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 8, 'dir': 'down', 'calls': [11, 14, 6], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 1, 'dir': 'up', 'calls': [6, 7, 8], 'mode': 'fire', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [6, 11, 14], 'announce': False})], [('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 33', {'call': 8, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'idle', 'calls': [1], 'mode': 'fire', 'load': 80}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [6, 8], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 13, 'dir': 'up', 'calls': [0], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 13, 'dir': 'up', 'calls': [9], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [9], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 23', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 4, 'dir': 'up', 'calls': [11], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('control 29', {'call': 1, 'cars': [{'id': 'H3', 'floor': 9, 'dir': 'down', 'calls': [5], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'down', 'calls': [2, 11, 14], 'mode': 'normal', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [2, 11, 14], 'announce': True})], [('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 57', {'call': 10, 'cars': [{'id': 'H3', 'floor': 7, 'dir': 'down', 'calls': [7], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 12, 'dir': 'idle', 'calls': [3, 10], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 4, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [7], 'announce': False}), ('sampled regression 64', {'call': 8, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'down', 'calls': [9, 5], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'down', 'calls': [0, 1], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [13], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [4, 9, 1], 'mode': 'normal', 'load': 0}]}, {'car': 'H4', 'cancelled_calls': [0, 1], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 34', {'call': 9, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [14, 5], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('control 37', {'call': 2, 'cars': [{'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [2, 7, 11], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [8], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [2, 7, 11], 'announce': False}), ('sampled regression 40', {'call': 6, 'cars': [{'id': 'H3', 'floor': 10, 'dir': 'up', 'calls': [14, 13, 4], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [2, 1], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 1, 'dir': 'down', 'calls': [2, 10, 14], 'mode': 'independent', 'load': 80}, {'id': 'H4', 'floor': 3, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [12], 'announce': True})], [('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 72', {'call': 8, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [12, 5, 6], 'mode': 'fire', 'load': 80}, {'id': 'H3', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('boundary: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 45', {'call': 0, 'cars': [{'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'fire', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [14], 'announce': False}), ('control 48', {'call': 8, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [12, 2], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 0, 'dir': 'idle', 'calls': [12], 'mode': 'fire', 'load': 0}, {'id': 'H1', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('control 51', {'call': 11, 'cars': [{'id': 'H3', 'floor': 2, 'dir': 'down', 'calls': [11], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 7, 'dir': 'idle', 'calls': [14, 7], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 12, 'dir': 'up', 'calls': [10, 9, 13], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 11, 'dir': 'idle', 'calls': [0, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [0, 9], 'announce': True})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: car on independent service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Failed |
| sampled regression 2 | {'announce': False, 'cancelled_calls': [8, 11], 'car': 'H3'} | {'announce': False, 'cancelled_calls': [4, 5, 14], 'car': 'H1'} | Failed |
| sampled regression 8 | {'announce': True, 'cancelled_calls': [6], 'car': 'H3'} | {'announce': False, 'cancelled_calls': [0, 2, 7], 'car': 'H2'} | Failed |
| regression: car on fire service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Failed |
| boundary: car moving away with a far call | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| sampled regression 1 | {'announce': False, 'cancelled_calls': [3], 'car': 'H2'} | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | Failed |
| control 4 | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | Passed |
| control 7 | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | Passed |
SHA-256 / 7f60d36d124791485346654da89272d593b659db8c4878bda56b7cff2285220d
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
best = None
for c in sorted(x['cars'], key=lambda c: c['id']):
if c['mode'] == 'fire':
continue
f = c['floor']
if c['dir'] == 'idle' or (c['dir'] == 'up' and x['call'] >= f) or (c['dir'] == 'down' and x['call'] <= f):
cost = abs(x['call'] - f)
else:
turn = max(c['calls'] + [f]) if c['dir'] == 'up' else min(c['calls'] + [f])
cost = abs(turn - f) + abs(turn - x['call'])
if best is None or cost < best[0]:
best = (cost, c)
if best is None:
return {'car': None, 'cancelled_calls': [], 'announce': False}
c = best[1]
return {'car': c['id'], 'cancelled_calls': sorted(c['calls']), 'announce': c['load'] > 0}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 2', {'call': 13, 'cars': [{'id': 'H2', 'floor': 5, 'dir': 'down', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 12, 'dir': 'up', 'calls': [4, 14, 5], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 1, 'dir': 'idle', 'calls': [10, 5], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 13, 'dir': 'down', 'calls': [8, 11], 'mode': 'fire', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 5, 14], 'announce': False}), ('sampled regression 8', {'call': 13, 'cars': [{'id': 'H2', 'floor': 12, 'dir': 'down', 'calls': [7, 2, 0], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [6], 'mode': 'fire', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'idle', 'calls': [12, 7], 'mode': 'independent', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [0, 2, 7], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 1', {'call': 6, 'cars': [{'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'fire', 'load': 0}, {'id': 'H3', 'floor': 12, 'dir': 'idle', 'calls': [6, 10], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 3, 'dir': 'idle', 'calls': [11], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [11], 'announce': True}), ('control 4', {'call': 3, 'cars': [{'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [2], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [11, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3, 6, 4], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [3, 4, 6], 'announce': False}), ('control 7', {'call': 3, 'cars': [{'id': 'H1', 'floor': 2, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 13, 'dir': 'up', 'calls': [12, 1, 9], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [7], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False})], [('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 20', {'call': 6, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [13, 11], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('sampled regression 21', {'call': 4, 'cars': [{'id': 'H1', 'floor': 3, 'dir': 'idle', 'calls': [9, 14], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 3, 'dir': 'idle', 'calls': [10, 4, 8], 'mode': 'normal', 'load': 80}, {'id': 'H3', 'floor': 9, 'dir': 'up', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [4, 8, 10], 'announce': True}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 12', {'call': 8, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [4, 9], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 4, 'dir': 'idle', 'calls': [6, 3], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [5, 2], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 9], 'announce': False}), ('control 15', {'call': 12, 'cars': [{'id': 'H3', 'floor': 1, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 14, 'dir': 'down', 'calls': [5, 3, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [3, 5, 9], 'announce': True}), ('sampled regression 18', {'call': 14, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [10, 6, 7], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 8, 'dir': 'down', 'calls': [11, 14, 6], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 1, 'dir': 'up', 'calls': [6, 7, 8], 'mode': 'fire', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [6, 11, 14], 'announce': False})], [('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 33', {'call': 8, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'idle', 'calls': [1], 'mode': 'fire', 'load': 80}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [6, 8], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 13, 'dir': 'up', 'calls': [0], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 13, 'dir': 'up', 'calls': [9], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [9], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 23', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 4, 'dir': 'up', 'calls': [11], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('control 29', {'call': 1, 'cars': [{'id': 'H3', 'floor': 9, 'dir': 'down', 'calls': [5], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'down', 'calls': [2, 11, 14], 'mode': 'normal', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [2, 11, 14], 'announce': True})], [('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 57', {'call': 10, 'cars': [{'id': 'H3', 'floor': 7, 'dir': 'down', 'calls': [7], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 12, 'dir': 'idle', 'calls': [3, 10], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 4, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [7], 'announce': False}), ('sampled regression 64', {'call': 8, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'down', 'calls': [9, 5], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'down', 'calls': [0, 1], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [13], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [4, 9, 1], 'mode': 'normal', 'load': 0}]}, {'car': 'H4', 'cancelled_calls': [0, 1], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 34', {'call': 9, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [14, 5], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('control 37', {'call': 2, 'cars': [{'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [2, 7, 11], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [8], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [2, 7, 11], 'announce': False}), ('sampled regression 40', {'call': 6, 'cars': [{'id': 'H3', 'floor': 10, 'dir': 'up', 'calls': [14, 13, 4], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [2, 1], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 1, 'dir': 'down', 'calls': [2, 10, 14], 'mode': 'independent', 'load': 80}, {'id': 'H4', 'floor': 3, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [12], 'announce': True})], [('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 72', {'call': 8, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [12, 5, 6], 'mode': 'fire', 'load': 80}, {'id': 'H3', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('boundary: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 45', {'call': 0, 'cars': [{'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'fire', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [14], 'announce': False}), ('control 48', {'call': 8, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [12, 2], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 0, 'dir': 'idle', 'calls': [12], 'mode': 'fire', 'load': 0}, {'id': 'H1', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('control 51', {'call': 11, 'cars': [{'id': 'H3', 'floor': 2, 'dir': 'down', 'calls': [11], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 7, 'dir': 'idle', 'calls': [14, 7], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 12, 'dir': 'up', 'calls': [10, 9, 13], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 11, 'dir': 'idle', 'calls': [0, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [0, 9], 'announce': True})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: car on independent service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Failed |
| sampled regression 2 | {'announce': False, 'cancelled_calls': [4, 5, 14], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [4, 5, 14], 'car': 'H1'} | Passed |
| sampled regression 8 | {'announce': True, 'cancelled_calls': [7, 12], 'car': 'H4'} | {'announce': False, 'cancelled_calls': [0, 2, 7], 'car': 'H2'} | Failed |
| regression: car on fire service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| boundary: car moving away with a far call | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| sampled regression 1 | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | Passed |
| control 4 | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | Passed |
| control 7 | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | Passed |
SHA-256 / 78950117553c95d141a3af7d92f9a22713b79499ec08b0a96d18164647acdef0
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
best = None
for c in sorted(x['cars'], key=lambda c: c['id']):
if c['mode'] != 'normal':
continue
f = c['floor']
if c['dir'] == 'idle' or (c['dir'] == 'up' and x['call'] >= f) or (c['dir'] == 'down' and x['call'] <= f):
cost = abs(x['call'] - f)
else:
turn = max(c['calls'] + [f]) if c['dir'] == 'up' else min(c['calls'] + [f])
cost = abs(turn - f) + abs(turn - x['call'])
if best is None or cost < best[0]:
best = (cost, c)
if best is None:
return {'car': None, 'cancelled_calls': [], 'announce': False}
c = best[1]
return {'car': c['id'], 'cancelled_calls': sorted(c['calls']), 'announce': c['load'] > 0}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 2', {'call': 13, 'cars': [{'id': 'H2', 'floor': 5, 'dir': 'down', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 12, 'dir': 'up', 'calls': [4, 14, 5], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 1, 'dir': 'idle', 'calls': [10, 5], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 13, 'dir': 'down', 'calls': [8, 11], 'mode': 'fire', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 5, 14], 'announce': False}), ('sampled regression 8', {'call': 13, 'cars': [{'id': 'H2', 'floor': 12, 'dir': 'down', 'calls': [7, 2, 0], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [6], 'mode': 'fire', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'idle', 'calls': [12, 7], 'mode': 'independent', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [0, 2, 7], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 1', {'call': 6, 'cars': [{'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'fire', 'load': 0}, {'id': 'H3', 'floor': 12, 'dir': 'idle', 'calls': [6, 10], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 3, 'dir': 'idle', 'calls': [11], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [11], 'announce': True}), ('control 4', {'call': 3, 'cars': [{'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [2], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [11, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3, 6, 4], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [3, 4, 6], 'announce': False}), ('control 7', {'call': 3, 'cars': [{'id': 'H1', 'floor': 2, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 13, 'dir': 'up', 'calls': [12, 1, 9], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [7], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False})], [('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 20', {'call': 6, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [13, 11], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('sampled regression 21', {'call': 4, 'cars': [{'id': 'H1', 'floor': 3, 'dir': 'idle', 'calls': [9, 14], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 3, 'dir': 'idle', 'calls': [10, 4, 8], 'mode': 'normal', 'load': 80}, {'id': 'H3', 'floor': 9, 'dir': 'up', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [4, 8, 10], 'announce': True}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 12', {'call': 8, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [4, 9], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 4, 'dir': 'idle', 'calls': [6, 3], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [5, 2], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 9], 'announce': False}), ('control 15', {'call': 12, 'cars': [{'id': 'H3', 'floor': 1, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 14, 'dir': 'down', 'calls': [5, 3, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [3, 5, 9], 'announce': True}), ('sampled regression 18', {'call': 14, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [10, 6, 7], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 8, 'dir': 'down', 'calls': [11, 14, 6], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 1, 'dir': 'up', 'calls': [6, 7, 8], 'mode': 'fire', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [6, 11, 14], 'announce': False})], [('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 33', {'call': 8, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'idle', 'calls': [1], 'mode': 'fire', 'load': 80}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [6, 8], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 13, 'dir': 'up', 'calls': [0], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 13, 'dir': 'up', 'calls': [9], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [9], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 23', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 4, 'dir': 'up', 'calls': [11], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('control 29', {'call': 1, 'cars': [{'id': 'H3', 'floor': 9, 'dir': 'down', 'calls': [5], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'down', 'calls': [2, 11, 14], 'mode': 'normal', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [2, 11, 14], 'announce': True})], [('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 57', {'call': 10, 'cars': [{'id': 'H3', 'floor': 7, 'dir': 'down', 'calls': [7], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 12, 'dir': 'idle', 'calls': [3, 10], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 4, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [7], 'announce': False}), ('sampled regression 64', {'call': 8, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'down', 'calls': [9, 5], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'down', 'calls': [0, 1], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [13], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [4, 9, 1], 'mode': 'normal', 'load': 0}]}, {'car': 'H4', 'cancelled_calls': [0, 1], 'announce': False}), ('boundary: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 34', {'call': 9, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [14, 5], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('control 37', {'call': 2, 'cars': [{'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [2, 7, 11], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [8], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [2, 7, 11], 'announce': False}), ('sampled regression 40', {'call': 6, 'cars': [{'id': 'H3', 'floor': 10, 'dir': 'up', 'calls': [14, 13, 4], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [2, 1], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 1, 'dir': 'down', 'calls': [2, 10, 14], 'mode': 'independent', 'load': 80}, {'id': 'H4', 'floor': 3, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [12], 'announce': True})], [('regression: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 72', {'call': 8, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [12, 5, 6], 'mode': 'fire', 'load': 80}, {'id': 'H3', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('boundary: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('regression: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 45', {'call': 0, 'cars': [{'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'fire', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [14], 'announce': False}), ('control 48', {'call': 8, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [12, 2], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 0, 'dir': 'idle', 'calls': [12], 'mode': 'fire', 'load': 0}, {'id': 'H1', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('control 51', {'call': 11, 'cars': [{'id': 'H3', 'floor': 2, 'dir': 'down', 'calls': [11], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 7, 'dir': 'idle', 'calls': [14, 7], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 12, 'dir': 'up', 'calls': [10, 9, 13], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 11, 'dir': 'idle', 'calls': [0, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [0, 9], 'announce': True})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: car on independent service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| sampled regression 2 | {'announce': False, 'cancelled_calls': [4, 5, 14], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [4, 5, 14], 'car': 'H1'} | Passed |
| sampled regression 8 | {'announce': False, 'cancelled_calls': [0, 2, 7], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [0, 2, 7], 'car': 'H2'} | Passed |
| regression: car on fire service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| boundary: car moving away with a far call | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| sampled regression 1 | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | Passed |
| control 4 | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | Passed |
| control 7 | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | Passed |
SHA-256 / 48779c1f8c0f2c4c82cc020868f03f8150e935b3e6c36c583c5bf8fdfc6dee95
Verification & scope
Stipulated toy lift-control contract for a bounded teaching model; it makes no claim of conformance to any lift code or vendor dispatcher and omits real safety cases. 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:47:55.672007+00:00.
Case digest / e4ab3190657bceb3ee72ee14a925b1f89bb720b7f5b0fba6640ac6e069729a4a