inire/examples/05_orientation_stress.py

35 lines
1.2 KiB
Python

from inire import NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, route
from inire.utils.visualization import plot_routing_results
def main() -> None:
print("Running Example 05: Orientation Stress Test...")
bounds = (0, 0, 200, 200)
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)),
}
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),
)
print("Routing complex orientation nets...")
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}")
fig, _ax = plot_routing_results(run.results_by_net, [], bounds, netlist=netlist)
fig.savefig("examples/05_orientation_stress.png")
print("Saved plot to examples/05_orientation_stress.png")
if __name__ == "__main__":
main()