Initial buildout
This commit is contained in:
parent
34615f3aac
commit
84b76d0f6a
1 changed files with 25658 additions and 25 deletions
35
examples/05_orientation_stress.py
Normal file
35
examples/05_orientation_stress.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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: Port Headings...")
|
||||
|
||||
bounds = (0, 0, 200, 200)
|
||||
netlist = {
|
||||
"east_to_west": (Port(50, 50, 0), Port(50, 70, 180)),
|
||||
"north_to_south": (Port(100, 100, 90), Port(100, 80, 270)),
|
||||
"straight": (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 two heading reversals and one straight connection...")
|
||||
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()
|
||||
Loading…
Reference in a new issue