Skip refinement setup for paths with too few bends
This commit is contained in:
parent
16145714a8
commit
a4c76f3a68
3 changed files with 30 additions and 10 deletions
|
|
@ -1068,7 +1068,7 @@ class PathFinder:
|
||||||
|
|
||||||
for net_id in state.ordered_net_ids:
|
for net_id in state.ordered_net_ids:
|
||||||
result = state.results.get(net_id)
|
result = state.results.get(net_id)
|
||||||
if not result or not result.path or result.outcome in {"colliding", "partial", "unroutable"}:
|
if not result or not result.is_valid or not self.refiner.has_refinement_bends(result.path):
|
||||||
continue
|
continue
|
||||||
net = state.net_specs[net_id]
|
net = state.net_specs[net_id]
|
||||||
self.metrics.total_refine_path_calls += 1
|
self.metrics.total_refine_path_calls += 1
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,10 @@ class PathRefiner:
|
||||||
return None
|
return None
|
||||||
return best_path, best_candidate_cost
|
return best_path, best_candidate_cost
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def has_refinement_bends(path: Sequence[ComponentResult]) -> bool:
|
||||||
|
return len(path) >= 4 and sum(component.move_type == "bend90" for component in path) >= 4
|
||||||
|
|
||||||
def refine_path(
|
def refine_path(
|
||||||
self,
|
self,
|
||||||
net_id: str,
|
net_id: str,
|
||||||
|
|
@ -320,16 +324,10 @@ class PathRefiner:
|
||||||
net_width: float,
|
net_width: float,
|
||||||
path: Sequence[ComponentResult],
|
path: Sequence[ComponentResult],
|
||||||
) -> list[ComponentResult]:
|
) -> list[ComponentResult]:
|
||||||
if not path:
|
if not self.has_refinement_bends(path):
|
||||||
return list(path)
|
return list(path)
|
||||||
|
|
||||||
path = list(path)
|
best_path = list(path)
|
||||||
|
|
||||||
bend_count = sum(1 for comp in path if comp.move_type == "bend90")
|
|
||||||
if bend_count < 4:
|
|
||||||
return path
|
|
||||||
|
|
||||||
best_path = path
|
|
||||||
best_cost = self.score_path(start, path)
|
best_cost = self.score_path(start, path)
|
||||||
remaining = self.context.options.refinement.max_windows_per_net
|
remaining = self.context.options.refinement.max_windows_per_net
|
||||||
incumbent_valid = None
|
incumbent_valid = None
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from inire import RoutingOptions, RoutingProblem, SearchOptions
|
import pytest
|
||||||
|
|
||||||
|
from inire import CongestionOptions, RoutingOptions, RoutingProblem, SearchOptions, TopologyOptions, route
|
||||||
from inire.geometry.collision import RoutingWorld
|
from inire.geometry.collision import RoutingWorld
|
||||||
from inire.geometry.components import Bend90
|
from inire.geometry.components import Bend90
|
||||||
from inire.geometry.primitives import Port
|
from inire.geometry.primitives import Port
|
||||||
|
|
@ -47,6 +49,26 @@ def test_arc_resolution_sagitta() -> None:
|
||||||
assert pts_fine > pts_coarse
|
assert pts_fine > pts_coarse
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(("offset", "move_type"), [(0, "straight"), (5, "sbend")])
|
||||||
|
def test_refinement_leaves_simple_paths_installed(offset: int, move_type: str) -> None:
|
||||||
|
problem = RoutingProblem(
|
||||||
|
bounds=(0, 0, 120, 120),
|
||||||
|
nets=(NetSpec("out", Port(10, 50, 0), Port(110, 50 + offset, 0)),),
|
||||||
|
)
|
||||||
|
options = RoutingOptions(
|
||||||
|
search=SearchOptions(bend_radii=(10.0,), sbend_radii=(10.0,)),
|
||||||
|
congestion=CongestionOptions(warm_start_enabled=False),
|
||||||
|
topology=TopologyOptions(mode="off"),
|
||||||
|
)
|
||||||
|
|
||||||
|
run = route(problem, options=options)
|
||||||
|
|
||||||
|
assert run.results_by_net["out"].is_valid
|
||||||
|
assert run.results_by_net["out"].path[-1].move_type == move_type
|
||||||
|
assert run.metrics.refine_path_calls == 0
|
||||||
|
assert run.metrics.dynamic_path_objects_removed == 0
|
||||||
|
|
||||||
|
|
||||||
def test_locked_routes() -> None:
|
def test_locked_routes() -> None:
|
||||||
engine = RoutingWorld(clearance=2.0)
|
engine = RoutingWorld(clearance=2.0)
|
||||||
danger_map = DangerMap(bounds=(0, -50, 100, 50))
|
danger_map = DangerMap(bounds=(0, -50, 100, 50))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue