Allow column jog seeds beyond the lattice scan length

This commit is contained in:
Jan Petykiewicz 2026-11-30 11:24:56 -08:00
commit 90b30608f6
2 changed files with 22 additions and 2 deletions

View file

@ -678,7 +678,7 @@ def _jog_seeds(
points.reverse() points.reverse()
seed, end = compile_waypoints(tuple(points), track.net.start, radius) seed, end = compile_waypoints(tuple(points), track.net.start, radius)
if end != track.net.target or any( if end != track.net.target or any(
isinstance(move, StraightSeed) and not search.min_straight_length <= move.length <= search.max_straight_length isinstance(move, StraightSeed) and move.length < search.min_straight_length
for move in seed.segments for move in seed.segments
): ):
return None return None

View file

@ -3,7 +3,9 @@ from unittest.mock import Mock
import pytest import pytest
from shapely.geometry import box from shapely.geometry import box
from inire import CongestionOptions, NetSpec, Port, RefinementOptions, RoutingOptions, RoutingProblem, SBendSeed, SearchOptions, route from inire import (
CongestionOptions, NetSpec, Port, RefinementOptions, RoutingOptions, RoutingProblem, SBendSeed, SearchOptions, StraightSeed, route,
)
from inire.geometry import sbend from inire.geometry import sbend
from inire.geometry.sbend import exact_sbend_spans from inire.geometry.sbend import exact_sbend_spans
from inire.router import _columns from inire.router import _columns
@ -304,3 +306,21 @@ def test_sbend_column_passes_reuse_profiles_and_skip_duplicate_span_sets(monkeyp
def test_jog_transition_rejects_an_offset_that_cannot_fit_two_bends() -> None: def test_jog_transition_rejects_an_offset_that_cannot_fit_two_bends() -> None:
assert _jog_pivots((10, 40), (17, 40), (0, 100), (2, 2), 2, 5, 1) is None assert _jog_pivots((10, 40), (17, 40), (0, 100), (2, 2), 2, 5, 1) is None
assert _jog_pivots((10, 40), (25, 40), (0, 100), (2, 2), 2, 5, 1) == (8, None) assert _jog_pivots((10, 40), (25, 40), (0, 100), (2, 2), 2, 5, 1) == (8, None)
def test_column_jog_seeds_can_use_straights_longer_than_the_lattice_scan() -> None:
nets = tuple(NetSpec(str(y), Port(5, y, 0), Port(405, y + 50, 0)) for y in (60, 150, 240))
problem = RoutingProblem((0, 0, 420, 310), nets, (box(170, 0, 190, 20),), clearance=0)
options = RoutingOptions(
search=SearchOptions(node_limit=1, bend_radii=(10,), sbend_radii=(), max_straight_length=40),
congestion=CongestionOptions(max_iterations=1, warm_start_enabled=False),
refinement=RefinementOptions(enabled=False),
)
run = route(problem, options=options)
assert run.automatic.selected_planner == "column-jogs"
assert run.metrics.nodes_expanded == 0
for result in run.results_by_net.values():
assert result.is_valid
assert any(isinstance(move, StraightSeed) and move.length > 40 for move in result.as_seed().segments)