"""Verdicts M1-M5 for PREREG 2026-09-21 slot 2 (the DECISION place). python -u analyze_decision.py """ from __future__ import annotations import json import math from scipy.optimize._tstutils import (_APS_TESTS_DICTS, _CHANDRUPATLA_TESTS_DICTS) from simroot.pure import pure_root REF = {"APS": 2527, "CHA": 2683, "BOTH": 5511, "CHA_theirs": 2423, "APS_theirs": 2785} MODES = ("none", "slope", "band", "defect", "simpair") FAMILY = ("project", "safe", "credit") def main(): with open("sweep_decision.json", encoding="utf8") as fh: res = json.load(fh) by = {(r["spec"][1], r["spec"][5], r["spec"][3]): r for r in res} print("M1/M2 the readings, ratio similarity, per guard " "(band is CHANDRUPATLA'S rule, not ours)") print(f"{'guard':<9} " + " ".join(f"{m:>17}" for m in MODES)) for gu in ("none", "step", "bracket", "both", "project", "safe", "credit"): cells = [] for m in MODES: r = by.get(("ratio", m, gu)) cells.append(f"{r['APS']['total']:7d}/{r['CHA']['total']:<5d}" f"{r['APS']['solved'] + r['CHA']['solved']:>4}" if r else " " * 17) print(f"{gu:<9} " + " ".join(cells)) print(" (cells are APS/CHA solved-of-199)\n") print("Best per set by the paper's rule, restricted to the GUARANTEE family") for setname in ("APS", "CHA"): rows = [r for r in res if r["spec"][3] in FAMILY] rows.sort(key=lambda r: (r[setname]["n"] - r[setname]["solved"], r[setname]["total"])) for r in rows[:4]: print(f" {setname} {r['label']:<34} {r[setname]['solved']}/{r[setname]['n']} " f"{r[setname]['total']:6d} over2x={r[setname]['over']} " f"(ours {REF[setname]}, theirs {REF[setname + '_theirs']})") print("\nBoth sets, guarantee family") rows = [r for r in res if r["spec"][3] in FAMILY] rows.sort(key=lambda r: (398 - r["APS"]["solved"] - r["CHA"]["solved"], r["APS"]["total"] + r["CHA"]["total"])) for r in rows[:4]: print(f" {r['label']:<34} {r['APS']['solved'] + r['CHA']['solved']}/199 " f"{r['APS']['total'] + r['CHA']['total']:6d} (reference {REF['BOTH']})") print("\nM4 guarantee violations inside the family: ", end="") fam = [r for r in res if r["spec"][3] in FAMILY] print(sum(r["APS"]["over"] + r["CHA"]["over"] for r in fam), f"of {len(fam)} cells") print("\nM5 does each reading actually DECIDE? refusals / evaluations, " "over both benchmark sets") probs = [(float(d["bracket"][0]), float(d["bracket"][1]), (lambda ff, aa: lambda t: ff(t, *aa))(d["f"], d.get("args", ()))) for d in _APS_TESTS_DICTS] probs += [(float(d["bracket"][0]), float(d["bracket"][1]), (lambda ff: lambda t: ff(t))(d["f"])) for d in _CHANDRUPATLA_TESTS_DICTS] for m in MODES: ref = nfev = 0 for a, b, f in probs: st = {} try: _x, n, _c = pure_root(f, a, b, 1e-12, 200, similarity="ratio", scale="derived3", guard="project", prestep=m, stats=st) except Exception: continue ref += st.get("pre_refused", 0) nfev += int(n) rate = 100.0 * ref / max(nfev, 1) verdict = "DECIDES" if 0.0 < rate < 100.0 else "RELABELLING — result meaningless" print(f" {m:<9} {ref:6d}/{nfev:6d} = {rate:5.1f}% {verdict}") if __name__ == "__main__": main()