summaryrefslogtreecommitdiff
path: root/src/eval_tune/compare_ecm_depth.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval_tune/compare_ecm_depth.py')
-rw-r--r--src/eval_tune/compare_ecm_depth.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/eval_tune/compare_ecm_depth.py b/src/eval_tune/compare_ecm_depth.py
new file mode 100644
index 0000000..51329a7
--- /dev/null
+++ b/src/eval_tune/compare_ecm_depth.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+"""Pair up per-problem achieved-depth (final iterated depth reached before
+the node-count budget ran out) from two sn=N ECM stdout logs (same input
+file, same order) and report win/loss/tie counts plus median depth delta.
+"""
+import re
+import statistics
+import sys
+
+TELL_RE = re.compile(r"tellothers d(\d+),")
+
+
+def parse(path):
+ """Return list of achieved-depth ints, one per completed problem, in order."""
+ depths = []
+ with open(path) as f:
+ for line in f:
+ m = TELL_RE.search(line)
+ if m:
+ depths.append(int(m.group(1)))
+ return depths
+
+
+def main():
+ base_path, cand_path = sys.argv[1], sys.argv[2]
+ base = parse(base_path)
+ cand = parse(cand_path)
+ n = min(len(base), len(cand))
+ base, cand = base[:n], cand[:n]
+
+ deltas = [c - b for b, c in zip(base, cand)]
+ wins = sum(1 for d in deltas if d > 0)
+ losses = sum(1 for d in deltas if d < 0)
+ ties = sum(1 for d in deltas if d == 0)
+
+ print(f"Paired problems: {n}")
+ print(f" candidate deeper: {wins}")
+ print(f" candidate shallower: {losses}")
+ print(f" tied depth: {ties}")
+ print(f" median depth delta (candidate - baseline): {statistics.median(deltas):+.1f}")
+ print(f" mean depth delta: {statistics.mean(deltas):+.3f}")
+ print(f" sum of depth delta: {sum(deltas):+d}")
+
+
+if __name__ == "__main__":
+ main()