pre-step gate: prestep='none'|'progress' (default bit-identical), refuse the similarity step BEFORE spending an evaluation when it promises less progress than bisection — two lengths already in hand, no new constant; R1-R4 pinned by tests/test_prestep_gate.py (6 green); the gate grid writes to its OWN sweep_gate.json
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+29
-4
@@ -110,19 +110,23 @@ def make_method(spec):
|
||||
return BASELINES[spec[1]]
|
||||
sim, scale, guard = spec[1], spec[2], spec[3]
|
||||
space = spec[4] if len(spec) > 4 else "x"
|
||||
prestep = spec[5] if len(spec) > 5 else "none"
|
||||
|
||||
def m(f, a, b, xtol, maxfev):
|
||||
return pure_root(f, a, b, xtol, maxfev, similarity=sim,
|
||||
scale=scale, guard=guard, space=space)
|
||||
scale=scale, guard=guard, space=space, prestep=prestep)
|
||||
return m
|
||||
|
||||
|
||||
def label(spec):
|
||||
if spec[0] == "base":
|
||||
return spec[1]
|
||||
tag = "pure"
|
||||
if len(spec) > 4 and spec[4] != "x":
|
||||
return f"{spec[4]}.{spec[1]}.{spec[2]}.{spec[3]}"
|
||||
return f"pure.{spec[1]}.{spec[2]}.{spec[3]}"
|
||||
tag = spec[4]
|
||||
if len(spec) > 5 and spec[5] != "none":
|
||||
tag = f"{tag}+gate" if tag != "pure" else "gate"
|
||||
return f"{tag}.{spec[1]}.{spec[2]}.{spec[3]}"
|
||||
|
||||
|
||||
def evaluate(spec):
|
||||
@@ -185,6 +189,15 @@ def build_grid_log(smoke):
|
||||
for sim in sims for sc in ("derived", "derived3") for gu in guards]
|
||||
|
||||
|
||||
def build_grid_gate(smoke):
|
||||
"""The pre-step gate grid (PREREG 2026-09-21): the published x-space step with the
|
||||
gate switched on. Baselines are not recomputed - they are already in sweep_full.json."""
|
||||
sims = ["ratio", "sqrt"] if smoke else sorted(PURE_SIMS)
|
||||
guards = ("credit", "safe") if smoke else GUARD_MODES
|
||||
return [("pure", sim, sc, gu, "x", "progress")
|
||||
for sim in sims for sc in ("derived", "derived3") for gu in guards]
|
||||
|
||||
|
||||
def build_grid(smoke):
|
||||
specs = [("base", nm) for nm in BASELINES]
|
||||
sims = sorted(PURE_SIMS)
|
||||
@@ -205,7 +218,9 @@ def build_grid(smoke):
|
||||
def main():
|
||||
smoke = "--smoke" in sys.argv
|
||||
logmode = "--log" in sys.argv # the u-space grid, written to its OWN file
|
||||
specs = build_grid_log(smoke) if logmode else build_grid(smoke)
|
||||
gatemode = "--gate" in sys.argv # the pre-step gate grid, likewise
|
||||
specs = (build_grid_gate(smoke) if gatemode else
|
||||
build_grid_log(smoke) if logmode else build_grid(smoke))
|
||||
t0 = time.time()
|
||||
print(f"sweep: {len(specs)} configurations x 199 problems "
|
||||
f"({'SMOKE' if smoke else 'FULL'}{', LOG-SPACE' if logmode else ''})", flush=True)
|
||||
@@ -221,6 +236,16 @@ def main():
|
||||
|
||||
# the published sweep_full.json is what verify_article.py checks the paper
|
||||
# against, so the log grid never writes into it
|
||||
if gatemode:
|
||||
# never into sweep_full.json: that file is what verify_article.py checks the
|
||||
# paper against, and the smoke run of 2026-09-21 did land in sweep_smoke.json
|
||||
# before this branch existed
|
||||
out = "sweep_gate_smoke.json" if smoke else "sweep_gate.json"
|
||||
with open(out, "w", encoding="utf8") as fh:
|
||||
json.dump(results, fh)
|
||||
print(f"\nwrote {out} ({time.time() - t0:.0f}s total)\n", flush=True)
|
||||
report(results)
|
||||
return
|
||||
out = ("sweep_log_smoke.json" if smoke else "sweep_log.json") if logmode else \
|
||||
("sweep_smoke.json" if smoke else "sweep_full.json")
|
||||
with open(out, "w", encoding="utf8") as fh:
|
||||
|
||||
Reference in New Issue
Block a user