Initial buildout
This commit is contained in:
parent
34615f3aac
commit
84b76d0f6a
1 changed files with 25658 additions and 25 deletions
44
examples/02_congestion_resolution.py
Normal file
44
examples/02_congestion_resolution.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
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 02: Congestion Resolution (Triple Crossing)...")
|
||||
|
||||
bounds = (0, 0, 100, 100)
|
||||
netlist = {
|
||||
"horizontal": (Port(10, 50, 0), Port(90, 50, 0)),
|
||||
"vertical_up": (Port(45, 10, 90), Port(45, 90, 90)),
|
||||
"vertical_down": (Port(55, 90, 270), Port(55, 10, 270)),
|
||||
}
|
||||
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=(10.0,),
|
||||
sbend_radii=(10.0,),
|
||||
greedy_h_weight=1.5,
|
||||
),
|
||||
objective=ObjectiveWeights(
|
||||
bend_penalty=50.0,
|
||||
sbend_penalty=150.0,
|
||||
),
|
||||
congestion=CongestionOptions(base_penalty=1000.0),
|
||||
)
|
||||
|
||||
run = route(problem, options=options)
|
||||
all_valid = all(result.is_valid for result in run.results_by_net.values())
|
||||
if all_valid:
|
||||
print("Success! Congestion resolved for all nets.")
|
||||
else:
|
||||
print("Failed to resolve congestion for some nets.")
|
||||
|
||||
fig, _ax = plot_routing_results(run.results_by_net, [], bounds, netlist=netlist)
|
||||
fig.savefig("examples/02_congestion_resolution.png")
|
||||
print("Saved plot to examples/02_congestion_resolution.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in a new issue