inire/examples/05_orientation_stress.py

35 lines
1.2 KiB
Python
Raw Normal View History

2026-03-30 15:32:29 -07:00
from inire import NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, route
2026-03-08 22:57:42 -07:00
from inire.utils.visualization import plot_routing_results
def main() -> None:
print("Running Example 05: Orientation Stress Test...")
2026-03-08 22:57:42 -07:00
2026-03-11 09:37:54 -07:00
bounds = (0, 0, 200, 200)
2026-03-08 22:57:42 -07:00
netlist = {
"u_turn": (Port(50, 50, 0), Port(50, 70, 180)),
"loop": (Port(100, 100, 90), Port(100, 80, 270)),
"zig_zag": (Port(20, 150, 0), Port(180, 150, 0)),
2026-03-08 22:57:42 -07:00
}
2026-03-30 15:32:29 -07:00
problem = RoutingProblem(
bounds=bounds,
nets=tuple(NetSpec(net_id, start, target, width=2.0) for net_id, (start, target) in netlist.items()),
)
options = RoutingOptions(
search=SearchOptions(bend_radii=(20.0,)),
objective=ObjectiveWeights(bend_penalty=50.0),
)
2026-03-08 22:57:42 -07:00
print("Routing complex orientation nets...")
2026-03-30 15:32:29 -07:00
run = route(problem, options=options)
for net_id, result in run.results_by_net.items():
status = "Success" if result.is_valid else "Failed"
print(f" {net_id}: {status}")
2026-03-08 22:57:42 -07:00
2026-03-30 15:32:29 -07:00
fig, _ax = plot_routing_results(run.results_by_net, [], bounds, netlist=netlist)
2026-03-08 23:34:18 -07:00
fig.savefig("examples/05_orientation_stress.png")
print("Saved plot to examples/05_orientation_stress.png")
2026-03-08 22:57:42 -07:00
if __name__ == "__main__":
main()