Files
sim-numerics/analyze_extrap.py
T
vvsandClaude Opus 5 99be33a632 A in the method (extrapolate='steps', default 'none' = published bit for bit): NOT accepted into the proposed rule by the declared stop rule - X2 fails. Proposed rule without -> with A: APS 2806 -> 2967 (X2 FAIL), CHA 3220 -> 2925 (X1 pass), flat fun3-6 1823 -> 1524 (X4 pass), guarantee intact, 0 violations in 39 family cells (X3 pass). The per-problem edge over Chandrupatla on APS is lost (87/24/42, p=9e-5 -> 42/62/49, p=0.53).
X5: dissimilar+slope with A reaches 2859+2545 = 5404 over both sets, the best total this line has measured (was 5511; Chandrupatla 5228) - but again by trading the canonical set (2726 -> 2859) for the wide brackets (2785 -> 2545). The one-step replay (APS no harm) did not carry over: its bracket-halving metric rewards overshooting the root, which on a simple root costs superlinear convergence in the full run - the declared one-step limitation, now measured. Among the nine functions A helps only the tent (6026 -> 5892) and slightly ratio_soft.

Also: pin 'strictly fewer evaluations on every flat problem' was wrong for 6(x-2)^5 on [0,10] - both runs are budget-bound (90 of the guaranteed 91); corrected to the measured claim. verify_article 286/286, 836 tests pass twice.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 12:11:06 +01:00

101 lines
4.3 KiB
Python

"""Verdicts X1-X5 of PREREG_extrapolate_in_method_2026-09-21.md from sweep_extrap.json.
python -u analyze_extrap.py
"""
from __future__ import annotations
import json
import math
FLAT = ("fun3", "fun4", "fun5", "fun6")
FAMILY = ("project", "safe", "credit")
def load(p):
with open(p, encoding="utf8") as fh:
return json.load(fh)
def key(r):
s = r["spec"]
return (s[1], s[2], s[3], s[5], s[6], s[7])
def fam_sum(r, fams):
return sum((n if ok else 200) for pid, (n, ok) in r["CHA"]["per"].items()
if pid.split(".")[0] in fams)
def sign_p(w, l):
k, n = min(w, l), w + l
return min(1.0, 2.0 * sum(math.comb(n, i) for i in range(k + 1)) / 2.0 ** n) if n else 1.0
def h2h(a, b, s):
w = t = l = 0
for pid, (na, oka) in a[s]["per"].items():
nb, okb = b[s]["per"][pid]
if oka and okb:
w += na < nb
l += na > nb
t += na == nb
return w, t, l
def main():
rows = load("sweep_extrap.json")
full = {r["label"]: r for r in load("sweep_full.json")}
cha = full["chandrupatla"]
pairs = {}
for r in rows:
pairs.setdefault(key(r), {})[r["spec"][9]] = r
readings = {("none", "recent", "distance"): "plain", ("slope", "recent", "distance"): "slope",
("slope", "shape", "distance"): "shape+slope",
("slope", "recent", "dissimilar"): "dissim+slope",
("defect", "recent", "distance"): "defect"}
print("tent, three-point, pairs (without A -> with A): APS | CHA | both | flat fun3-6 sum")
for (sim, sc, gu, pre, pts, dirn), p in sorted(pairs.items()):
if sim != "ratio" or gu not in FAMILY + ("none",):
continue
a, b = p["none"], p["steps"]
rd = readings[(pre, pts, dirn)]
print(f" {rd:<13} {gu:<8} {a['APS']['total']:5d}->{b['APS']['total']:<5d} "
f"{a['CHA']['total']:5d}->{b['CHA']['total']:<5d} "
f"{a['APS']['total'] + a['CHA']['total']:5d}->"
f"{b['APS']['total'] + b['CHA']['total']:<5d} "
f"{fam_sum(a, FLAT):4d}->{fam_sum(b, FLAT):<4d} "
f"solved {b['APS']['solved'] + b['CHA']['solved']} over {b['APS']['over'] + b['CHA']['over']}")
prop = pairs[("ratio", "derived3", "project", "none", "recent", "distance")]
a, b = prop["none"], prop["steps"]
print("\nVERDICTS for the proposed rule (tent, 3-point, projection)")
print(f" X1 CHA < 3220: {b['CHA']['total']} -> {'PASS' if b['CHA']['total'] < 3220 else 'FAIL'}")
print(f" X2 APS <= 2806: {b['APS']['total']} -> {'PASS' if b['APS']['total'] <= 2806 else 'FAIL'}")
fam = [p["steps"] for k, p in pairs.items() if k[2] in FAMILY]
viol = sum(r["APS"]["over"] + r["CHA"]["over"] for r in fam)
low = [r["label"] for r in fam if r["APS"]["solved"] + r["CHA"]["solved"] < 193]
print(f" X3 guarantee family with A: {viol} violations over {len(fam)} cells; "
f"cells solving < 193: {len(low)} -> {'PASS' if viol == 0 and not low else 'FAIL'}")
fa, fb = fam_sum(a, FLAT), fam_sum(b, FLAT)
print(f" X4 flat fun3-6 sum: {fa} -> {fb} -> {'PASS' if fb < fa else 'FAIL'}")
best = min((p["steps"] for p in pairs.values()
if p["steps"]["spec"][3] in FAMILY
and p["steps"]["APS"]["solved"] + p["steps"]["CHA"]["solved"] >= 193),
key=lambda r: r["APS"]["total"] + r["CHA"]["total"])
print(f" X5 best pair with A over both sets: {best['label']} "
f"{best['APS']['total']}+{best['CHA']['total']}="
f"{best['APS']['total'] + best['CHA']['total']} (reference 5511, Chandrupatla 5228)")
for s in ("APS", "CHA"):
w, t, l = h2h(b, cha, s)
print(f" proposed + A vs Chandrupatla, {s}: {w}/{t}/{l} sign p={sign_p(w, l):.2g} "
f"totals {b[s]['total']} vs {cha[s]['total']}")
print("\nnine functions, three-point, projection, no readings (without A -> with A), both sets:")
for (sim, sc, gu, pre, pts, dirn), p in sorted(pairs.items()):
if gu == "project" and pre == "none" and pts == "recent" and dirn == "distance":
a2, b2 = p["none"], p["steps"]
print(f" {sim:<11} {a2['APS']['total'] + a2['CHA']['total']:6d} -> "
f"{b2['APS']['total'] + b2['CHA']['total']:6d}")
if __name__ == "__main__":
main()