58 lines
2.4 KiB
Python
58 lines
2.4 KiB
Python
"""Wins and losses of A' (and A, the plain rule) against the library Chandrupatla, Brent and
|
|
TOMS748 on all six corpora, from the saved server results only (no new run):
|
|
sweep_fourth_seen.json (APS, CHA, new corpus 1, Roots.jl, applied - uniform sign-change
|
|
criterion) and sweep_fourth_fourth.json (the fourth corpus).
|
|
|
|
python -u table_all_corpora.py
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from sweep_oos import sign_p
|
|
|
|
MAXFEV = 200
|
|
NAMES = {"APS": "APS (154)", "CHA": "Chandrupatla (45)", "NEW": "new corpus 1 (206)",
|
|
"RJL": "Roots.jl (78)", "APP": "applied+GSL (132)", "D": "FOURTH (240)"}
|
|
|
|
|
|
def cost(v):
|
|
return v[0] if v[1] else MAXFEV
|
|
|
|
|
|
def main():
|
|
R = json.load(open("sweep_fourth_seen.json", encoding="utf8"))
|
|
F = json.load(open("sweep_fourth_fourth.json", encoding="utf8"))
|
|
for k in R:
|
|
R[k].update(F[k])
|
|
M = json.load(open("sweep_modab.json", encoding="utf8"))
|
|
R["modab"] = dict(M["seen"]["modab"])
|
|
R["modab"].update(M["fourth"]["modab"])
|
|
print("TOTALS (violations of the 2x-bisection bound in brackets)")
|
|
print(f" {'corpus':<20}" + "".join(f"{n:>16}" for n in
|
|
("A'", "A", "plain", "Chandrupatla", "ModAB", "Brent", "TOMS748")))
|
|
for s in NAMES:
|
|
cells = []
|
|
for k in ("Aprime", "A", "base", "chandrupatla", "modab", "brent", "toms748"):
|
|
r = R[k][s]
|
|
cells.append(f"{sum(cost(v) for v in r.values())} ({sum(v[2] for v in r.values())})")
|
|
print(f" {NAMES[s]:<20}" + "".join(f"{c:>16}" for c in cells))
|
|
print("\nA' PER PROBLEM against each rival: wins/ties/losses (sign-test p); total difference")
|
|
for s in NAMES:
|
|
line = f" {NAMES[s]:<20}"
|
|
for rv in ("chandrupatla", "modab", "brent", "toms748"):
|
|
a, o = R["Aprime"][s], R[rv][s]
|
|
w = sum(cost(a[p]) < cost(o[p]) for p in a)
|
|
l = sum(cost(a[p]) > cost(o[p]) for p in a)
|
|
ta, to = sum(cost(v) for v in a.values()), sum(cost(v) for v in o.values())
|
|
line += f" {rv[:5]} {w}/{len(a) - w - l}/{l} p={sign_p(w, l):.1g} {100 * (ta - to) / to:+.0f}%"
|
|
print(line)
|
|
tot = {k: sum(cost(v) for s in NAMES for v in R[k][s].values()) for k in R}
|
|
n_all = sum(len(R["Aprime"][s]) for s in NAMES)
|
|
print(f"\nALL SIX CORPORA ({n_all} problems):",
|
|
" ".join(f"{k} {tot[k]}" for k in ("Aprime", "A", "base", "chandrupatla", "modab", "brent", "toms748")))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|