Recover bounded routes around bends and through narrow corridors
This commit is contained in:
parent
d02dbb872f
commit
af3ddfbb09
2 changed files with 616 additions and 73 deletions
|
|
@ -15,7 +15,7 @@ Omitting `options` uses `RoutingOptions()`. To observe progress, pass a callable
|
|||
### 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, 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.
|
||||
- `NetSpec(net_id, start, target, width=2.0)` uses a unique string 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. If both snapped ports are identical, connect the placed ports directly and omit that net from the routing problem.
|
||||
|
||||
### RoutingProblem
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ The fields below appear in constructor order. Use one layout unit for coordinate
|
|||
| `static_obstacles` | `()` | Valid, nonempty Shapely `Polygon` objects that define keepouts. |
|
||||
| `initial_paths` | Empty mapping | Net IDs mapped to `PathSeed` objects. |
|
||||
| `clearance` | `2.0` | Finite, nonnegative spacing required between distinct nets and between a net and a keepout. At zero clearance, distinct nets must still be disjoint, including at vertices. Boundary contact with a keepout is allowed. |
|
||||
| `self_clearance` | `0.0` | Optional spacing within one net. Applies between components when the intervening centerline is at least this long. Adjacent joins and components immediately on either side of one bend are exempt. Unintended contact is always checked. |
|
||||
| `safety_zone_radius` | `0.0021` | Tolerance for small obstacle intersections at a move's endpoints during search. |
|
||||
| `self_clearance` | `0.0` | Optional spacing within one net. Applies between components when the intervening centerline is at least this long. Adjacent joins and components immediately on either side of one bend are exempt. Unintended contact is always checked. |
|
||||
|
||||
## Path seeds
|
||||
|
||||
|
|
@ -43,7 +43,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` flags geometry outside the board. `discontinuous` flags missing or point-only joins, including at terminal faces. `invalid_geometry` flags invalid or empty physical polygons. `seed_error` identifies a supplied bend that cannot carry the net's width. |
|
||||
| `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. `seed_error` identifies a supplied bend that cannot carry the net's width. `terminal_error` identifies an inaccessible start or target face. |
|
||||
| `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. |
|
||||
|
|
@ -129,7 +129,7 @@ For a layout that repeatedly stops short at an opening, `guide` can suggest a pa
|
|||
| --- | --- | --- |
|
||||
| `mode` | `"automatic"` | Select a [routing mode](tune-and-troubleshoot.md#choose-a-routing-mode). |
|
||||
| `max_corridors` | `3` | Maximum proposed passages per net. |
|
||||
| `guide_strength` | `0.75` | Maximum added guidance cost per unit length. Zero keeps the suggested moves without adding cost. |
|
||||
| `guide_strength` | `0.75` | Maximum added guidance cost per unit length. Explicit guide and seed runs with at least two configured congestion iterations may try one additional iteration from the start with zero guidance cost. The retry retains corridor move proposals and wins only with higher verified coverage. |
|
||||
| `seed_node_limit` | `600` | Total seed-search expansions per net, capped by the active search limit. |
|
||||
| `infer_terminal_headings` | `False` | Let automatic or bundle mode choose headings for supported layouts with flexible port directions. Automatic preserves caller headings when initial paths are supplied. |
|
||||
| `automatic_cost` | `"selective"` | Try a second column-planning pass based on route cost when the first pass chains short S-bends. Use `"always"` to try both passes or `"never"` to plan by span alone. |
|
||||
|
|
|
|||
|
|
@ -88,6 +88,37 @@ For a multi-net layout, apply the validity check to every net you intend to expo
|
|||
- **Give the router a route it can move.** Put `result.as_seed()` in `initial_paths` under the net's ID. A seed uses the current start port, width, and geometry settings. Search can follow a partial seed from the first iteration and can leave it to find another approach. To build a hint from turns and straights, see the [path seed reference](api-reference.md#path-seeds).
|
||||
- **Hold a route fixed.** Check `result.is_valid`, then add `result.locked_geometry` to `static_obstacles` while routing other nets. The next run applies its own clearance to those polygons.
|
||||
|
||||
When terminal headings are inferred, store the two selected ports alongside the seed, width, and geometry options. Use those exact ports to replay the route and export the same polygons.
|
||||
|
||||
```python
|
||||
from dataclasses import replace
|
||||
|
||||
from inire import RefinementOptions, TopologyOptions, route
|
||||
|
||||
chosen = route(problem, options=options)
|
||||
verified_nets = []
|
||||
seeds = {}
|
||||
for net in problem.nets:
|
||||
result = chosen.results_by_net[net.net_id]
|
||||
if result.is_valid:
|
||||
verified_nets.append(replace(net, start=result.path[0].start_port, target=result.path[-1].end_port))
|
||||
seeds[net.net_id] = result.as_seed()
|
||||
|
||||
replay = route(
|
||||
replace(problem, nets=tuple(verified_nets), initial_paths=seeds),
|
||||
options=replace(
|
||||
options,
|
||||
search=replace(options.search, node_limit=0),
|
||||
topology=TopologyOptions(mode="off"),
|
||||
refinement=RefinementOptions(enabled=False),
|
||||
),
|
||||
)
|
||||
for net in verified_nets:
|
||||
result = replay.results_by_net[net.net_id]
|
||||
assert result.is_valid
|
||||
assert result.locked_geometry == chosen.results_by_net[net.net_id].locked_geometry
|
||||
```
|
||||
|
||||
Route a straight net, then use its polygons as keepouts in a second routing problem. The second net has to detour around one end of the fixed route.
|
||||
|
||||
```python
|
||||
|
|
|
|||
Loading…
Reference in a new issue