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

@ -154,7 +154,7 @@ class _AutomaticRun:
def _trial(self, run: RoutingRunResult, stage: RoutingStage) -> Trial:
with self._time("verify", planner=stage.planner, mode=stage.mode, policy=stage.policy):
return _trial(run, stage, self.board, score=self._selection_cost)
return _trial(run, stage, score=self._selection_cost)
def _seeded_problem(self, trial: Trial) -> RoutingProblem:
seeds = {net_id: trial.run.results_by_net[net_id].as_seed() for net_id in trial.valid_costs}
@ -267,7 +267,7 @@ class _AutomaticRun:
problem, options = self.problem, self.options
if len(problem.nets) != 2:
return
world = RoutingWorld(clearance=problem.clearance, safety_zone_radius=problem.safety_zone_radius)
world = RoutingWorld(clearance=problem.clearance, safety_zone_radius=problem.safety_zone_radius, board=self.board)
for obstacle in problem.static_obstacles:
world.add_static_obstacle(obstacle)
@ -278,8 +278,7 @@ class _AutomaticRun:
if not path or path[-1].end_port != net.target or not world.verify_path_report(net.net_id, path).is_valid:
continue
footprint = shapely.union_all([shape for component in path for shape in component.physical_geometry])
if self.board.covers(footprint):
choices.append((seed, footprint))
choices.append((seed, footprint))
return choices
candidates: list[list[tuple[PathSeed, BaseGeometry]]] = []
@ -589,7 +588,7 @@ class _AutomaticRun:
policy=best.stage.policy,
operation="refine",
)
# Audit the merged result so the stage still reports unresolved routes outside the board.
# Keep reports for unresolved routes when merging the refined subset.
results = {**best.run.results_by_net, **run.results_by_net}
refined = self._trial(replace(run, results_by_net=results), stage)
# Only a whole verified replacement of the incumbent can win.