Files
sim-numerics/tables_for_md.py
T
vvsandClaude Opus 5 8830765454 §3.1 and Tables 2-3 of the canonical .md brought to current data (Valeri's request). §3.1 said the projection's doubling 'is not a tuning constant' and that zero slack 'behaves as bisection'; both are refuted by measurement (stage12 part 3, rerun as measure_budget_factor.py): the canonical total is 2806 for every multiplier >= 1.25, but the wide-bracket total moves monotonically, 2752 at 1.25 to 4006 at 4, and multiplier 1 costs 4817/2997, nowhere near bisection's 7530/3090. So the proposed safeguard is the EARNED projection (credit, C0 = 1 bit: bisection + 1 step, the cheapest endowment within that promise, 8395 -> 7658 -> 6588), as code and verifier had already fixed but no text said; the scheduled projection stays as the one-constant end of the trade. The text says openly that this choice was made after a question, and that it was not made for the numbers - on the canonical set it costs 762 more.
Tables 2-3 regenerated from sweep_full.json by tables_for_md.py with the verifier's own ranking: Chandrupatla's method, missing from both, is FIRST on the canonical set (2785) and second on the wide-bracket set (2423); the proposed rule is 29th (3568) and 10th (3020); Brent 2889/4099 (was 2890/4101). The abstract, §5 text, §5.1, §5.2 (timed configuration named), §7 (records 2527/2523 are under the scheduled projection: 2523 flat for every multiplier 1.25-4, 2527 becomes 2541 at 1.25; under credit the readings give far less, best constant-free total 6494 by 'defect'), §8.4, §8.11 and the conclusion now say so: parity with the tuned methods at the price of one constant, or a constant-free rule with a tighter guarantee that trails on the canonical set. verify_article.py: 279 checks, measured tables recomputed from fresh runs; 762 tests pass twice.

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

65 lines
3.1 KiB
Python

"""Tables 2-3 of article/sim_numerics.md regenerated from sweep_full.json.
The published tables predate Chandrupatla's own method as a baseline (it is first on
Alefeld-Potra-Shi) and name the projection variant as proposed, while the code and
verify_article.py have since fixed the credit safeguard as the proposed method. This
prints the rows and head-to-head counts from the data, with the SAME ranking function the
verifier uses, so nothing in the new tables is transcribed by hand.
python -u tables_for_md.py
"""
from __future__ import annotations
from report_sweep import PROPOSED, TUNED, head_to_head, load, place
PROJ = "pure.ratio.derived3.project"
NONE = "pure.ratio.derived3.none"
NAMES = {PROPOSED: "**proposed: tent, 3-point, credit**",
PROJ: "projection variant (tent, 3-point, projection)",
NONE: "the same rule with no safeguard at all",
"chandrupatla": "Chandrupatla", "toms748": "TOMS 748", "brent": "Brent",
"dekker": "Dekker", "itp_oracle": "ITP, per-problem oracle",
"ridders": "Ridders", "itp": "ITP, recommended constants",
"illinois": "Illinois", "bisection": "bisection",
"regula_falsi": "false position",
"pure.sqrt.bracket.project": "similarity, $1-\\sqrt{|z|}$, bracket scale, projection",
"pure.exp_abs.bracket.both": "similarity, $e^{-|z|}$, bracket scale, both guards"}
APS_ROWS = ("chandrupatla", PROJ, NONE, "toms748", "brent", "dekker", "itp_oracle",
"ridders", PROPOSED, "itp", "illinois", "bisection", "regula_falsi")
CHA_ROWS = ("pure.sqrt.bracket.project", "chandrupatla", "itp_oracle",
"pure.exp_abs.bracket.both", "itp", PROPOSED, "bisection", PROJ, NONE,
"toms748", "brent")
OPPONENTS = ("chandrupatla", "toms748", "brent", "itp", "itp_oracle", "bisection")
def main():
rows = load()
by = {r["label"]: r for r in rows}
print(f"configurations in the sweep: {len(rows)}")
for setname, keys in (("APS", APS_ROWS), ("CHA", CHA_ROWS)):
n = by[PROPOSED][setname]["n"]
print(f"\n{setname}, {n} problems")
print("| # | configuration | tuned | solved | total evals | $>2\\times$ |")
print("|---|---|---|---|---|---|")
for k in sorted(keys, key=lambda k: place(rows, setname, k)):
d = by[k][setname]
tuned = "yes" if k in TUNED else "no"
over = "—" if k in ("regula_falsi",) else str(d["over"])
print(f"| {place(rows, setname, k)} | {NAMES[k]} | {tuned} | "
f"{d['solved']}/{n} | {d['total']} | {over} |")
for lbl in (PROPOSED, PROJ):
print(f"\nhead to head, {lbl} (wins/ties/losses on problems both solve)")
for setname in ("APS", "CHA"):
cells = []
for opp in OPPONENTS:
w, t, l, _ = head_to_head(rows, lbl, opp, setname)
cells.append(f"{opp} {w}/{t}/{l}")
print(f" {setname}: " + ", ".join(cells))
for lbl in (PROPOSED, PROJ, "chandrupatla", "toms748", "brent", "itp_oracle"):
d = by[lbl]
print(f" both sets {lbl:34s} {d['APS']['total'] + d['CHA']['total']}")
if __name__ == "__main__":
main()