Skip unusable circular radii for residual doglegs
This commit is contained in:
parent
f2b646143f
commit
31ad878aeb
2 changed files with 22 additions and 1 deletions
|
|
@ -45,6 +45,12 @@ def residual_dogleg_candidates(problem: RoutingProblem, search: SearchOptions, *
|
||||||
end_x, end_y = map(int, project(net.target.x, net.target.y))
|
end_x, end_y = map(int, project(net.target.x, net.target.y))
|
||||||
if end_x <= start_x:
|
if end_x <= start_x:
|
||||||
return
|
return
|
||||||
|
circular = bend90_uses_circular_geometry(*resolve_bend_geometry(search))
|
||||||
|
radii = sorted({int(r) for r in search.bend_radii if isfinite(r) and r > 0 and r == int(r)})
|
||||||
|
if circular:
|
||||||
|
radii = [r for r in radii if bend_fits_width(r, net.width)]
|
||||||
|
if not radii:
|
||||||
|
return
|
||||||
half_width = net.width / 2
|
half_width = net.width / 2
|
||||||
pad = problem.clearance + half_width
|
pad = problem.clearance + half_width
|
||||||
_, floor_y, _, ceiling_y = extent(problem.bounds)
|
_, floor_y, _, ceiling_y = extent(problem.bounds)
|
||||||
|
|
@ -66,7 +72,6 @@ def residual_dogleg_candidates(problem: RoutingProblem, search: SearchOptions, *
|
||||||
lanes.update((floor(bottom), ceil(top)))
|
lanes.update((floor(bottom), ceil(top)))
|
||||||
lanes = {y for y in lanes if floor_y + half_width <= y <= ceiling_y - half_width}
|
lanes = {y for y in lanes if floor_y + half_width <= y <= ceiling_y - half_width}
|
||||||
ordered_lanes = sorted(lanes, key=lambda y: (abs(y - start_y) + abs(y - end_y), y))
|
ordered_lanes = sorted(lanes, key=lambda y: (abs(y - start_y) + abs(y - end_y), y))
|
||||||
radii = sorted({int(r) for r in search.bend_radii if isfinite(r) and r > 0 and r == int(r)})
|
|
||||||
seen: set[PathSeed] = set()
|
seen: set[PathSeed] = set()
|
||||||
|
|
||||||
def seed_pass(minimum: float) -> Iterator[PathSeed]:
|
def seed_pass(minimum: float) -> Iterator[PathSeed]:
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,22 @@ def test_residual_doglegs_prefer_the_lattice_minimum_but_can_relax_it(forward, n
|
||||||
assert any(length < OPTIONS.search.min_straight_length for length in lengths) is needs_short_straight
|
assert any(length < OPTIONS.search.min_straight_length for length in lengths) is needs_short_straight
|
||||||
|
|
||||||
|
|
||||||
|
def test_residual_doglegs_spend_attempts_only_on_radii_that_fit_the_trace() -> None:
|
||||||
|
trunk = NetSpec("trunk", Port(30, 100, 0), Port(270, 100, 0), width=30)
|
||||||
|
north = NetSpec("north", Port(20, 150, 90), Port(20, 200, 90))
|
||||||
|
rail = NetSpec("rail", Port(250, 200, 0), Port(300, 200, 0))
|
||||||
|
obstacles = (box(140, 93, 153, 107), *(box(x, 180, x + 2, 182) for x in range(70, 241, 20)))
|
||||||
|
problem = RoutingProblem((0, 0, 310, 230), (trunk, north, rail), obstacles, clearance=0)
|
||||||
|
options = replace(OPTIONS, search=replace(OPTIONS.search, bend_radii=(10, 20)))
|
||||||
|
|
||||||
|
run = route(problem, options=options)
|
||||||
|
|
||||||
|
assert run.automatic.selected_planner == "residual-dogleg"
|
||||||
|
assert all(result.is_valid for result in run.results_by_net.values())
|
||||||
|
segments = run.results_by_net[trunk.net_id].as_seed().segments
|
||||||
|
assert {move.radius for move in segments if isinstance(move, Bend90Seed)} == {20}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("requires_reservation", [False, True])
|
@pytest.mark.parametrize("requires_reservation", [False, True])
|
||||||
def test_paired_perimeter_plans_peer_reserved_detours_only_as_a_fallback(monkeypatch, requires_reservation) -> None:
|
def test_paired_perimeter_plans_peer_reserved_detours_only_as_a_fallback(monkeypatch, requires_reservation) -> None:
|
||||||
line = NetSpec("line", Port(5, 75, 0), Port(195, 75, 0))
|
line = NetSpec("line", Port(5, 75, 0), Port(195, 75, 0))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue