broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('two deliveries same slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 4, 2: 2}, {1: 8, 2: 4}, {1: 12, 2: 6}, {1: 16, 2: 8}, {1: 20, 2: 10}]), ('mixed known unknown slots / two deliveries same slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 4, 2: 2}, {1: 8, 2: 4}, {1: 12, 2: 6}, {1: 16, 2: 8}, {1: 20, 2: 10}]), ('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 2: 2}, {1: 4, 2: 4}, {1: 6, 2: 6}, {1: 8, 2: 8}, {1: 10, 2: 10}]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 5: 2}, {1: 4, 5: 4}, {1: 6, 5: 6}, {1: 8, 5: 8}, {1: 10, 5: 10}]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [{1: 2, 2: 2}, {1: 4, 2: 4}, {1: 6, 2: 6}, {1: 8, 2: 8}, {1: 10, 2: 10}]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 2: 2, 3: 2}, {1: 4, 2: 4, 3: 4}, {1: 6, 2: 6, 3: 6}, {1: 8, 2: 8, 3: 8}, {1: 10, 2: 10, 3: 10}]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 3: 2}, {1: 4, 3: 4}, {1: 6, 3: 6}, {1: 8, 3: 8}, {1: 10, 3: 10}]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 2: 2}, {1: 4, 2: 4}, {1: 6, 2: 6}, {1: 8, 2: 8}, {1: 10, 2: 10}]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 2: 2}, {1: 4, 2: 4}, {1: 6, 2: 6}, {1: 8, 2: 8}, {1: 10, 2: 10}]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{5: 2}, {5: 4}, {5: 6}, {5: 8}, {5: 10}]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 1, 2: 1}, {1: 2, 2: 2}, {1: 3, 2: 3}, {1: 4, 2: 4}, {1: 5, 2: 5}])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['repeated-slot-demand'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:len(x["requested"])*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('two deliveries same slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 4, 2: 2}, {1: 8, 2: 4}, {1: 12, 2: 6}, {1: 16, 2: 8}, {1: 20, 2: 10}]), ('mixed known unknown slots / two deliveries same slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 4, 2: 2}, {1: 8, 2: 4}, {1: 12, 2: 6}, {1: 16, 2: 8}, {1: 20, 2: 10}]), ('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 2: 2}, {1: 4, 2: 4}, {1: 6, 2: 6}, {1: 8, 2: 8}, {1: 10, 2: 10}]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 5: 2}, {1: 4, 5: 4}, {1: 6, 5: 6}, {1: 8, 5: 8}, {1: 10, 5: 10}]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [{1: 2, 2: 2}, {1: 4, 2: 4}, {1: 6, 2: 6}, {1: 8, 2: 8}, {1: 10, 2: 10}]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 2: 2, 3: 2}, {1: 4, 2: 4, 3: 4}, {1: 6, 2: 6, 3: 6}, {1: 8, 2: 8, 3: 8}, {1: 10, 2: 10, 3: 10}]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 3: 2}, {1: 4, 3: 4}, {1: 6, 3: 6}, {1: 8, 3: 8}, {1: 10, 3: 10}]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 2: 2}, {1: 4, 2: 4}, {1: 6, 2: 6}, {1: 8, 2: 8}, {1: 10, 2: 10}]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 2, 2: 2}, {1: 4, 2: 4}, {1: 6, 2: 6}, {1: 8, 2: 8}, {1: 10, 2: 10}]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{5: 2}, {5: 4}, {5: 6}, {5: 8}, {5: 10}]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [{1: 1, 2: 1}, {1: 2, 2: 2}, {1: 3, 2: 3}, {1: 4, 2: 4}, {1: 5, 2: 5}])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['repeated-slot-demand'], expected[N-1])
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)

prompt:
A package containing several simultaneous deliveries collapses multiplicity at one slot.

An auction awards delivery capacity in discrete named slots. A bid may require several consecutive slots, setup occupies an earlier slot, and cleanup occupies a later slot. Existing commitments and a separate seller maintenance mask must both constrain certificates. No continuous scheduling optimization is claimed. Named decision repeated-slot-demand: For repeated slot demand, apply the stipulated decision {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = sum(x["used"])+x["amount"]<=sum(x["capacity"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [False, False, False, False, False]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['per-slot-capacity'], expected[N-1])
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]<x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [False, False, False, False, False]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['per-slot-capacity'], expected[N-1])
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)

prompt:
Aggregate spare capacity hides an oversold delivery slot.

An auction awards delivery capacity in discrete named slots. A bid may require several consecutive slots, setup occupies an earlier slot, and cleanup occupies a later slot. Existing commitments and a separate seller maintenance mask must both constrain certificates. No continuous scheduling optimization is claimed. Named decision per-slot-capacity: For per slot capacity, apply the stipulated decision all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"]).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = []
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['setup-footprint'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(x["start"],x["start"]+x["setup"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[0], [0], [0], [0], [0]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['setup-footprint'], expected[N-1])
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)

prompt:
Setup capacity is omitted or reserved after delivery starts.

An auction awards delivery capacity in discrete named slots. A bid may require several consecutive slots, setup occupies an earlier slot, and cleanup occupies a later slot. Existing commitments and a separate seller maintenance mask must both constrain certificates. No continuous scheduling optimization is claimed. Named decision setup-footprint: For setup footprint, apply the stipulated decision list(range(max(0,x["start"]-x["setup"]),x["start"])).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = []
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['cleanup-footprint'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"]-x["cleanup"],x["end"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[3], [3], [3], [3], [3]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['cleanup-footprint'], expected[N-1])
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)

prompt:
Cleanup is reserved inside the award instead of after it.

An auction awards delivery capacity in discrete named slots. A bid may require several consecutive slots, setup occupies an earlier slot, and cleanup occupies a later slot. Existing commitments and a separate seller maintenance mask must both constrain certificates. No continuous scheduling optimization is claimed. Named decision cleanup-footprint: For cleanup footprint, apply the stipulated decision list(range(x["end"],x["end"]+x["cleanup"])).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not set(x["transfer"])&set(x["occupied"])
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [True, True, True, True, True]), ('mixed known unknown slots / released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [True, True, True, True, True]), ('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['transfer-release-before-check'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not set(x["transfer"])&(set(x["occupied"])|set(x["released"]))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [True, True, True, True, True]), ('mixed known unknown slots / released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [True, True, True, True, True]), ('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['transfer-release-before-check'], expected[N-1])
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)

