"""Revision point 11 (2026-09-22): ITP in Table 10 - at the authors' recommended constants and as the per-problem oracle of section 4 - on all six corpora, under the uniform criterion of section 9, with the harness of sweep_fourth.py (same problems, same seeding, same charging). python -u sweep_itp.py run -> sweep_itp.json, then the table python -u sweep_itp.py --report """ from __future__ import annotations import json import sys from multiprocessing import Pool import sweep_fourth from sweep_oos import sign_p sweep_fourth.CONFIGS["itp"] = ("base", "itp") sweep_fourth.CONFIGS["itp_oracle"] = ("base", "itp_oracle") SETS = ("APS", "CHA", "NEW", "RJL", "APP", "D") def job(j): name, which = j return name, which, sweep_fourth.evaluate((name, which))[1] def cost(v): return v[0] if v[1] else 200 def report(R): seen = json.load(open("sweep_fourth_seen.json", encoding="utf8")) four = json.load(open("sweep_fourth_fourth.json", encoding="utf8")) ap = dict(seen["Aprime"]) ap.update(four["Aprime"]) print("corpus A' ITP (viol) ITP oracle (viol) A' vs ITP A' vs oracle") tot = {"A": 0, "itp": 0, "itp_oracle": 0} for s in SETS: a = ap[s] row = [f"{s:<5} {sum(cost(v) for v in a.values()):6d}"] tot["A"] += sum(cost(v) for v in a.values()) h = [] for k in ("itp", "itp_oracle"): r = R[k][s] t = sum(cost(v) for v in r.values()) tot[k] += t row.append(f"{t:6d} ({sum(v[2] for v in r.values())})") w = sum(cost(a[p]) < cost(r[p]) for p in a) l = sum(cost(a[p]) > cost(r[p]) for p in a) h.append(f"{w}/{len(a) - w - l}/{l} p={sign_p(w, l):.1g}") print(" ".join(row) + " " + " ".join(h)) print(f"all {tot['A']:6d} {tot['itp']:6d} {tot['itp_oracle']:6d}") def main(): if "--report" not in sys.argv: jobs = [(n, w) for n in ("itp", "itp_oracle") for w in ("seen", "fourth")] with Pool(len(jobs)) as pool: out = pool.map(job, jobs) R = {} for name, _which, res in out: R.setdefault(name, {}).update(res) with open("sweep_itp.json", "w", encoding="utf8") as fh: json.dump(R, fh) with open("sweep_itp.json", encoding="utf8") as fh: R = json.load(fh) report(R) print("itp done") if __name__ == "__main__": main()