265 lines
8 KiB
Python
265 lines
8 KiB
Python
"""Feasible placements reserved for evaluating experimental retry orders."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from shapely.geometry import box
|
|
|
|
from inire.tests.routing_crossing_benchmarks import _crossing_keepout
|
|
from inire.tests.stress_routing_benchmarks import _Track, _waypoint_case
|
|
|
|
if TYPE_CHECKING:
|
|
from shapely.geometry import Polygon
|
|
|
|
from inire.tests.routing_benchmark_case import BenchmarkCase
|
|
|
|
|
|
def _shelf(
|
|
name: str,
|
|
description: str,
|
|
*,
|
|
width: int,
|
|
wall: tuple[int, int, int],
|
|
bay: tuple[int, int, int],
|
|
launch: tuple[int, int],
|
|
arrival: tuple[int, int],
|
|
radius: int = 20,
|
|
side_block: tuple[Polygon, ...] = (),
|
|
) -> BenchmarkCase:
|
|
wall_left, wall_right, wall_bottom = wall
|
|
left_turn, right_turn, bottom = bay
|
|
x_start, y_start = launch
|
|
x_finish, y_finish = arrival
|
|
return _waypoint_case(
|
|
f"retry-holdout-{name}",
|
|
description,
|
|
(0, 0, width, 520),
|
|
(
|
|
box(wall_left, wall_bottom, wall_right, 520),
|
|
box(260, 127, 353, 154),
|
|
*side_block,
|
|
),
|
|
(
|
|
_Track(
|
|
"fold",
|
|
(
|
|
(x_start, y_start),
|
|
(width - 67, y_start),
|
|
(width - 67, 414),
|
|
(right_turn, 414),
|
|
(right_turn, bottom),
|
|
(left_turn, bottom),
|
|
(left_turn, 414),
|
|
(138, 414),
|
|
(138, y_finish),
|
|
(x_finish, y_finish),
|
|
),
|
|
),
|
|
_Track("edge", ((212, 278), (x_finish + 49, 278)), width=4),
|
|
_Track("lower", ((x_finish + 26, 171), (61, 171))),
|
|
_Track("east", ((width - 116, 461), (right_turn + 58, 461))),
|
|
),
|
|
radius=radius,
|
|
extra_bend_radius=radius + 7,
|
|
)
|
|
|
|
|
|
def _crossing_detour(
|
|
name: str,
|
|
description: str,
|
|
*,
|
|
left: int,
|
|
right: int,
|
|
level: int,
|
|
width: int,
|
|
floor: tuple[int, int],
|
|
left_turn: int,
|
|
right_turn: int,
|
|
extra: tuple[Polygon, ...] = (),
|
|
reverse: frozenset[str] = frozenset(),
|
|
) -> BenchmarkCase:
|
|
floor_bottom, floor_top = floor
|
|
outside_y = level - 50
|
|
tracks = (
|
|
_Track("west_link", ((30, level - 20), (left - 112, level - 20), (left - 72, level), (left - 14, level)), radius=25),
|
|
_Track("device_link", ((left + 14, level), (right - 14, level))),
|
|
_Track("east_link", ((right + 14, level), (right + 97, level), (right + 137, level + 20), (width - 46, level + 20)), radius=25),
|
|
_Track("west_south", ((left, floor_top + 8), (left, level - 14))),
|
|
_Track("east_south", ((right, level - 14), (right, floor_top + 9))),
|
|
_Track("west_north", ((left, level + 14), (left, level + 48), (left - 20, level + 88), (left - 20, level + 141)), radius=25),
|
|
_Track("east_north", ((right + 20, level + 138), (right + 20, level + 84), (right, level + 44), (right, level + 14)), radius=25),
|
|
_Track(
|
|
"outside_lower",
|
|
(
|
|
(35, outside_y),
|
|
(left_turn, outside_y),
|
|
(left_turn, floor_bottom - 23),
|
|
(right_turn, floor_bottom - 23),
|
|
(right_turn, outside_y),
|
|
(width - 38, outside_y),
|
|
),
|
|
width=4,
|
|
),
|
|
_Track("outside_upper", ((width - 37, level + 177), (33, level + 177))),
|
|
)
|
|
ordered = tuple(
|
|
_Track(track.name, tuple(reversed(track.points)), track.width, track.radius) if track.name in reverse else track for track in tracks
|
|
)
|
|
return _waypoint_case(
|
|
f"retry-holdout-{name}",
|
|
description,
|
|
(0, 0, width, level + 230),
|
|
(
|
|
_crossing_keepout(left, level),
|
|
_crossing_keepout(right, level),
|
|
box(left - 57, floor_bottom, right + 64, floor_top),
|
|
box(left - 122, level + 37, left - 79, level + 81),
|
|
*extra,
|
|
),
|
|
ordered,
|
|
sbend_radius=25,
|
|
clearance=4,
|
|
)
|
|
|
|
|
|
def _competing_lock(
|
|
name: str,
|
|
description: str,
|
|
*,
|
|
inset: int,
|
|
radius: int,
|
|
top_detour: bool,
|
|
branch_stagger: int,
|
|
obstacles: tuple[Polygon, ...],
|
|
reverse: bool = False,
|
|
) -> BenchmarkCase:
|
|
y = 190
|
|
detour_y = 296 if top_detour else 68
|
|
branch_start, branch_end = 137 - branch_stagger, 241 + branch_stagger
|
|
points = ((inset, y), (78, y), (78, detour_y), (461, detour_y), (461, y), (550 - inset, y))
|
|
trunk = _Track("trunk", tuple(reversed(points)) if reverse else points, width=4)
|
|
return _waypoint_case(
|
|
f"retry-holdout-{name}",
|
|
description,
|
|
(0, 0, 550, 365),
|
|
obstacles,
|
|
(
|
|
trunk,
|
|
_Track("west_branch", ((241, branch_start), (241, branch_end))),
|
|
_Track("east_branch", ((302, branch_end - 4), (302, branch_start + 7)), width=3),
|
|
_Track("upper", ((31, 331), (513, 331))),
|
|
_Track("lower", ((508, 38), (30, 38))),
|
|
),
|
|
radius=radius,
|
|
clearance=5,
|
|
)
|
|
|
|
|
|
RETRY_HOLDOUT_CASES = (
|
|
_shelf(
|
|
"stepped-roof",
|
|
"A widened roof and shifted return bay with a second right-hand obstacle",
|
|
width=850,
|
|
wall=(431, 529, 332),
|
|
bay=(386, 570, 310),
|
|
launch=(675, 148),
|
|
arrival=(572, 236),
|
|
side_block=(box(651, 257, 704, 308),),
|
|
),
|
|
_shelf(
|
|
"deep-roof",
|
|
"A deeper roof and a longer western run past a mixed-width shelf edge",
|
|
width=823,
|
|
wall=(448, 511, 324),
|
|
bay=(400, 553, 298),
|
|
launch=(654, 153),
|
|
arrival=(579, 221),
|
|
radius=22,
|
|
),
|
|
_shelf(
|
|
"west-roof",
|
|
"A western roof position with uneven reach and a blocked approach above the return",
|
|
width=835,
|
|
wall=(391, 489, 321),
|
|
bay=(347, 535, 298),
|
|
launch=(655, 159),
|
|
arrival=(574, 233),
|
|
side_block=(box(188, 335, 230, 361),),
|
|
),
|
|
_crossing_detour(
|
|
"stretched-crossings",
|
|
"A long center link and a raised floor between differently spaced crossing ports",
|
|
left=234,
|
|
right=399,
|
|
level=198,
|
|
width=680,
|
|
floor=(80, 96),
|
|
left_turn=104,
|
|
right_turn=557,
|
|
),
|
|
_crossing_detour(
|
|
"floor-pocket",
|
|
"An extra keepout inside the lower detour and staggered port access",
|
|
left=216,
|
|
right=366,
|
|
level=187,
|
|
width=648,
|
|
floor=(70, 84),
|
|
left_turn=99,
|
|
right_turn=527,
|
|
extra=(box(128, 98, 162, 118),),
|
|
),
|
|
_crossing_detour(
|
|
"reversed-bank",
|
|
"Two reversed links compete with an offset lower approach",
|
|
left=231,
|
|
right=374,
|
|
level=193,
|
|
width=657,
|
|
floor=(71, 88),
|
|
left_turn=105,
|
|
right_turn=520,
|
|
reverse=frozenset({"outside_lower", "east_link", "west_north"}),
|
|
),
|
|
_crossing_detour(
|
|
"tight-right-bank",
|
|
"A short right bypass and an irregular gap beside the south approach",
|
|
left=219,
|
|
right=382,
|
|
level=191,
|
|
width=625,
|
|
floor=(66, 80),
|
|
left_turn=100,
|
|
right_turn=538,
|
|
extra=(box(321, 100, 340, 130),),
|
|
),
|
|
_competing_lock(
|
|
"sealed-trunk",
|
|
"A near-boundary trunk can seal two short perpendicular branches",
|
|
inset=2,
|
|
radius=20,
|
|
top_detour=False,
|
|
branch_stagger=0,
|
|
obstacles=(box(167, 101, 196, 119),),
|
|
),
|
|
_competing_lock(
|
|
"turn-limited-trunk",
|
|
"Topologically connected side gaps are too narrow for a branch turn",
|
|
inset=12,
|
|
radius=27,
|
|
top_detour=True,
|
|
branch_stagger=5,
|
|
obstacles=(box(346, 237, 381, 261),),
|
|
),
|
|
_competing_lock(
|
|
"offset-trunk",
|
|
"An offset return has wider side room and two independently routed branches",
|
|
inset=29,
|
|
radius=18,
|
|
top_detour=False,
|
|
branch_stagger=12,
|
|
reverse=True,
|
|
obstacles=(box(127, 103, 170, 125), box(374, 248, 409, 268)),
|
|
),
|
|
)
|