prompt:
Award slot transfer fails to remove legitimately released capacity.

An auction awards delivery capacity in discrete named slots. A bid may require several consecutive slots, setup occupies an earlier slot, and cleanup occupies a later slot. Existing commitments and a separate seller maintenance mask must both constrain certificates. No continuous scheduling optimization is claimed. Named decision transfer-release-before-check: For transfer release before check, apply the stipulated decision not (set(x["transfer"])&(set(x["occupied"])-set(x["released"]))).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(x["requested"])>=x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('mixed known unknown slots / extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('two deliveries same slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [True, True, True, True, True]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['duration-certificate'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(x["requested"])<=x["duration"]
    v9 = list(range(x["start"],x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('mixed known unknown slots / extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [False, False, False, False, False]), ('two deliveries same slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [True, True, True, True, True]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['duration-certificate'], expected[N-1])
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)

prompt:
A fixed-duration winning slot package has the wrong number of slots.

An auction awards delivery capacity in discrete named slots. A bid may require several consecutive slots, setup occupies an earlier slot, and cleanup occupies a later slot. Existing commitments and a separate seller maintenance mask must both constrain certificates. No continuous scheduling optimization is claimed. Named decision duration-certificate: For duration certificate, apply the stipulated decision len(set(x["requested"]))==x["duration"].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"],x["end"]+1))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['end-exclusive-reservation'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = not x["requested"] or sorted(set(x["requested"]))==list(range(min(x["requested"]),max(x["requested"])+1))
    v1 = not set(x["requested"])&set(x["occupied"])
    v2 = not set(x["requested"])&set(x["maintenance"])
    v3 = {i:x["requested"].count(i)*x["amount"] for i in x["requested"]}
    v4 = all(x["used"][i]+x["amount"]<=x["capacity"][i] for i in x["requested"] if i in x["slots"])
    v5 = list(range(max(0,x["start"]-x["setup"]),x["start"]))
    v6 = list(range(x["end"],x["end"]+x["cleanup"]))
    v7 = not (set(x["transfer"])&(set(x["occupied"])-set(x["released"])))
    v8 = len(set(x["requested"]))==x["duration"]
    v9 = list(range(x["start"]+1,x["end"]))
    return {'consecutive-slot-package':v0,'occupied-slot-conflict':v1,'maintenance-exclusion':v2,'repeated-slot-demand':v3,'per-slot-capacity':v4,'setup-footprint':v5,'cleanup-footprint':v6,'transfer-release-before-check':v7,'duration-certificate':v8,'end-exclusive-reservation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('mixed known unknown slots', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('released occupied slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [3], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('extra duration slot', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('gap in award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 3], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('slot collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [2], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('maintenance collision', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [2], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('outside slot', {'slots': [0, 1, 2, 3, 4], 'requested': [5], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 2, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]), ('room for award', {'slots': [0, 1, 2, 3, 4], 'requested': [1, 2], 'occupied': [3], 'maintenance': [0], 'setup': 1, 'cleanup': 1, 'capacity': [2, 2, 2, 2, 2], 'used': [0, 1, 0, 2, 0], 'amount': 1, 'start': 1, 'end': 3, 'transfer': [2, 3], 'released': [1], 'duration': 2}, [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['cleanup', 'count', 'delivery_index', 'disputed', 'duration', 'end', 'maintenance', 'maximum_set', 'minimum_set', 'occupied', 'released', 'requested', 'setup', 'slots', 'stage', 'start', 'threshold', 'transfer', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['end-exclusive-reservation'], expected[N-1])
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)

prompt:
A delivery award reserves its neighbor closing slot or loses its opening slot.

An auction awards delivery capacity in discrete named slots. A bid may require several consecutive slots, setup occupies an earlier slot, and cleanup occupies a later slot. Existing commitments and a separate seller maintenance mask must both constrain certificates. No continuous scheduling optimization is claimed. Named decision end-exclusive-reservation: For end exclusive reservation, apply the stipulated decision list(range(x["start"],x["end"])).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] or x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['both-party-confirmation'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['both-party-confirmation'], expected[N-1])
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)

prompt:
A one-sided confirmation finalizes a matched award.

After an auction allocation, buyer and seller confirmations reserve a specific trade version. A trade is final only when both parties confirm the same proposed version; rejection releases reservations but does not erase executed trades. Match identity differs from party identity. Named decision both-party-confirmation: For both party confirmation, apply the stipulated decision x["buyer_accept"] and x["seller_accept"].

split: open-access