2026-03-30 15:32:29 -07:00
|
|
|
from inire import NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, route
|
2026-03-08 14:40:36 -07:00
|
|
|
from inire.utils.visualization import plot_routing_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
2026-03-30 15:32:29 -07:00
|
|
|
print("Running Example 03: Locked Routes...")
|
2026-03-08 14:40:36 -07:00
|
|
|
|
2026-03-26 20:22:17 -07:00
|
|
|
bounds = (0, -50, 100, 50)
|
2026-03-30 15:32:29 -07:00
|
|
|
options = RoutingOptions(
|
|
|
|
|
search=SearchOptions(bend_radii=(10.0,)),
|
|
|
|
|
objective=ObjectiveWeights(
|
|
|
|
|
bend_penalty=250.0,
|
|
|
|
|
sbend_penalty=500.0,
|
|
|
|
|
),
|
|
|
|
|
)
|
2026-03-11 09:37:54 -07:00
|
|
|
print("Routing initial net...")
|
2026-03-30 15:32:29 -07:00
|
|
|
results_a = route(
|
|
|
|
|
RoutingProblem(
|
|
|
|
|
bounds=bounds,
|
|
|
|
|
nets=(NetSpec("netA", Port(10, 0, 0), Port(90, 0, 0), width=2.0),),
|
|
|
|
|
),
|
|
|
|
|
options=options,
|
|
|
|
|
).results_by_net
|
2026-03-08 14:40:36 -07:00
|
|
|
|
2026-03-11 09:37:54 -07:00
|
|
|
print("Routing detour net around locked path...")
|
2026-03-30 15:32:29 -07:00
|
|
|
results_b = route(
|
|
|
|
|
RoutingProblem(
|
|
|
|
|
bounds=bounds,
|
|
|
|
|
nets=(NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90), width=2.0),),
|
2026-03-30 19:51:37 -07:00
|
|
|
static_obstacles=results_a["netA"].locked_geometry,
|
2026-03-30 15:32:29 -07:00
|
|
|
),
|
|
|
|
|
options=options,
|
|
|
|
|
).results_by_net
|
2026-03-08 14:40:36 -07:00
|
|
|
|
2026-03-26 20:22:17 -07:00
|
|
|
results = {**results_a, **results_b}
|
|
|
|
|
fig, ax = plot_routing_results(results, [], 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()
|