Add --reduce-vias and --via-cost to the exact engine

--reduce-vias is a last stage: each net that has vias is routed again on
its own with vias made eight times dearer, everything else held as fixed
copper (the window stage's board), and its new copper is kept only if the
net fails nothing new and has fewer vias; the nets with the most vias go
first, within a share of the routing's own time. --via-cost exposes the
search's layer-change price (default 10 grid steps). bench.py records
each run's via count and prints via totals per variant.
This commit is contained in:
2026-10-07 20:06:00 -06:00
parent 1852df3d53
commit 8cb7a627f0
6 changed files with 346 additions and 3 deletions
+16 -1
View File
@@ -100,13 +100,18 @@ def run_one(board, variant, seed: int, timeout: float) -> dict:
)
rss_mb = round(usage.ru_maxrss / 1024)
secs = round(time.monotonic() - start, 1)
try:
with open(f"{tmp}/out.ses", encoding="utf-8") as f:
vias = f.read().count("(via ")
except OSError:
vias = None
missing = NOT_ROUTED.search(err)
zone = TO_ZONE.search(err)
return {
"board": name, "variant": vname, "seed": seed, "status": status,
"unrouted": int(missing.group(1)) if missing else 0,
"to_zone": int(zone.group(1)) if zone else 0,
"secs": secs, "rss_mb": rss_mb,
"secs": secs, "rss_mb": rss_mb, "vias": vias,
"tail": err.strip().splitlines()[-1] if status != "ok" and err.strip() else "",
}
@@ -147,6 +152,16 @@ def report(rows: list[dict], boards, variants) -> None:
line += (f" {dm:+.1f} ± {se:.1f} ({better} better, {worse} worse,"
f" {len(diffs) - better - worse} same) {verdict}")
print(line)
# vias, where the runs recorded them (older result files did not)
print("\nvias per variant, summed over boards (mean over seeds per board)\n")
for vname, _, _ in variants:
total, boards_counted = 0.0, 0
for bname, _, _ in boards:
vs = [r["vias"] for k, r in ok.items() if k[:2] == (bname, vname) and r.get("vias") is not None]
if vs:
total += sum(vs) / len(vs)
boards_counted += 1
print(f"{vname:14} {total:8.1f} vias over {boards_counted} boards")
failed = [r for r in rows if r["status"] != "ok"]
for r in failed:
print(f"FAILED {r['board']} {r['variant']} seed {r['seed']}: {r['status']} {r['tail']}")