Preserve route identity through reservation and export

This commit is contained in:
Jan Petykiewicz 2026-11-29 00:12:59 -08:00
commit 286caa273b
2 changed files with 226 additions and 99 deletions

View file

@ -1,7 +1,7 @@
from dataclasses import replace
from inire import NetSpec, ObjectiveWeights, Port, RefinementOptions, RoutingOptions, RoutingProblem, SearchOptions, TopologyOptions, route
from inire.layout import route_profiles, verify_export_grid
from inire import FixedRoute, NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, TopologyOptions, route
from inire.layout import verify_export_grid
from inire.utils.visualization import plot_routing_results
@ -24,16 +24,13 @@ def main() -> None:
assert fixed.is_valid
print("Routing detour net around locked path...")
replay = replace(
options, search=replace(options.search, node_limit=0), refinement=RefinementOptions(enabled=False),
)
problem = replace(problem, initial_paths={"netA": fixed.as_seed()})
results = route_profiles(problem, [(("netA",), replay), (("netB",), options)])
export = verify_export_grid(problem, results, grid=1)
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)
if not export.is_valid:
raise ValueError(export.reports_by_net)
fig, _ax = plot_routing_results(results, [], bounds)
fig, _ax = plot_routing_results({fixed.net_id: fixed, **run.results_by_net}, [], bounds)
fig.savefig("examples/03_locked_paths.png")
print("Saved plot to examples/03_locked_paths.png")

View file

@ -20,7 +20,7 @@ After [installing Inire](../README.md#install), run the example scripts with Pyt
![A second waveguide makes a U-shaped detour around the left end of a fixed straight waveguide.](03_locked_paths.png)
The first call routes a straight waveguide. `route_profiles` replays and reserves it, so the new connection passes to the left of the fixed route. The example verifies both routes together on the export grid. Run [`03_locked_paths.py`](03_locked_paths.py) to reproduce the detour. To hold a route fixed in your own design, follow the [route reuse workflow](../docs/user/route-a-layout.md#reuse-an-existing-route).
The first call routes a straight waveguide. `FixedRoute.from_result()` reserves its exact polygons, so the new connection passes to the left of the fixed route. The example checks the new route on the export grid against the fixed polygons. Run [`03_locked_paths.py`](03_locked_paths.py) to reproduce the detour. To hold a route fixed in your own design, follow the [route reuse workflow](../docs/user/route-a-layout.md#reuse-an-existing-route).
<a id="fit-bends-to-available-room"></a>