logarithmic space mode: pure_root gains space='x'|'log' (default reproduces the published grid bit-for-bit), u = sign(x-c)*log1p(|x-c|/xtol) with c = the end of smaller |f| and s = xtol fixed by derivation; gates G1/G2' pinned by tests/test_log_space.py (7 green); sweep writes the log grid to its OWN sweep_log.json so the verified sweep_full.json is untouched
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+28
-7
@@ -101,20 +101,27 @@ BASELINES = {
|
||||
|
||||
|
||||
def make_method(spec):
|
||||
"""spec is ('base', name) or ('pure', similarity, scale, guard)."""
|
||||
"""spec is ('base', name) or ('pure', similarity, scale, guard[, space]).
|
||||
|
||||
The optional 5th element is the SPACE the step is read in (PREREG
|
||||
amendment 1, 2026-09-20): omitted or "x" reproduces the published grid
|
||||
bit-for-bit, "log" is the logarithmic-march mode."""
|
||||
if spec[0] == "base":
|
||||
return BASELINES[spec[1]]
|
||||
_, sim, scale, guard = spec
|
||||
sim, scale, guard = spec[1], spec[2], spec[3]
|
||||
space = spec[4] if len(spec) > 4 else "x"
|
||||
|
||||
def m(f, a, b, xtol, maxfev):
|
||||
return pure_root(f, a, b, xtol, maxfev, similarity=sim,
|
||||
scale=scale, guard=guard)
|
||||
scale=scale, guard=guard, space=space)
|
||||
return m
|
||||
|
||||
|
||||
def label(spec):
|
||||
if spec[0] == "base":
|
||||
return spec[1]
|
||||
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]}"
|
||||
|
||||
|
||||
@@ -152,6 +159,16 @@ def evaluate(spec):
|
||||
return res
|
||||
|
||||
|
||||
def build_grid_log(smoke):
|
||||
"""The logarithmic-space grid (PREREG 2026-09-20). Baselines are NOT recomputed:
|
||||
their numbers are already in sweep_full.json and re-running known expensive
|
||||
controls is waste. Only the derived scales are admissible in u-space."""
|
||||
sims = ["ratio", "cbrt"] if smoke else sorted(PURE_SIMS)
|
||||
guards = ("credit", "project") if smoke else GUARD_MODES
|
||||
return [("pure", sim, sc, gu, "log")
|
||||
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)
|
||||
@@ -171,10 +188,11 @@ def build_grid(smoke):
|
||||
|
||||
def main():
|
||||
smoke = "--smoke" in sys.argv
|
||||
specs = build_grid(smoke)
|
||||
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)
|
||||
t0 = time.time()
|
||||
print(f"sweep: {len(specs)} configurations x 199 problems "
|
||||
f"({'SMOKE' if smoke else 'FULL'})", flush=True)
|
||||
f"({'SMOKE' if smoke else 'FULL'}{', LOG-SPACE' if logmode else ''})", flush=True)
|
||||
|
||||
workers = max(1, min(8, (os.cpu_count() or 2) - 1))
|
||||
with Pool(workers) as pool:
|
||||
@@ -185,7 +203,10 @@ def main():
|
||||
print(f" {i}/{len(specs)} done, "
|
||||
f"{time.time() - t0:.0f}s elapsed", flush=True)
|
||||
|
||||
out = "sweep_smoke.json" if smoke else "sweep_full.json"
|
||||
# the published sweep_full.json is what verify_article.py checks the paper
|
||||
# against, so the log grid never writes into it
|
||||
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:
|
||||
json.dump(results, fh)
|
||||
print(f"\nwrote {out} ({time.time() - t0:.0f}s total)\n", flush=True)
|
||||
@@ -225,7 +246,7 @@ def report(results, top=20):
|
||||
for r in results:
|
||||
if r["spec"][0] != "pure":
|
||||
continue
|
||||
_, sim, sc, gu = r["spec"]
|
||||
sim, sc, gu = r["spec"][1], r["spec"][2], r["spec"][3]
|
||||
if sc != scale or gu != "step" or sim not in group:
|
||||
continue
|
||||
cnt += 1
|
||||
|
||||
Reference in New Issue
Block a user