Recover bounded routes around bends and through narrow corridors

This commit is contained in:
Jan Petykiewicz 2026-11-28 20:29:40 -08:00
commit af3ddfbb09

View file

@ -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