diff --git a/inire/router/_compact.py b/inire/router/_compact.py index c55b2ae..f7a5c64 100644 --- a/inire/router/_compact.py +++ b/inire/router/_compact.py @@ -168,10 +168,8 @@ def compact_port_seed_set(problem: RoutingProblem, search: SearchOptions) -> dic def _shift_seeds(forward: int, offset: int, search: SearchOptions) -> Iterator[PathSeed]: - minimum, maximum = search.min_straight_length, search.max_straight_length if offset == 0: - if minimum <= forward <= maximum: - yield _path(forward) + yield _path(forward) return if not search.allows_sbend_offset(offset): return @@ -187,9 +185,7 @@ def _shift_seeds(forward: int, offset: int, search: SearchOptions) -> Iterator[P continue placements = {i * spare // 8 for i in range(9)} for lead in sorted(placements, key=lambda distance: (abs(2 * distance - spare), distance)): - tail = spare - lead - if all(not length or minimum <= length <= maximum for length in (lead, tail)): - yield _path(lead, SBendSeed(offset, radius), tail) + yield _path(lead, SBendSeed(offset, radius), spare - lead) def short_shift_seed_set(problem: RoutingProblem, search: SearchOptions, score: Scorer) -> dict[str, PathSeed] | None: diff --git a/inire/tests/test_compact.py b/inire/tests/test_compact.py index 4f2a93d..7373658 100644 --- a/inire/tests/test_compact.py +++ b/inire/tests/test_compact.py @@ -1,3 +1,5 @@ +import pytest + from inire import CongestionOptions, NetSpec, Port, RefinementOptions, RoutingOptions, RoutingProblem, SBendSeed, SearchOptions, route @@ -37,3 +39,23 @@ def test_local_sbend_packing_skips_intersecting_candidates_at_zero_clearance() - assert all(result.is_valid for result in run.results_by_net.values()) assert run.automatic.selected_planner == "local-sbend" assert run.metrics.nodes_expanded == 0 + + + +@pytest.mark.parametrize(("forward", "scan_limit"), [(18, 2000), (14, 20)], ids=["short-tangents", "long-straight"]) +def test_local_sbend_seeds_can_use_straights_outside_lattice_scan_limits(forward, scan_limit) -> None: + east = NetSpec("east", Port(10, 10, 0), Port(10 + forward, 15, 0)) + north = NetSpec("north", Port(70, 10, 90), Port(65, 10 + forward, 90)) + line = NetSpec("line", Port(10, 40, 0), Port(40, 40, 0)) + problem = RoutingProblem((0, 0, 100, 100), (east, north, line), clearance=0) + options = RoutingOptions( + search=SearchOptions(node_limit=1, bend_radii=(), sbend_radii=(10,), min_straight_length=5, max_straight_length=scan_limit), + congestion=CongestionOptions(max_iterations=1, warm_start_enabled=False), + refinement=RefinementOptions(enabled=False), + ) + + run = route(problem, options=options) + + assert all(run.results_by_net[net.net_id].is_valid for net in problem.nets) + assert run.automatic.selected_planner == "local-sbend" + assert run.metrics.nodes_expanded == 0