2026-11-29 00:09:54 -08:00
|
|
|
from dataclasses import replace
|
|
|
|
|
|
2026-11-29 00:12:59 -08:00
|
|
|
from inire import FixedRoute, NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, TopologyOptions, route
|
2026-03-08 14:40:36 -07:00
|
|
|
from inire.utils.visualization import plot_routing_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
2026-03-30 21:22:20 -07:00
|
|
|
print("Running Example 03: Locked Paths...")
|
2026-03-08 14:40:36 -07:00
|
|
|
|
2026-03-26 20:22:17 -07:00
|
|
|
bounds = (0, -50, 100, 50)
|
2026-11-27 00:38:00 -08:00
|
|
|
options = RoutingOptions(
|
|
|
|
|
search=SearchOptions(bend_radii=(10.0,)),
|
2026-11-29 00:09:54 -08:00
|
|
|
# Isolate the lattice detour.
|
2026-11-27 00:38:00 -08:00
|
|
|
objective=ObjectiveWeights(danger_weight=0.0),
|
|
|
|
|
topology=TopologyOptions(mode="off"),
|
2026-03-30 23:40:29 -07:00
|
|
|
)
|
2026-11-27 00:38:00 -08:00
|
|
|
|
|
|
|
|
print("Routing initial net...")
|
2026-11-29 00:09:54 -08:00
|
|
|
fixed_net = NetSpec("netA", Port(10, 0, 0), Port(90, 0, 0))
|
|
|
|
|
detour_net = NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90))
|
|
|
|
|
problem = RoutingProblem(bounds, (fixed_net, detour_net))
|
|
|
|
|
fixed = route(replace(problem, nets=(fixed_net,)), options=options).results_by_net["netA"]
|
2026-11-27 00:38:00 -08:00
|
|
|
assert fixed.is_valid
|
2026-03-08 14:40:36 -07:00
|
|
|
|
2026-03-11 09:37:54 -07:00
|
|
|
print("Routing detour net around locked path...")
|
2026-11-29 00:12:59 -08:00
|
|
|
remaining = replace(problem, nets=(detour_net,), fixed_routes=(FixedRoute.from_result(fixed),))
|
|
|
|
|
run = route(remaining, options=options)
|
2026-11-29 16:36:32 -08:00
|
|
|
detour = run.results_by_net[detour_net.net_id]
|
|
|
|
|
if not detour.is_valid:
|
|
|
|
|
raise ValueError(detour.report)
|
|
|
|
|
print("Detour net", detour.effective_net)
|
|
|
|
|
print("Placement recipe", detour.as_seed())
|
2026-03-08 14:40:36 -07:00
|
|
|
|
2026-11-29 00:12:59 -08:00
|
|
|
fig, _ax = plot_routing_results({fixed.net_id: fixed, **run.results_by_net}, [], bounds)
|
2026-03-08 23:34:18 -07:00
|
|
|
fig.savefig("examples/03_locked_paths.png")
|
|
|
|
|
print("Saved plot to examples/03_locked_paths.png")
|
2026-03-08 14:40:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|