Preserve route identity through reservation and export

This commit is contained in:
Jan Petykiewicz 2026-11-29 00:12:59 -08:00
commit 286caa273b

View file

@ -90,7 +90,7 @@ For a multi-net layout, apply the validity check to every net you intend to expo
## Reuse an existing route
- **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 replay its seed in the first group of `route_profiles` with search and refinement disabled. Later groups respect it as a distinct net, including at zero clearance. Verify the groups together before [exporting the layer](fabrication.md#check-the-export-grid).
- **Hold a route fixed.** Check `result.is_valid`, then use `FixedRoute.from_result(result)` and pass it in `fixed_routes` alongside the remaining nets. The next run respects it as a distinct net, including at zero clearance. Verify the groups together before [exporting the layer](fabrication.md#check-the-export-grid).
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.
@ -128,8 +128,8 @@ Route a straight net, then reserve it while routing another net on the same laye
```python
from dataclasses import replace
from inire import NetSpec, Port, RefinementOptions, RoutingOptions, RoutingProblem, SearchOptions, route
from inire.layout import route_profiles, verify_export_grid
from inire import FixedRoute, NetSpec, Port, RoutingOptions, RoutingProblem, SearchOptions, route
from inire.layout import verify_export_grid
bounds = (0, -50, 100, 50)
options = RoutingOptions(search=SearchOptions(bend_radii=(10,)))
@ -137,16 +137,14 @@ fixed_net = NetSpec("fixed", Port(10, 0, 0), Port(90, 0, 0))
detour_net = NetSpec("detour", Port(50, -20, 90), Port(50, 20, 90))
problem = RoutingProblem(bounds=bounds, nets=(fixed_net, detour_net), clearance=0)
fixed = route(replace(problem, nets=(fixed_net,)), options=options).results_by_net["fixed"]
assert fixed.is_valid
replay_options = replace(
options, search=replace(options.search, node_limit=0), refinement=RefinementOptions(enabled=False),
)
problem = replace(problem, initial_paths={"fixed": fixed.as_seed()})
results = route_profiles(problem, [(("fixed",), replay_options), (("detour",), options)])
export = verify_export_grid(problem, results, grid=1.0)
remaining = replace(problem, nets=(detour_net,), fixed_routes=(FixedRoute.from_result(fixed),))
run = route(remaining, options=options)
export = verify_export_grid(remaining, run.results_by_net, grid=1.0)
if not export.is_valid:
raise ValueError(export.reports_by_net)
```
For imported metal or waveguide polygons, use `FixedRoute("existing_net", imported_polygons)`. Supply fixed polygons in their final layer coordinates. Export checks new routes against them and returns the new polygons.
To compare the two paths on a plot, see the [fixed-route example](../../examples/README.md#route-around-fixed-geometry).