Verify route continuity and simplify automatic search setup

This commit is contained in:
Jan Petykiewicz 2026-11-27 15:21:37 -08:00
commit def1e4ea1d
2 changed files with 489 additions and 103 deletions

View file

@ -8,14 +8,14 @@ Import these types from `inire`. To see how the inputs fit together in a runnabl
route(problem, *, options=None, iteration_callback=None) -> RoutingRunResult
```
Omitting `options` uses `RoutingOptions()`. To observe progress, pass a callable accepting `(index, results_by_net)`. Each call reports one completed congestion iteration on the nets in that attempt. Automatic mode keeps increasing the index across attempts. Check the returned result for final coverage, including on runs that finish without a callback.
Omitting `options` uses `RoutingOptions()`. To observe progress, pass a callable accepting `(index, results_by_net)`. Each call receives a snapshot of the nets in one completed congestion iteration. Automatic mode keeps increasing the index across attempts and uses the same planner order with or without a callback. Check the returned result for final coverage, including on runs that finish without a callback.
## Layout inputs
### Ports and nets
- `Port(x, y, r)` rounds coordinates to integers. The heading `r` is in degrees, with 0 east, 90 north, 180 west, and 270 south. The rounded angle must be a multiple of 90 and is wrapped to the range 0–359.
- `NetSpec(net_id, start, target, width=2.0)` uses a unique ID and two ports. Set the start heading to the direction of departure and the target heading to the direction of arrival.
- `NetSpec(net_id, start, target, width=2.0)` uses a unique ID, two ports, and a finite positive width. Set the start heading to the direction of departure and the target heading to the direction of arrival.
### RoutingProblem
@ -23,16 +23,16 @@ The fields below appear in constructor order. Use one layout unit for coordinate
| Field | Default | Meaning |
| --- | --- | --- |
| `bounds` | Required | Board rectangle as `(xmin, ymin, xmax, ymax)`. |
| `bounds` | Required | Finite board rectangle as `(xmin, ymin, xmax, ymax)`, with each minimum below its maximum. |
| `nets` | `()` | Sequence of `NetSpec` objects with unique IDs. Duplicate IDs raise `ValueError`. |
| `static_obstacles` | `()` | Shapely polygons that define keepouts. |
| `initial_paths` | Empty mapping | Net IDs mapped to `PathSeed` objects. |
| `clearance` | `2.0` | Required spacing between physical shapes. |
| `clearance` | `2.0` | Finite, nonnegative spacing required between physical shapes. |
| `safety_zone_radius` | `0.0021` | Tolerance for small obstacle intersections at a move's endpoints during search. |
## Path seeds
`PathSeed(segments)` holds an ordered tuple of `StraightSeed(length)`, `Bend90Seed(radius, direction)`, and `SBendSeed(offset, radius)` moves. Bend directions are `"CW"` and `"CCW"`. A seed is materialized from the net's current start port using its width and the run's geometry options. For a workflow that starts from an existing route, see [Reuse an existing route](route-a-layout.md#reuse-an-existing-route).
`PathSeed(segments)` holds an ordered tuple of `StraightSeed(length)`, `Bend90Seed(radius, direction)`, and `SBendSeed(offset, radius)` moves. Lengths and radii must be finite and positive. Bend directions are `"CW"` and `"CCW"`. S-bend offsets must be nonzero integers with magnitude less than twice the radius. A seed is materialized from the net's current start port using its width and the run's geometry options. Search skips seeds with a bend radius below half the net width. For a workflow that starts from an existing route, see [Reuse an existing route](route-a-layout.md#reuse-an-existing-route).
## Results
@ -42,7 +42,7 @@ The fields below appear in constructor order. Use one layout unit for coordinate
| `RoutingResult.is_valid` and `outcome` | `is_valid` is true when the outcome is `completed`. Read `outcome` to distinguish success, a failed geometry check (`colliding`), a path that stopped short (`partial`), or an empty path (`unroutable`). |
| `RoutingResult.path` | Ordered path components from the source to the last reached state. An unroutable result has an empty path. |
| `RoutingResult.reached_target` | Whether the path reached the target position and heading. With heading inference, the check uses the chosen heading. Read `is_valid` for the result of geometry verification. |
| `RoutingResult.report` | `total_length` in layout units plus static, dynamic, and self-collision counts. `out_of_bounds` indicates that physical geometry extends outside the board rectangle. |
| `RoutingResult.report` | `total_length` in layout units plus static, dynamic, and self-collision counts. `out_of_bounds` flags geometry outside the board. `discontinuous` flags missing or point-only joins, including at terminal faces. `invalid_geometry` flags invalid or empty physical polygons. |
| `RoutingResult.locked_geometry` and `as_seed()` | Physical polygons and the sequence of moves, respectively. Check validity before exporting polygons or using them as keepouts. |
| `RoutingRunResult.automatic` | In automatic mode, the selected planner, verified IDs, stage history, and any capacity or port-conflict bound. `None` for explicit modes. |
| `RoutingRunResult.topology` and `metrics` | Corridor counts and seed work when reported by the selected worker, plus work counters across the run. |
@ -70,9 +70,9 @@ To read a route's polygons and write them to a test file, follow the [geometry e
| `min_straight_length` | `5.0` | Minimum length for regular forward moves in lattice search. |
| `max_straight_length` | `2000.0` | Maximum distance the forward scan uses to propose straight moves in lattice search. |
| `greedy_h_weight` | `1.5` | Weight on the estimated cost still needed to reach the target. Lower values give more influence to the cost of the path so far. |
| `bend_radii` | `(50.0, 100.0)` | Permitted radii for 90-degree bends. |
| `sbend_radii` | `(10.0,)` | Permitted S-bend radii. |
| `sbend_offsets` | `None` | Set permitted lateral offsets explicitly, or let search suggest offsets. A compact S-bend needs a nonzero offset with magnitude less than twice its radius. |
| `bend_radii` | `(50.0, 100.0)` | Permitted radii for 90-degree bends. Each move needs a radius of at least half its net width. |
| `sbend_radii` | `(10.0,)` | Permitted S-bend radii, subject to the same width requirement. |
| `sbend_offsets` | `None` | `None` lets the router choose signed lateral offsets. An explicit list restricts routing and seeds to those offsets after rounding to the grid. An empty list disables S-bends. |
| `bend_collision_type` | `"arc"` | Search proxy, one of `"arc"`, `"bbox"`, or `"clipped_bbox"`. The legacy polygon form defines both shapes unless split geometry is supplied. |
| `bend_proxy_geometry` | `None` | Override the proxy. A custom polygon proxy by itself keeps the standard physical arc and emits a warning. |
| `bend_physical_geometry` | `None` | Override the physical geometry with `"arc"` or a polygon. A custom physical polygon also supplies the default proxy when the collision type is `"arc"`. |
@ -96,7 +96,7 @@ Increase the iteration limit when later reroutes might resolve conflicts. Adjust
| Field | Default | Effect |
| --- | --- | --- |
| `max_iterations` | `10` | Maximum congestion iterations per attempt. Automatic's initial probe may use fewer. |
| `max_iterations` | `10` | Maximum congestion iterations per attempt. Automatic's initial probe may use fewer. Zero skips warm-start and corridor searches. |
| `base_penalty` | `100.0` | Initial penalty for overlapping other routes. |
| `multiplier` | `1.5` | Scale the penalty between unresolved iterations. |
| `use_tiered_strategy` | `True` | Allow a cheaper bend proxy in the first iteration when applicable. |

View file

@ -7,7 +7,7 @@ Start with `run.results_by_net[net_id].outcome`. It distinguishes a path that st
| `result.outcome` | What to inspect |
| --- | --- |
| `completed` | The path reached its target and passed verification. Read its length in `report.total_length` and follow the [geometry export steps](route-a-layout.md#export-verified-geometry). |
| `colliding` | The path reached its target and failed verification. Check `result.report` for keepout clearance, conflicts with another route, self-overlap, or geometry outside the board. |
| `colliding` | The path reached its target and failed verification. Check `result.report` for keepout clearance, conflicts with another route, self-overlap, invalid geometry, a bad join, or geometry outside the board. |
| `partial` | Read the position and heading of `result.path[-1].end_port`. Check room for the path to continue from that heading. If the next turn fits, compare search limits. |
| `unroutable` | The path is empty. Check the launch heading and room for the first straight or bend. |