from shapely.geometry import box from inire import CongestionOptions, NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, route from inire.utils.visualization import plot_routing_results def main() -> None: print("Running Example 09: Best-Effort Under Tight Search Budget...") bounds = (0, 0, 100, 100) obstacles = [ box(35, 35, 45, 65), box(55, 35, 65, 65), ] problem = RoutingProblem( bounds=bounds, nets=(NetSpec("budget_limited_net", Port(10, 50, 0), Port(85, 60, 180), width=2.0),), static_obstacles=tuple(obstacles), ) options = RoutingOptions( search=SearchOptions( node_limit=3, bend_radii=(10.0,), ), objective=ObjectiveWeights( bend_penalty=50.0, sbend_penalty=150.0, ), congestion=CongestionOptions(warm_start_enabled=False, max_iterations=1), ) print(f"Routing with a node limit of {options.search.node_limit} per search.") run = route(problem, options=options) result = run.results_by_net["budget_limited_net"] print(f"Outcome: {result.outcome}") if result.outcome == "partial": print(f"Partial path contains {len(result.path)} segments.") fig, _ax = plot_routing_results( run.results_by_net, list(obstacles), bounds, netlist={"budget_limited_net": (Port(10, 50, 0), Port(85, 60, 180))}, ) fig.savefig("examples/09_unroutable_best_effort.png") print("Saved plot to examples/09_unroutable_best_effort.png") if __name__ == "__main__": main()