"""job 2958 triage: price ladder of the 83# ascent from the corpus's OWN recorded run. Reads job2767/fresh/0017-ladder-n02-21.out (the posted 0017 package, read-only) and prints, per rank n: the rank's last COVERABLE rung, the REFUTED rung that closes it, and their node counts and seconds. The object is 0017's paired two-class covering search (jtwin.c), seeds R=2..21 from monotonicity. Why this is the decisive price datum: the route's next experiment is "decide R = 308" at n = 23, and what it costs is a property of the engine's search tree, not of the target. The ladder is the engine's own record of that tree at 20 smaller ranks, each closed by a REFUTED verdict. """ import json import os import re import sys HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.abspath(os.path.join(HERE, "..", "..", "..", "..", "..")) LADDER = os.path.join(ROOT, "job2767", "fresh", "0017-ladder-n02-21.out") rank_rx = re.compile(r"^=== n=(\d+)\s+primes (\S+)") run_rx = re.compile(r"^\s+R = (\d+)\s+(COVERABLE|REFUTED)\s+\(a=(\d+)\s+G2=(\d+)\s*\)\s+nodes (\d+)\s+\(([\d.]+)s\)") term_rx = re.compile(r"==> R = (\d+)\s+;\s+A144311\((\d+)\) = (\d+)\s+;\s+G_2\((\d+)#\) = (\d+)") blocks = [] cur = None with open(LADDER, encoding="utf-8", errors="replace") as fh: for line in fh: m = rank_rx.match(line) if m: cur = {"n": int(m.group(1)), "primes": m.group(2).strip().rstrip("."), "rungs": [], "term": None} blocks.append(cur) continue if cur is None: continue m = run_rx.match(line) if m: cur["rungs"].append({"R": int(m.group(1)), "verdict": m.group(2), "a": int(m.group(3)), "G2": int(m.group(4)), "nodes": int(m.group(5)), "secs": float(m.group(6))}) continue m = term_rx.match(line) if m: cur["term"] = {"R": int(m.group(1)), "idx": int(m.group(2)), "A": int(m.group(3)), "G2": int(m.group(5))} rows = [] for b in blocks: cov = [r for r in b["rungs"] if r["verdict"] == "COVERABLE"] ref = [r for r in b["rungs"] if r["verdict"] == "REFUTED"] rows.append({ "n": b["n"], "primes": b["primes"], "last_coverable_R": max([r["R"] for r in cov]) if cov else None, "last_coverable_nodes": max([r["nodes"] for r in cov]) if cov else None, "refuted_R": ref[-1]["R"] if ref else None, "refuted_nodes": ref[-1]["nodes"] if ref else None, "refuted_secs": ref[-1]["secs"] if ref else None, "term_A144311": b["term"]["A"] if b["term"] else None, "term_index": b["term"]["idx"] if b["term"] else None, "G2": b["term"]["G2"] if b["term"] else None, }) print("%3s %8s %14s %12s %10s %14s %12s %10s %8s" % ( "n", "primes", "last cov R", "nodes", "secs", "REFUTED R", "nodes", "secs", "A144311")) for r in rows: print("%3d %8s %14s %12s %10s %14s %12s %10s %8s" % ( r["n"], r["primes"], r["last_coverable_R"], r["last_coverable_nodes"], "", r["refuted_R"], r["refuted_nodes"], r["refuted_secs"], r["term_A144311"])) # ratio: refutation cost / last coverable rung cost, where both are recorded rat = [(r["n"], r["refuted_nodes"] / r["last_coverable_nodes"]) for r in rows if r["refuted_nodes"] and r["last_coverable_nodes"]] print("\nrefutation nodes / last-coverable nodes, per rank:") for n, q in rat: print(" n=%2d %.3f" % (n, q)) out = os.path.join(HERE, "ascent-price-ladder.json") with open(out, "w", encoding="utf-8", newline="\n") as fh: json.dump({"source": os.path.relpath(LADDER, os.path.dirname(HERE)), "rows": rows, "refutation_over_last_coverable": [{"n": n, "ratio": q} for n, q in rat]}, fh, indent=1, sort_keys=True) fh.write("\n") print("\nwrote", out)