Initial buildout
BIN
examples/01_simple_route.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
32
examples/01_simple_route.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from inire import NetSpec, Port, RoutingOptions, RoutingProblem, SearchOptions, route
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 01: Simple Route...")
|
||||
|
||||
bounds = (0, 0, 100, 100)
|
||||
netlist = {
|
||||
"net1": (Port(10, 50, 0), Port(90, 50, 0)),
|
||||
}
|
||||
problem = RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=(NetSpec("net1", *netlist["net1"], width=2.0),),
|
||||
)
|
||||
options = RoutingOptions(search=SearchOptions(bend_radii=(10.0,)))
|
||||
|
||||
run = route(problem, options=options)
|
||||
result = run.results_by_net["net1"]
|
||||
if result.is_valid:
|
||||
print("Success! Route found.")
|
||||
print(f"Path collisions: {result.collisions}")
|
||||
else:
|
||||
print("Failed to find route.")
|
||||
|
||||
fig, _ax = plot_routing_results(run.results_by_net, [], bounds, netlist=netlist)
|
||||
fig.savefig("examples/01_simple_route.png")
|
||||
print("Saved plot to examples/01_simple_route.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
examples/02_congestion_resolution.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
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()
|
||||
BIN
examples/03_locked_paths.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
40
examples/03_locked_paths.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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()
|
||||
BIN
examples/04_sbends_and_radii.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
41
examples/04_sbends_and_radii.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from inire import NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, route
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 04: S-Bends and Multiple Radii...")
|
||||
|
||||
bounds = (0, 0, 100, 100)
|
||||
netlist = {
|
||||
"sbend_only": (Port(10, 50, 0), Port(60, 55, 0)),
|
||||
"multi_radii": (Port(10, 10, 0), Port(90, 90, 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(
|
||||
node_limit=50000,
|
||||
bend_radii=(10.0, 30.0),
|
||||
sbend_offsets=(5.0,),
|
||||
),
|
||||
objective=ObjectiveWeights(
|
||||
unit_length_cost=1.0,
|
||||
bend_penalty=10.0,
|
||||
sbend_penalty=20.0,
|
||||
),
|
||||
)
|
||||
|
||||
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}, collisions={result.collisions}")
|
||||
|
||||
fig, _ax = plot_routing_results(run.results_by_net, [], bounds, netlist=netlist)
|
||||
fig.savefig("examples/04_sbends_and_radii.png")
|
||||
print("Saved plot to examples/04_sbends_and_radii.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
examples/05_orientation_stress.png
Normal file
|
After Width: | Height: | Size: 88 KiB |
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()
|
||||
BIN
examples/06_bend_collision_models.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
79
examples/06_bend_collision_models.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
from shapely.geometry import Polygon
|
||||
|
||||
from inire import CongestionOptions, NetSpec, ObjectiveWeights, RoutingOptions, RoutingProblem, RoutingResult, SearchOptions, route
|
||||
from inire.geometry.components import BendCollisionModel, BendPhysicalGeometry
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
|
||||
|
||||
def _route_scenario(
|
||||
bounds: tuple[float, float, float, float],
|
||||
obstacles: list[Polygon],
|
||||
netlist: dict[str, tuple[Port, Port]],
|
||||
widths: dict[str, float],
|
||||
*,
|
||||
bend_collision_type: BendCollisionModel = "arc",
|
||||
bend_proxy_geometry: BendCollisionModel | None = None,
|
||||
bend_physical_geometry: BendPhysicalGeometry | None = None,
|
||||
bend_clip_margin: float | None = None,
|
||||
) -> dict[str, RoutingResult]:
|
||||
problem = RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=tuple(NetSpec(net_id, start, target, width=widths[net_id]) for net_id, (start, target) in netlist.items()),
|
||||
static_obstacles=tuple(obstacles),
|
||||
)
|
||||
options = RoutingOptions(
|
||||
search=SearchOptions(
|
||||
bend_radii=(10.0,),
|
||||
bend_collision_type=bend_collision_type,
|
||||
bend_proxy_geometry=bend_proxy_geometry,
|
||||
bend_physical_geometry=bend_physical_geometry,
|
||||
bend_clip_margin=bend_clip_margin,
|
||||
),
|
||||
objective=ObjectiveWeights(
|
||||
bend_penalty=50.0,
|
||||
sbend_penalty=150.0,
|
||||
),
|
||||
congestion=CongestionOptions(use_tiered_strategy=False),
|
||||
)
|
||||
return route(problem, options=options).results_by_net
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 06: Bend Collision Models...")
|
||||
|
||||
bounds = (-20, -20, 170, 170)
|
||||
obs_arc = Polygon([(40, 110), (60, 110), (60, 130), (40, 130)])
|
||||
obs_bbox = Polygon([(40, 60), (60, 60), (60, 80), (40, 80)])
|
||||
obs_custom = Polygon([(40, 10), (60, 10), (60, 30), (40, 30)])
|
||||
custom_bend = Polygon([(0, -11), (11, -11), (11, 0), (9, 0), (9, -9), (0, -9)])
|
||||
|
||||
obstacles = [obs_arc, obs_bbox, obs_custom]
|
||||
netlist_arc = {"arc_model": (Port(10, 120, 0), Port(90, 140, 90))}
|
||||
netlist_bbox = {"bbox_model": (Port(10, 70, 0), Port(90, 90, 90))}
|
||||
netlist_custom = {"custom_geometry": (Port(10, 20, 0), Port(90, 40, 90))}
|
||||
|
||||
print("Routing Scenario 1 (Arc)...")
|
||||
res_arc = _route_scenario(bounds, obstacles, netlist_arc, {"arc_model": 2.0}, bend_collision_type="arc")
|
||||
print("Routing Scenario 2 (BBox)...")
|
||||
res_bbox = _route_scenario(bounds, obstacles, netlist_bbox, {"bbox_model": 2.0}, bend_collision_type="bbox")
|
||||
print("Routing Scenario 3 (Custom Manhattan Geometry With Matching Proxy)...")
|
||||
res_custom = _route_scenario(
|
||||
bounds,
|
||||
obstacles,
|
||||
netlist_custom,
|
||||
{"custom_geometry": 2.0},
|
||||
bend_physical_geometry=custom_bend,
|
||||
bend_proxy_geometry=custom_bend,
|
||||
)
|
||||
|
||||
all_results = {**res_arc, **res_bbox, **res_custom}
|
||||
all_netlists = {**netlist_arc, **netlist_bbox, **netlist_custom}
|
||||
|
||||
fig, _ax = plot_routing_results(all_results, obstacles, bounds, netlist=all_netlists)
|
||||
fig.savefig("examples/06_bend_collision_models.png")
|
||||
print("Saved plot to examples/06_bend_collision_models.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
examples/07_large_scale_routing.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
124
examples/07_large_scale_routing.py
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
import time
|
||||
|
||||
from shapely.geometry import box
|
||||
|
||||
from inire import (
|
||||
CongestionOptions,
|
||||
DiagnosticsOptions,
|
||||
NetSpec,
|
||||
ObjectiveWeights,
|
||||
Port,
|
||||
RoutingOptions,
|
||||
RoutingProblem,
|
||||
RoutingResult,
|
||||
SearchOptions,
|
||||
)
|
||||
from inire.router._stack import build_routing_stack
|
||||
from inire.utils.visualization import plot_expanded_nodes, plot_routing_results
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 07: Fan-Out (10 Nets, 50um Radius)...")
|
||||
|
||||
bounds = (0, 0, 1000, 1000)
|
||||
obstacles = [
|
||||
box(450, 0, 550, 400),
|
||||
box(450, 600, 550, 1000),
|
||||
]
|
||||
|
||||
num_nets = 10
|
||||
start_x = 50
|
||||
start_y_base = 500 - (num_nets * 10.0) / 2.0
|
||||
end_x = 950
|
||||
end_y_base = 100
|
||||
end_y_pitch = 800.0 / (num_nets - 1)
|
||||
|
||||
netlist: dict[str, tuple[Port, Port]] = {}
|
||||
for index in range(num_nets):
|
||||
start_y = int(round(start_y_base + index * 10.0))
|
||||
end_y = int(round(end_y_base + index * end_y_pitch))
|
||||
netlist[f"net_{index:02d}"] = (Port(start_x, start_y, 0), Port(end_x, end_y, 0))
|
||||
|
||||
problem = RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=tuple(NetSpec(net_id, start, target, width=2.0) for net_id, (start, target) in netlist.items()),
|
||||
static_obstacles=tuple(obstacles),
|
||||
clearance=6.0,
|
||||
)
|
||||
options = RoutingOptions(
|
||||
search=SearchOptions(
|
||||
node_limit=2_000_000,
|
||||
bend_radii=(50.0,),
|
||||
sbend_radii=(50.0,),
|
||||
greedy_h_weight=1.5,
|
||||
bend_clip_margin=10.0,
|
||||
distance_heuristic_weight=10.0,
|
||||
),
|
||||
objective=ObjectiveWeights(
|
||||
unit_length_cost=0.1,
|
||||
bend_penalty=100.0,
|
||||
sbend_penalty=400.0,
|
||||
),
|
||||
congestion=CongestionOptions(
|
||||
max_iterations=15,
|
||||
base_penalty=100.0,
|
||||
multiplier=1.4,
|
||||
net_order="shortest",
|
||||
shuffle_nets=True,
|
||||
seed=42,
|
||||
),
|
||||
diagnostics=DiagnosticsOptions(capture_expanded=True),
|
||||
)
|
||||
stack = build_routing_stack(problem, options)
|
||||
evaluator = stack.evaluator
|
||||
finder = stack.finder
|
||||
metrics = finder.metrics
|
||||
|
||||
iteration_stats: list[dict[str, int]] = []
|
||||
|
||||
def iteration_callback(iteration: int, current_results: dict[str, RoutingResult]) -> None:
|
||||
successes = sum(1 for result in current_results.values() if result.is_valid)
|
||||
total_collisions = sum(result.collisions for result in current_results.values())
|
||||
total_nodes = metrics.nodes_expanded
|
||||
print(f" Iteration {iteration} finished. Successes: {successes}/{len(netlist)}, Collisions: {total_collisions}")
|
||||
new_greedy = max(1.1, 1.5 - ((iteration + 1) / 10.0) * 0.4)
|
||||
evaluator.greedy_h_weight = new_greedy
|
||||
print(f" Adaptive Greedy Weight for Next Iteration: {new_greedy:.3f}")
|
||||
iteration_stats.append(
|
||||
{
|
||||
"Iteration": iteration,
|
||||
"Success": successes,
|
||||
"Congestion": total_collisions,
|
||||
"Nodes": total_nodes,
|
||||
}
|
||||
)
|
||||
metrics.reset_per_route()
|
||||
|
||||
print(f"Routing {len(netlist)} nets through 200um bottleneck...")
|
||||
start_time = time.perf_counter()
|
||||
results = finder.route_all(iteration_callback=iteration_callback)
|
||||
end_time = time.perf_counter()
|
||||
|
||||
print(f"Routing took {end_time - start_time:.4f}s")
|
||||
print("\n--- Iteration Summary ---")
|
||||
print(f"{'Iter':<5} | {'Success':<8} | {'Congest':<8} | {'Nodes':<10}")
|
||||
print("-" * 43)
|
||||
for stats in iteration_stats:
|
||||
print(f"{stats['Iteration']:<5} | {stats['Success']:<8} | {stats['Congestion']:<8} | {stats['Nodes']:<10}")
|
||||
|
||||
success_count = sum(1 for result in results.values() if result.is_valid)
|
||||
print(f"\nFinal: Routed {success_count}/{len(netlist)} nets successfully.")
|
||||
for net_id, result in results.items():
|
||||
if not result.is_valid:
|
||||
print(f" FAILED: {net_id}, collisions={result.collisions}")
|
||||
else:
|
||||
print(f" {net_id}: SUCCESS")
|
||||
|
||||
fig, ax = plot_routing_results(results, list(obstacles), bounds, netlist=netlist)
|
||||
plot_expanded_nodes(list(finder.accumulated_expanded_nodes), ax=ax)
|
||||
fig.savefig("examples/07_large_scale_routing.png")
|
||||
print("Saved plot to examples/07_large_scale_routing.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
examples/08_custom_bend_geometry.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
72
examples/08_custom_bend_geometry.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
from shapely.geometry import Polygon, box
|
||||
|
||||
from inire import CongestionOptions, NetSpec, RoutingOptions, RoutingProblem, SearchOptions, route
|
||||
from inire.geometry.components import BendCollisionModel, BendPhysicalGeometry
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
|
||||
|
||||
def _run_session(
|
||||
bounds: tuple[float, float, float, float],
|
||||
net_id: str,
|
||||
start: Port,
|
||||
target: Port,
|
||||
*,
|
||||
bend_collision_type: BendCollisionModel = "arc",
|
||||
bend_proxy_geometry: BendCollisionModel | None = None,
|
||||
bend_physical_geometry: BendPhysicalGeometry | None = None,
|
||||
) -> dict[str, object]:
|
||||
problem = RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=(NetSpec(net_id, start, target, width=2.0),),
|
||||
)
|
||||
options = RoutingOptions(
|
||||
search=SearchOptions(
|
||||
bend_radii=(10.0,),
|
||||
bend_collision_type=bend_collision_type,
|
||||
bend_proxy_geometry=bend_proxy_geometry,
|
||||
bend_physical_geometry=bend_physical_geometry,
|
||||
sbend_radii=(),
|
||||
),
|
||||
congestion=CongestionOptions(max_iterations=1, use_tiered_strategy=False),
|
||||
)
|
||||
return route(problem, options=options).results_by_net
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 08: Custom Bend Geometry...")
|
||||
|
||||
bounds = (0, 0, 150, 150)
|
||||
start = Port(20, 20, 0)
|
||||
target = Port(100, 100, 90)
|
||||
custom_physical = Polygon([(0, -11), (11, -11), (11, 0), (9, 0), (9, -9), (0, -9)])
|
||||
custom_proxy = box(0, -11, 11, 0)
|
||||
|
||||
print("Routing standard arc in its own session...")
|
||||
results_std = _run_session(bounds, "standard_arc", start, target)
|
||||
print("Routing custom geometry with a separate custom proxy in its own session...")
|
||||
results_custom = _run_session(
|
||||
bounds,
|
||||
"custom_geometry_and_proxy",
|
||||
start,
|
||||
target,
|
||||
bend_physical_geometry=custom_physical,
|
||||
bend_proxy_geometry=custom_proxy,
|
||||
)
|
||||
|
||||
all_results = {**results_std, **results_custom}
|
||||
fig, _ax = plot_routing_results(
|
||||
all_results,
|
||||
[],
|
||||
bounds,
|
||||
netlist={
|
||||
"standard_arc": (start, target),
|
||||
"custom_geometry_and_proxy": (start, target),
|
||||
},
|
||||
)
|
||||
fig.savefig("examples/08_custom_bend_geometry.png")
|
||||
print("Saved plot to examples/08_custom_bend_geometry.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
examples/09_unroutable_best_effort.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
50
examples/09_unroutable_best_effort.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
from shapely.geometry import box
|
||||
|
||||
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 09: Best-Effort Under Tight Search Budget...")
|
||||
|
||||
bounds = (0, 0, 100, 100)
|
||||
obstacles = [
|
||||
box(35, 35, 45, 65),
|
||||
box(55, 35, 65, 65),
|
||||
]
|
||||
problem = RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=(NetSpec("budget_limited_net", Port(10, 50, 0), Port(85, 60, 180), width=2.0),),
|
||||
static_obstacles=tuple(obstacles),
|
||||
)
|
||||
options = RoutingOptions(
|
||||
search=SearchOptions(
|
||||
node_limit=3,
|
||||
bend_radii=(10.0,),
|
||||
),
|
||||
objective=ObjectiveWeights(
|
||||
bend_penalty=50.0,
|
||||
sbend_penalty=150.0,
|
||||
),
|
||||
congestion=CongestionOptions(warm_start_enabled=False, max_iterations=1),
|
||||
)
|
||||
|
||||
print(f"Routing with a node limit of {options.search.node_limit} per search.")
|
||||
run = route(problem, options=options)
|
||||
result = run.results_by_net["budget_limited_net"]
|
||||
print(f"Outcome: {result.outcome}")
|
||||
if result.outcome == "partial":
|
||||
print(f"Partial path contains {len(result.path)} segments.")
|
||||
|
||||
fig, _ax = plot_routing_results(
|
||||
run.results_by_net,
|
||||
list(obstacles),
|
||||
bounds,
|
||||
netlist={"budget_limited_net": (Port(10, 50, 0), Port(85, 60, 180))},
|
||||
)
|
||||
fig.savefig("examples/09_unroutable_best_effort.png")
|
||||
print("Saved plot to examples/09_unroutable_best_effort.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
44
examples/README.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# Routing examples
|
||||
|
||||
## Start with a connection
|
||||
|
||||
- [Quick start](../README.md#route-a-net)
|
||||
|
||||

|
||||
|
||||
## Route a challenging layout
|
||||
|
||||

|
||||
|
||||
All nine routes verify. Follow the long lower route beneath both south approaches.
|
||||
|
||||
- [Advanced example gallery](advanced.md)
|
||||
|
||||
## Optional workflows
|
||||
|
||||
After [installing Inire](../README.md#install), run the example scripts with Python from the repository root. Each saves a PNG in `examples/`.
|
||||
|
||||
### Route around fixed geometry
|
||||
|
||||

|
||||
|
||||
`FixedRoute.from_result()` reserves the straight route. The next connection detours around its end.
|
||||
|
||||
- [Fixed-route script](03_locked_paths.py)
|
||||
- [Route reuse](../docs/user/route-a-layout.md#reuse-an-existing-route)
|
||||
|
||||
<a id="fit-bends-to-available-room"></a>
|
||||
|
||||
### Set the bend geometry
|
||||
|
||||
- **Choose allowed radii and offsets.** The [radii and S-bends example](04_sbends_and_radii.py) supplies two 90-degree bend radii and a 5-unit S-bend offset.
|
||||
- **Supply a custom bend shape.** The [custom bends example](08_custom_bend_geometry.py) sets a physical polygon for the waveguide and a separate box for collision checks during search. The [bend proxy comparison](06_bend_collision_models.py) shows how the same circular bend can use different shapes for collision checks.
|
||||
|
||||
<a id="diagnose-congestion-or-an-incomplete-route"></a>
|
||||
|
||||
### Inspect an incomplete route
|
||||
|
||||
At `node_limit=3`, the route stops after its first turn. At 500 it reaches the target.
|
||||
|
||||
- [Best-effort script](09_unroutable_best_effort.py)
|
||||
- [Partial routes](../docs/user/tune-and-troubleshoot.md#why-a-net-stopped-short)
|
||||
253
examples/advanced-layouts.json
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
{
|
||||
"stress-refine-alternating-doglegs": {
|
||||
"bounds": [0, 0, 1080, 410],
|
||||
"clearance": 5,
|
||||
"bend_radii": [20, 24],
|
||||
"sbend_radii": [20],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((379 0, 379 238, 284 238, 284 0, 379 0))",
|
||||
"POLYGON ((682 139, 682 410, 594 410, 594 139, 682 139))"
|
||||
],
|
||||
"nets": [
|
||||
["track_0", [34, 147, 0], [1030, 173, 0], 2],
|
||||
["track_1", [34, 164, 0], [1030, 190, 0], 4],
|
||||
["track_2", [34, 181, 0], [1030, 207, 0], 3]
|
||||
]
|
||||
},
|
||||
"stress-refine-return-shelf": {
|
||||
"bounds": [0, 0, 790, 480],
|
||||
"clearance": 5,
|
||||
"bend_radii": [20, 27],
|
||||
"sbend_radii": [20],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((502 320, 502 480, 428 480, 428 320, 502 320))",
|
||||
"POLYGON ((340 145, 340 168, 250 168, 250 145, 340 145))"
|
||||
],
|
||||
"nets": [
|
||||
["folded_return", [640, 155, 0], [555, 230, 0], 2],
|
||||
["shelf_edge", [201, 272, 0], [595, 272, 0], 4],
|
||||
["lower_return", [585, 178, 180], [64, 178, 180], 2],
|
||||
["east_shelf", [675, 438, 180], [610, 438, 180], 2]
|
||||
]
|
||||
},
|
||||
"stress-retry-straight-decoy": {
|
||||
"bounds": [0, 0, 760, 440],
|
||||
"clearance": 5,
|
||||
"bend_radii": [20],
|
||||
"sbend_radii": [20],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((15 222, 15 238, 0 238, 0 222, 15 222))",
|
||||
"POLYGON ((760 222, 760 238, 745 238, 745 222, 760 222))",
|
||||
"POLYGON ((282 114, 282 186, 216 186, 216 114, 282 114))",
|
||||
"POLYGON ((539 114, 539 199, 463 199, 463 114, 539 114))"
|
||||
],
|
||||
"nets": [
|
||||
["trunk", [25, 230, 0], [735, 230, 0], 4],
|
||||
["branch_west", [326, 144, 90], [326, 339, 90], 2],
|
||||
["branch_east", [398, 358, 270], [398, 170, 270], 3],
|
||||
["lower_rail", [58, 79, 0], [708, 79, 0], 2]
|
||||
]
|
||||
},
|
||||
"stress-retry-compact-shift-bank": {
|
||||
"bounds": [0, 0, 720, 720],
|
||||
"clearance": 5,
|
||||
"bend_radii": [20],
|
||||
"sbend_radii": [20],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((720 230, 720 242, 0 242, 0 230, 720 230))",
|
||||
"POLYGON ((720 389, 720 401, 0 401, 0 389, 720 389))",
|
||||
"POLYGON ((720 549, 720 561, 0 561, 0 549, 720 549))",
|
||||
"POLYGON ((202 96, 202 158, 113 158, 113 96, 202 96))",
|
||||
"POLYGON ((345 264, 345 298, 258 298, 258 264, 345 264))",
|
||||
"POLYGON ((447 426, 447 460, 337 460, 337 426, 447 426))",
|
||||
"POLYGON ((402 581, 402 616, 285 616, 285 581, 402 581))"
|
||||
],
|
||||
"nets": [
|
||||
["short", [45, 117, 0], [111, 202, 0], 3],
|
||||
["middle", [33, 274, 0], [650, 347, 0], 4],
|
||||
["upper", [56, 445, 0], [670, 513, 0], 2],
|
||||
["top", [63, 598, 0], [630, 669, 0], 2]
|
||||
]
|
||||
},
|
||||
"stress-retry-mixed-port-bank": {
|
||||
"bounds": [0, 0, 680, 540],
|
||||
"clearance": 5,
|
||||
"bend_radii": [20],
|
||||
"sbend_radii": [20],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((194 53, 194 131, 133 131, 133 53, 194 53))",
|
||||
"POLYGON ((498 221, 498 291, 452 291, 452 221, 498 221))",
|
||||
"POLYGON ((624 171, 624 230, 564 230, 564 171, 624 171))",
|
||||
"POLYGON ((190 185, 339 175, 353 218, 315 283, 199 290, 190 185))",
|
||||
"POLYGON ((348 302, 348 337, 256 337, 256 302, 348 302))",
|
||||
"POLYGON ((310 408, 310 443, 108 443, 108 408, 310 408))"
|
||||
],
|
||||
"nets": [
|
||||
["east_compact", [40, 75, 0], [115, 158, 0], 3],
|
||||
["west_compact", [590, 261, 180], [516, 182, 180], 4],
|
||||
["turning_exit", [290, 50, 90], [437, 113, 0], 2],
|
||||
["upper_shift", [40, 315, 0], [450, 395, 0], 2],
|
||||
["return", [535, 475, 180], [60, 475, 180], 2]
|
||||
]
|
||||
},
|
||||
"stress-passage-width-key": {
|
||||
"bounds": [0, 0, 1210, 720],
|
||||
"clearance": 5,
|
||||
"bend_radii": [20],
|
||||
"sbend_radii": [20],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((492 0, 492 246, 440 246, 440 0, 492 0))",
|
||||
"POLYGON ((492 260, 492 340, 440 340, 440 260, 492 260))",
|
||||
"POLYGON ((492 443, 492 720, 440 720, 440 443, 492 443))"
|
||||
],
|
||||
"nets": [
|
||||
["lane_0", [1190, 498, 180], [30, 64, 180], 2],
|
||||
["lane_1", [30, 81, 0], [1190, 515, 0], 7],
|
||||
["lane_2", [1190, 533, 180], [30, 99, 180], 4],
|
||||
["lane_3", [30, 118, 0], [1190, 551, 0], 8],
|
||||
["lane_4", [30, 135, 0], [1190, 569, 0], 5],
|
||||
["lane_5", [1190, 587, 180], [30, 153, 180], 6]
|
||||
]
|
||||
},
|
||||
"stress-passage-split-merge": {
|
||||
"bounds": [0, 0, 1710, 880],
|
||||
"clearance": 5,
|
||||
"bend_radii": [20],
|
||||
"sbend_radii": [20],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((470 0, 470 243, 422 243, 422 0, 470 0))",
|
||||
"POLYGON ((470 293, 470 374, 422 374, 422 293, 470 293))",
|
||||
"POLYGON ((470 439, 470 880, 422 880, 422 439, 470 439))",
|
||||
"POLYGON ((982 0, 982 523, 930 523, 930 0, 982 0))",
|
||||
"POLYGON ((982 618, 982 880, 930 880, 930 618, 982 618))"
|
||||
],
|
||||
"nets": [
|
||||
["lane_0", [1670, 679, 180], [30, 53, 180], 3],
|
||||
["lane_1", [30, 70, 0], [1670, 697, 0], 5],
|
||||
["lane_2", [30, 87, 0], [1670, 716, 0], 2],
|
||||
["lane_3", [1670, 734, 180], [30, 105, 180], 4],
|
||||
["lane_4", [30, 123, 0], [1670, 752, 0], 6],
|
||||
["lane_5", [1670, 772, 180], [30, 141, 180], 3]
|
||||
]
|
||||
},
|
||||
"stress-sbend-competing-slots": {
|
||||
"bounds": [0, 0, 450, 320],
|
||||
"clearance": 4,
|
||||
"bend_radii": [25],
|
||||
"sbend_radii": [25],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((120 130, 120 135, 104 135, 104 130, 120 130))",
|
||||
"POLYGON ((358 166, 358 154, 370 154, 370 140, 356 140, 356 152, 344 152, 344 140, 330 140, 330 154, 342 154, 342 166, 330 166, 330 180, 344 180, 344 168, 356 168, 356 180, 370 180, 370 166, 358 166))"
|
||||
],
|
||||
"nets": [
|
||||
["lower_east", [35, 112, 0], [235, 132, 0], 3],
|
||||
["upper_west", [235, 141, 180], [35, 121, 180], 3],
|
||||
["south_access", [330, 52, 90], [350, 146, 90], 2],
|
||||
["north_access", [350, 174, 90], [330, 284, 90], 2]
|
||||
]
|
||||
},
|
||||
"stress-crossing-off-lattice-slot": {
|
||||
"bounds": [0, 0, 500, 460],
|
||||
"clearance": 4,
|
||||
"bend_radii": [6, 15],
|
||||
"sbend_radii": [25],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((268 236, 268 224, 280 224, 280 210, 266 210, 266 222, 254 222, 254 210, 240 210, 240 224, 252 224, 252 236, 240 236, 240 250, 254 250, 254 238, 266 238, 266 250, 280 250, 280 236, 268 236))",
|
||||
"POLYGON ((273 272, 273 317, 245 317, 245 272, 273 272))",
|
||||
"POLYGON ((176 193, 176 214, 145 214, 145 193, 176 193))"
|
||||
],
|
||||
"nets": [
|
||||
["west_odd_shift", [34, 213, 0], [246, 230, 0], 2],
|
||||
["east_exact_shift", [274, 230, 0], [465, 250, 0], 2],
|
||||
["north_pocket", [260, 244, 90], [260, 429, 90], 3],
|
||||
["south_exact_shift", [240, 30, 90], [260, 216, 90], 2]
|
||||
]
|
||||
},
|
||||
"stress-crossings-shared-outside-detour": {
|
||||
"bounds": [0, 0, 625, 397],
|
||||
"clearance": 4,
|
||||
"bend_radii": [20],
|
||||
"sbend_radii": [25],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((228 186, 228 174, 240 174, 240 160, 226 160, 226 172, 214 172, 214 160, 200 160, 200 174, 212 174, 212 186, 200 186, 200 200, 214 200, 214 188, 226 188, 226 200, 240 200, 240 186, 228 186))",
|
||||
"POLYGON ((363 186, 363 174, 375 174, 375 160, 361 160, 361 172, 349 172, 349 160, 335 160, 335 174, 347 174, 347 186, 335 186, 335 200, 349 200, 349 188, 361 188, 361 200, 375 200, 375 186, 363 186))",
|
||||
"POLYGON ((415 69, 415 81, 160 81, 160 69, 415 69))",
|
||||
"POLYGON ((144 216, 144 261, 102 261, 102 216, 144 216))"
|
||||
],
|
||||
"nets": [
|
||||
["west_link", [32, 160, 0], [206, 180, 0], 2],
|
||||
["device_link", [234, 180, 0], [341, 180, 0], 2],
|
||||
["east_link", [369, 180, 0], [581, 200, 0], 2],
|
||||
["west_south", [220, 87, 90], [220, 166, 90], 2],
|
||||
["east_south", [355, 166, 270], [355, 90, 270], 2],
|
||||
["west_north", [220, 194, 90], [200, 317, 90], 2],
|
||||
["east_north", [375, 315, 270], [355, 194, 270], 2],
|
||||
["outside_lower", [35, 130, 0], [590, 130, 0], 4],
|
||||
["outside_upper", [589, 353, 180], [33, 353, 180], 2]
|
||||
]
|
||||
},
|
||||
"complex-routing-example-1": {
|
||||
"bounds": [0, 0, 2500, 1000],
|
||||
"clearance": 6.0,
|
||||
"bend_radii": [50.0],
|
||||
"sbend_radii": [50.0],
|
||||
"infer_terminal_headings": false,
|
||||
"keepouts": [
|
||||
"POLYGON ((550 80, 550 480, 450 480, 450 80, 550 80))",
|
||||
"POLYGON ((550 520, 550 920, 450 920, 450 520, 550 520))",
|
||||
"POLYGON ((2010 130, 2010 491.5, 1910 491.5, 1910 130, 2010 130))",
|
||||
"POLYGON ((2010 510, 2010 851.5, 1910 851.5, 1910 510, 2010 510))",
|
||||
"POLYGON ((1040 680, 1040 983, 940 983, 940 680, 1040 680))",
|
||||
"POLYGON ((1080 50, 1080 475, 980 475, 980 50, 1080 50))",
|
||||
"POLYGON ((1537 18, 1537 620, 1350 620, 1350 18, 1537 18))"
|
||||
],
|
||||
"nets": [
|
||||
["net_00", [12, 460, 0], [2412, 150, 0], 2.0],
|
||||
["net_01", [12, 470, 0], [2412, 250, 0], 2.0],
|
||||
["net_02", [12, 480, 0], [2412, 350, 0], 2.0],
|
||||
["net_03", [12, 490, 0], [902, 900, 0], 2.0],
|
||||
["net_04", [12, 500, 0], [2412, 500, 0], 2.0],
|
||||
["net_05", [12, 510, 0], [2412, 650, 0], 2.0],
|
||||
["net_06", [12, 520, 0], [2412, 750, 0], 2.0],
|
||||
["net_07", [12, 530, 0], [2412, 850, 0], 2.0],
|
||||
["net_08", [12, 450, 0], [1112, 991, 0], 2.0]
|
||||
]
|
||||
},
|
||||
"complex-routing-example-1-point-terminals": {
|
||||
"bounds": [0, 0, 2500, 1000],
|
||||
"clearance": 6.0,
|
||||
"bend_radii": [50.0],
|
||||
"sbend_radii": [50.0],
|
||||
"infer_terminal_headings": true,
|
||||
"keepouts": [
|
||||
"POLYGON ((550 80, 550 480, 450 480, 450 80, 550 80))",
|
||||
"POLYGON ((550 520, 550 920, 450 920, 450 520, 550 520))",
|
||||
"POLYGON ((2010 130, 2010 491.5, 1910 491.5, 1910 130, 2010 130))",
|
||||
"POLYGON ((2010 510, 2010 851.5, 1910 851.5, 1910 510, 2010 510))",
|
||||
"POLYGON ((1040 680, 1040 983, 940 983, 940 680, 1040 680))",
|
||||
"POLYGON ((1080 50, 1080 475, 980 475, 980 50, 1080 50))",
|
||||
"POLYGON ((1537 18, 1537 620, 1350 620, 1350 18, 1537 18))"
|
||||
],
|
||||
"nets": [
|
||||
["net_00", [12, 460, 0], [2412, 150, 0], 2.0],
|
||||
["net_01", [12, 470, 0], [2412, 250, 0], 2.0],
|
||||
["net_02", [12, 480, 0], [2412, 350, 0], 2.0],
|
||||
["net_03", [12, 490, 0], [902, 900, 0], 2.0],
|
||||
["net_04", [12, 500, 0], [2412, 500, 0], 2.0],
|
||||
["net_05", [12, 510, 0], [2412, 650, 0], 2.0],
|
||||
["net_06", [12, 520, 0], [2412, 750, 0], 2.0],
|
||||
["net_07", [12, 530, 0], [2412, 850, 0], 2.0],
|
||||
["net_08", [12, 450, 0], [1112, 991, 0], 2.0]
|
||||
]
|
||||
}
|
||||
}
|
||||