Refactor routing internals and archive retry benchmarks

This commit is contained in:
Jan Petykiewicz 2026-11-26 19:58:46 -08:00
commit ea5cfe7f31

View file

@ -10,6 +10,7 @@ from shapely.geometry import box
from inire import TopologyOptions, route
from inire.router._waypoints import export_waypoints
from inire.router.cost import weighted_path_length
from inire.tests.terminal_bench_scenario import LENGTH_COST, terminal_bench_options, terminal_bench_problem
@ -39,9 +40,9 @@ def main() -> None:
if not result.is_valid or any(not board.covers(shape) for shape in result.locked_geometry):
parser.exit(1, f"Lane plan failed inire verification for {net_id}\n")
cost = sum(component.length * LENGTH_COST[component.move_type] for result in run.results_by_net.values() for component in result.path)
cost = weighted_path_length((component for result in run.results_by_net.values() for component in result.path), LENGTH_COST)
total = len(problem.nets)
print(f"{total}/{total} verified, weighted cost {cost:.2f}, {run.metrics.nodes_expanded} A* expansions, {elapsed:.3f} s")
print(f"{total}/{total} verified, benchmark-weighted length {cost:.2f}, {run.metrics.nodes_expanded} A* expansions, {elapsed:.3f} s")
if args.output is not None:
waypoints = {net_id: export_waypoints(result.path) for net_id, result in run.results_by_net.items()}
args.output.write_text(dumps({"nets": {net_id: {"waypoints": path} for net_id, path in waypoints.items()}}, indent=2) + "\n")