Simplify routing verification and isolate benchmark policies

This commit is contained in:
Jan Petykiewicz 2026-11-26 21:55:34 -08:00
commit ec2768853e

View file

@ -26,6 +26,7 @@ from inire.geometry.primitives import Port
from inire.results import RouteMetrics, _sum_route_metrics
from inire.router._astar_types import AStarContext, AStarMetrics
from inire.router._router import PathFinder
from inire.router._stack import build_routing_stack
from inire.router.cost import CostEvaluator
from inire.router.danger_map import DangerMap
from inire.tests.routing_corpus import SNAPSHOT_CASES, profile_options
@ -455,54 +456,59 @@ def _build_example_07_variant_stack(
capture_pre_pair_frontier_trace: bool = False,
) -> tuple[CostEvaluator, AStarMetrics, PathFinder]:
bounds = (0, 0, 1000, 1000)
obstacles = [
obstacles = (
box(450, 0, 550, 400),
box(450, 600, 550, 1000),
]
)
start_x = 50
start_y_base = 500 - (num_nets * 10.0) / 2.0
end_x = 950
end_y_base = 100
end_y_pitch = 800.0 / (num_nets - 1)
netlist = {}
nets = []
for index in range(num_nets):
sy = int(round(start_y_base + index * 10.0))
ey = int(round(end_y_base + index * end_y_pitch))
netlist[f"net_{index:02d}"] = (Port(start_x, sy, 0), Port(end_x, ey, 0))
widths = dict.fromkeys(netlist, 2.0)
_, evaluator, metrics, pathfinder = _build_routing_stack(
nets.append(NetSpec(f"net_{index:02d}", Port(start_x, sy, 0), Port(end_x, ey, 0)))
problem = RoutingProblem(
bounds=bounds,
netlist=netlist,
widths=widths,
nets=tuple(nets),
static_obstacles=obstacles,
clearance=6.0,
obstacles=obstacles,
evaluator_kwargs={
"greedy_h_weight": 1.5,
"unit_length_cost": 0.1,
"bend_penalty": 100.0,
"sbend_penalty": 400.0,
},
request_kwargs={
"node_limit": 2000000,
"bend_radii": [50.0],
"sbend_radii": [50.0],
"bend_clip_margin": 10.0,
"max_iterations": 15,
"base_penalty": 100.0,
"multiplier": 1.4,
"net_order": "shortest",
"capture_expanded": True,
"capture_conflict_trace": capture_conflict_trace,
"capture_frontier_trace": capture_frontier_trace,
"capture_iteration_trace": capture_iteration_trace,
"capture_pre_pair_frontier_trace": capture_pre_pair_frontier_trace,
"shuffle_nets": True,
"seed": seed,
"warm_start_enabled": warm_start_enabled,
},
)
return evaluator, metrics, pathfinder
options = RoutingOptions(
search=SearchOptions(
node_limit=2_000_000,
bend_radii=(50.0,),
sbend_radii=(50.0,),
greedy_h_weight=1.5,
bend_clip_margin=10.0,
),
objective=ObjectiveWeights(
unit_length_cost=0.1,
bend_penalty=100.0,
sbend_penalty=400.0,
),
congestion=CongestionOptions(
max_iterations=15,
base_penalty=100.0,
multiplier=1.4,
net_order="shortest",
shuffle_nets=True,
seed=seed,
warm_start_enabled=warm_start_enabled,
),
diagnostics=DiagnosticsOptions(
capture_expanded=True,
capture_conflict_trace=capture_conflict_trace,
capture_frontier_trace=capture_frontier_trace,
capture_iteration_trace=capture_iteration_trace,
capture_pre_pair_frontier_trace=capture_pre_pair_frontier_trace,
),
)
stack = build_routing_stack(problem, options)
return stack.evaluator, stack.finder.metrics, stack.finder
def _run_example_07_variant(