44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
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=250.0,
|
|
sbend_penalty=500.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()
|