40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
|
|
from dataclasses import replace
|
||
|
|
|
||
|
|
from inire import FixedRoute, NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, TopologyOptions, route
|
||
|
|
from inire.utils.visualization import plot_routing_results
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> None:
|
||
|
|
print("Running Example 03: Locked Paths...")
|
||
|
|
|
||
|
|
bounds = (0, -50, 100, 50)
|
||
|
|
options = RoutingOptions(
|
||
|
|
search=SearchOptions(bend_radii=(10.0,)),
|
||
|
|
# Isolate the lattice detour.
|
||
|
|
objective=ObjectiveWeights(danger_weight=0.0),
|
||
|
|
topology=TopologyOptions(mode="off"),
|
||
|
|
)
|
||
|
|
|
||
|
|
print("Routing initial net...")
|
||
|
|
fixed_net = NetSpec("netA", Port(10, 0, 0), Port(90, 0, 0))
|
||
|
|
detour_net = NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90))
|
||
|
|
problem = RoutingProblem(bounds, (fixed_net, detour_net))
|
||
|
|
fixed = route(replace(problem, nets=(fixed_net,)), options=options).results_by_net["netA"]
|
||
|
|
assert fixed.is_valid
|
||
|
|
|
||
|
|
print("Routing detour net around locked path...")
|
||
|
|
remaining = replace(problem, nets=(detour_net,), fixed_routes=(FixedRoute.from_result(fixed),))
|
||
|
|
run = route(remaining, options=options)
|
||
|
|
detour = run.results_by_net[detour_net.net_id]
|
||
|
|
if not detour.is_valid:
|
||
|
|
raise ValueError(detour.report)
|
||
|
|
print("Detour net", detour.effective_net)
|
||
|
|
print("Placement recipe", detour.as_seed())
|
||
|
|
|
||
|
|
fig, _ax = plot_routing_results({fixed.net_id: fixed, **run.results_by_net}, [], bounds)
|
||
|
|
fig.savefig("examples/03_locked_paths.png")
|
||
|
|
print("Saved plot to examples/03_locked_paths.png")
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|