"""Brute force over real-phase cells (integer input lattice for all endpoints).""" from fractions import Fraction from itertools import product import json,sys from pathlib import Path ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT/'src')) from phase_schedule import compare,clustered if not __debug__:raise SystemExit("use active assertions") variable=binary=0 for T in range(3,11): for w in range(1,T): for seq in product(range(T),repeat=3): res=compare(T,seq,w);misses=0 for n in range(3): b=n*T;cuts=[(n-1)*T+seq[n-1],n*T+seq[n]] for u in range(b-w+1,b+1): misses+=int(not any(u<=s=sum(seq)*H variable+=1 for T in range(3,12): for h in range(1,T): for w in range(1,T): for seq in product((0,h),repeat=6): k=sum(x>0 for x in seq);R=sum(x>0 and seq[i-1]==0 for i,x in enumerate(seq)) H=min(w,T-w,h,T-h);J=min(w,h)-H m=compare(T,seq,w)['lost_start_measure'] assert m==k*H+R*J assert clustered(T,h,k,6,w)[1]['lost_start_measure']<=m binary+=1 sample={k:compare(10,s,9) for k,s in [('alternating',[0,4]*4),('clustered',[0]*4+[4]*4)]} print(json.dumps(dict(variable_schedules_checked=variable,binary_schedules_checked=binary,example=sample),indent=2))