/* e1533.c — driver for job #1533 (explore/discovery, no route, "Leads: new route"). * * Reuses return #159's recovered instrument UNCHANGED (tct.h, tile.c, analyze.c, * sha256 recorded in PROGRESS.md) exactly as job #1492's driver e1492.c did, and * changes only the run list: after the published gates it extends the * FIXED-START-TILE families in q. * * Why: #698 (job #1492) showed that at fixed q = 43 the value * c = q(1 - max_theta N_new/RHS) * depends on the START TILE (T_23 -> 1.7132, T_31 -> 1.8197, T_37 -> 1.8507), a * spread 0.1375 wider than the global spread 0.118 of the "consecutive fold" * series on which the K/q law 1 - R = K/q was fitted. A law fitted on the * diagonal series alone cannot separate * (L1) c is a function of q only (the deferred #1532 proposal) * (L2) c is a per-start-tile-family function of q * The cheapest discriminating experiment is NOT the consecutive 41 -> 43 fold * (D(T_41) = 8,499,244,879,125 slots ~ 16.8 CPU-h, over the per-assignment cap, * and it needs a nested stream generator the recovered instrument lacks): it is * to hold the start tile FIXED and let q grow. Folds from T_23 cost ~0.01 s and * from T_31 ~7 s each, so several new points per family are affordable. * * New points taken here: * T_23 by q for q = 43 (gate, re-measures #698), 47, 53, 59, 61, 67 * T_31 by q for q = 47, 53 * Every row prints the EXACT integers (N_new, RHS_loose, N_theta) at the argmax, * so c = q(RHS - N_new)/RHS is an exact rational. * * build: cc -O3 -pthread -I -o build1533/e1533 e1533.c \ * /tile.c /analyze.c -lm * run: ./build1533/e1533 [nthreads] */ #include #include #include #include "tct.h" double wallnow(void); static int FAILS = 0; typedef struct { long double best; int theta, thetas, vl, va, g2; unsigned long long nnew, rl, ra, ntheta, cnum, cden; /* restricted statistic: max over theta with N(theta) >= 1 (the degenerate equality rows found by #698 and here have N(theta) = 0 at the argmax and are not c/q points at all) */ long double bestP; int thetaP, nz; unsigned long long cnumP, cdenP; uint64_t dnew, dexpect, nidx; } Res; /* tails + the argmax over theta = 6*b, exactly the object main.c's report() builds. */ static Res show(const char *label, const char *kind, int x, int q, uint64_t Dold, int g2old, const Acc *a, double wall, int nth) { static uint64_t Nt[NB], Qlt[NB], Qat[NB], Nwt[NB]; uint64_t sN = 0, sQl = 0, sQa = 0, sNw = 0; Res r; memset(&r, 0, sizeof r); for (int b = NB - 1; b >= 0; b--) { sN += a->histN[b]; sQl += a->histQl[b]; sQa += a->histQa[b]; sNw += a->histNew[b]; Nt[b] = sN; Qlt[b] = sQl; Qat[b] = sQa; Nwt[b] = sNw; } int bestb = 0, bestPb = 0; for (int b = NB - 1; b >= 1; b--) if (Nwt[b] > 0) { r.g2 = b * 6; break; } for (int b = 1; b < NB; b++) { unsigned long long Rl = (unsigned long long)(q - 2) * Nt[b] + 2ULL * Qlt[b]; unsigned long long Ra = (unsigned long long)(q - 2) * Nt[b] + 2ULL * Qat[b]; if (Nwt[b] == 0 && Rl == 0) continue; r.thetas++; long double rr = (Rl == 0) ? 1e300L : (long double)Nwt[b] / (long double)Rl; if (rr > r.best) { r.best = rr; bestb = b; } if (Nt[b] >= 1) { r.nz++; if (rr > r.bestP) { r.bestP = rr; bestPb = b; } } if ((long double)Nwt[b] > (long double)Rl + 1e-9L) r.vl++; if ((long double)Nwt[b] > (long double)Ra + 1e-9L) r.va++; } r.theta = bestb * 6; r.thetaP = bestPb * 6; r.cnumP = (unsigned long long)q * ((unsigned long long)((q - 2) * Nt[bestPb] + 2ULL * Qlt[bestPb]) - (unsigned long long)Nwt[bestPb]); r.cdenP = (unsigned long long)(q - 2) * Nt[bestPb] + 2ULL * Qlt[bestPb]; r.nnew = (unsigned long long)Nwt[bestb]; r.rl = (unsigned long long)(q - 2) * Nt[bestb] + 2ULL * Qlt[bestb]; r.ra = (unsigned long long)(q - 2) * Nt[bestb] + 2ULL * Qat[bestb]; r.ntheta = (unsigned long long)Nt[bestb]; r.cnum = (unsigned long long)q * (r.rl - r.nnew); r.cden = r.rl; r.dnew = Nwt[0]; r.dexpect = Dold * (uint64_t)(q - 2); r.nidx = a->nIdx; if (label && *label) { printf("\n--- %s : T_%d by %d (%s) ---\n", label, x, q, kind); printf(" D(old) = %llu D(new) = %llu expected D(q-2) = %llu %s\n", (unsigned long long)Dold, (unsigned long long)r.dnew, (unsigned long long)r.dexpect, r.dnew == r.dexpect ? "EXACT" : "MISMATCH"); printf(" nIdx = %llu %s\n", (unsigned long long)r.nidx, r.nidx == Dold ? "= D(old) EXACT" : "MISMATCH"); printf(" G2(old) = %d G2(new) = %d\n", g2old, r.g2); printf(" wall = %.2f s threads = %d thetas tested = %d violations loose = %d alt = %d\n", wall, nth, r.thetas, r.vl, r.va); printf(" max N_new/RHS = %.6f at theta = %d\n", (double)r.best, r.theta); printf(" EXACT theta=%d N_new=%llu RHS_loose=%llu RHS_alt=%llu N_theta=%llu c_num=%llu c_den=%llu\n", r.theta, r.nnew, r.rl, r.ra, r.ntheta, r.cnum, r.cden); printf(" ROW x=%d q=%d theta=%d R=%.6Lf N_new=%llu RHS=%llu N_theta=%llu c_num=%llu c_den=%llu\n", x, q, r.theta, r.best, r.nnew, r.rl, r.ntheta, r.cnum, r.cden); printf(" RESTRICTED theta=%d Rplus=%.6Lf N_new=%llu RHS=%llu c_num=%llu c_den=%llu\n", r.thetaP, r.bestP, (unsigned long long)Nwt[bestPb], (unsigned long long)((q - 2) * Nt[bestPb] + 2ULL * Qlt[bestPb]), r.cnumP, r.cdenP); printf(" ROWP x=%d q=%d theta=%d Rplus=%.6Lf c_num=%llu c_den=%llu\n", x, q, r.thetaP, r.bestP, r.cnumP, r.cdenP); } if (r.dnew != r.dexpect || r.nidx != Dold || r.vl || r.va) FAILS++; return r; } /* published figures are printed to 4 dp, so the gate is |value - figure| <= 1e-4 */ static int near4(long double v, long double e) { long double d = v - e; if (d < 0) d = -d; return d <= 1e-4L; } static void gate(const char *what, int ok, const char *det) { if (!ok) FAILS++; printf(" %s %s%s%s\n", ok ? "ok " : "FAIL", what, det ? " " : "", det ? det : ""); } int main(int argc, char **argv) { int nth = argc > 1 ? atoi(argv[1]) : 10; setvbuf(stdout, NULL, _IOLBF, 0); printf("== e1533 (job #1533): fixed-start-tile margin families extended in q, threads = %d ==\n", nth); Tile T23 = tile_base23(); printf("T_23: D = %llu W = %llu gmax = %d\n", (unsigned long long)T23.D, (unsigned long long)T23.W, T23.gmax); gate("T_23 built", T23.D == 7952175ULL && T23.W == 223092870ULL && T23.gmax == 204, NULL); double t0 = wallnow(); Tile T29 = tile_fold(&T23, 29); printf("T_29: D = %llu gmax = %d [%.1f s]\n", (unsigned long long)T29.D, T29.gmax, wallnow() - t0); gate("T_29 built", T29.D == 214708725ULL && T29.gmax == 258, NULL); t0 = wallnow(); Tile T31 = tile_fold(&T29, 31); printf("T_31: D = %llu gmax = %d [%.1f s]\n", (unsigned long long)T31.D, T31.gmax, wallnow() - t0); gate("T_31 built", T31.D == 6226553025ULL && T31.gmax == 348, NULL); Acc a; Res r; /* ---- instrument gates: published rows re-measured here ---- */ printf("\n== gates: published rows (#159 b.log/cd.log) and #698 rows re-measured ==\n"); double w = analyze_array(&T23, 29, nth, &a); r = show("gate", "array", 23, 29, T23.D, T23.gmax, &a, w, nth); gate("T_23 by 29 = 0.9324 at theta = 42", near4(r.best, 0.9324L) && r.theta == 42, NULL); w = analyze_array(&T23, 31, nth, &a); r = show("gate", "array", 23, 31, T23.D, T23.gmax, &a, w, nth); gate("T_23 by 31 = 0.9361 at theta = 42", near4(r.best, 0.9361L) && r.theta == 42, NULL); w = analyze_array(&T23, 37, nth, &a); r = show("gate", "array", 23, 37, T23.D, T23.gmax, &a, w, nth); gate("T_23 by 37 = 0.9499 at theta = 48", near4(r.best, 0.9499L) && r.theta == 48, NULL); w = analyze_array(&T31, 37, nth, &a); r = show("gate", "array", 31, 37, T31.D, T31.gmax, &a, w, nth); gate("T_31 by 37 = 0.9477 at theta = 48 [consecutive 31->37]", near4(r.best, 0.9477L) && r.theta == 48, NULL); /* CORRECTED GATE (first run of this driver refused it, log kept as e1533-attempt1.log): 0.9551 is the DIAGONAL row 37 -> 41 (start tile T_37), NOT the fixed-start-tile row T_31 by 41. The fixed-tile row is 0.955883 per return #698's table, which is what the instrument returns. The expectation was wrong; the value was not. Corrected, not deleted. */ w = analyze_array(&T31, 41, nth, &a); r = show("gate", "array", 31, 41, T31.D, T31.gmax, &a, w, nth); printf(" c(T_31,41) = %llu/%llu = %.6f\n", r.cnum, r.cden, (double)((long double)r.cnum / (long double)r.cden)); gate("T_31 by 41 = 0.955883 at theta = 72 [fixed-tile row, return #698]", near4(r.best, 0.9559L) && r.theta == 72, NULL); w = analyze_array(&T31, 43, nth, &a); r = show("gate", "array", 31, 43, T31.D, T31.gmax, &a, w, nth); printf(" c(T_31,43) = %llu/%llu = %.6f\n", r.cnum, r.cden, (double)((long double)r.cnum / (long double)r.cden)); gate("T_31 by 43 = 0.957682 at theta = 72 [return #698 row]", near4(r.best, 0.9577L) && r.theta == 72, NULL); w = analyze_array(&T23, 43, nth, &a); r = show("gate", "array", 23, 43, T23.D, T23.gmax, &a, w, nth); printf(" c(T_23,43) = %llu/%llu = %.6f\n", r.cnum, r.cden, (double)((long double)r.cnum / (long double)r.cden)); gate("T_23 by 43 = 0.960158 at theta = 72 [return #698 row]", near4(r.best, 0.9602L), NULL); /* ---- new points: the T_23 family extended in q (each fold ~0.01 s) ---- */ printf("\n== NEW: T_23 by q, q = 47 53 59 61 67 ==\n"); int q23[] = {47, 53, 59, 61, 67}; for (unsigned i = 0; i < sizeof(q23) / sizeof(q23[0]); i++) { w = analyze_array(&T23, q23[i], nth, &a); r = show("new", "array", 23, q23[i], T23.D, T23.gmax, &a, w, nth); printf(" c(T_23,%d) = %llu/%llu = %.6f\n", q23[i], r.cnum, r.cden, (double)((long double)r.cnum / (long double)r.cden)); } /* ---- new points: the T_31 family extended in q (each fold ~7 s) ---- */ printf("\n== NEW: T_31 by q, q = 47 53 ==\n"); int q31[] = {47, 53}; for (unsigned i = 0; i < sizeof(q31) / sizeof(q31[0]); i++) { w = analyze_array(&T31, q31[i], nth, &a); r = show("new", "array", 31, q31[i], T31.D, T31.gmax, &a, w, nth); printf(" c(T_31,%d) = %llu/%llu = %.6f\n", q31[i], r.cnum, r.cden, (double)((long double)r.cnum / (long double)r.cden)); } tile_free(&T29); tile_free(&T31); tile_free(&T23); printf("\n%s (FAILS = %d)\n", FAILS ? "CHECKS FAILED" : "ALL CHECKS PASS", FAILS); return FAILS ? 1 : 0; }