Verify physical route clearance and board containment

This commit is contained in:
Jan Petykiewicz 2026-11-27 14:12:40 -08:00
commit c200d0f7c1

View file

@ -33,7 +33,6 @@ from inire.tests.routing_corpus import (
)
if TYPE_CHECKING:
from shapely.geometry import Polygon
from inire import CapacityLimit, RoutingProblem, RoutingTiming, TopologyReport
from inire.router._routing_policy import Trial
from inire.tests.routing_benchmark_case import BenchmarkCase
@ -76,13 +75,13 @@ def _mode_options(options: RoutingOptions, strategy: str, profile: str = "matche
return replace(options, topology=replace(options.topology, mode="off" if strategy in POLICIES else strategy))
def _order_trials(problem: RoutingProblem, board: Polygon, options: RoutingOptions, strategy: str) -> list[Trial]:
def _order_trials(problem: RoutingProblem, options: RoutingOptions, strategy: str) -> list[Trial]:
limit = options.search.node_limit
first_limit = max(1, limit // 2)
first_order = options.congestion.net_order
first_options = replace(options, search=replace(options.search, node_limit=first_limit), topology=replace(options.topology, mode="seed"))
run = route(problem, options=first_options)
first = _trial(run, RoutingStage("seed", (), run.metrics.nodes_expanded, first_limit, net_order=first_order), board)
first = _trial(run, RoutingStage("seed", (), run.metrics.nodes_expanded, first_limit, net_order=first_order))
if len(first.valid_costs) == len(problem.nets) or limit == 1:
return [first]
@ -112,7 +111,7 @@ def _order_trials(problem: RoutingProblem, board: Polygon, options: RoutingOptio
if strategy == "seed-order-locked":
run = replace(run, results_by_net={**incumbents, **run.results_by_net})
stage = RoutingStage("seed", (), run.metrics.nodes_expanded, second_limit, net_order=second_order, incumbent_net_ids=tuple(incumbents))
return [first, _trial(run, stage, board)]
return [first, _trial(run, stage)]
def _measure(case: BenchmarkCase, options: RoutingOptions, strategy: str) -> RunSample:
@ -161,16 +160,16 @@ def _measure(case: BenchmarkCase, options: RoutingOptions, strategy: str) -> Run
else:
bundle_duration = perf_counter() - started
stage = RoutingStage("bundle", (), run.metrics.nodes_expanded, options.search.node_limit, kind="bundle")
trials = [_trial(run, stage, board)]
trials = [_trial(run, stage)]
elif strategy in DIRECT_POLICIES:
problem = case.fixed_headings_problem()
trials = _direct_trials(problem, board, options, strategy)
elif strategy in ORDER_POLICIES:
problem = case.fixed_headings_problem()
trials = _order_trials(problem, board, options, strategy)
trials = _order_trials(problem, options, strategy)
else:
run = route(case.fixed_headings_problem(), options=options)
trials = [_trial(run, RoutingStage(strategy, (), run.metrics.nodes_expanded, options.search.node_limit), board)]
trials = [_trial(run, RoutingStage(strategy, (), run.metrics.nodes_expanded, options.search.node_limit))]
best = _best_trial(trials)
duration = perf_counter() - started
run = best.run