more bend work; bounds constrain edges
This commit is contained in:
parent
4714bed9a8
commit
58873692d6
15 changed files with 251 additions and 124 deletions
|
|
@ -28,7 +28,7 @@ def main() -> None:
|
|||
"vertical_up": (Port(45, 10, 90), Port(45, 90, 90)),
|
||||
"vertical_down": (Port(55, 90, 270), Port(55, 10, 270)),
|
||||
}
|
||||
net_widths = {nid: 2.0 for nid in netlist}
|
||||
net_widths = dict.fromkeys(netlist, 2.0)
|
||||
|
||||
# 3. Route with Negotiated Congestion
|
||||
# We increase the base penalty to encourage faster divergence
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ def main() -> None:
|
|||
"bus_2": (Port(10, 60, 0), Port(110, 65, 0)),
|
||||
}
|
||||
print("Phase 1: Routing bus (3 nets)...")
|
||||
results_p1 = pf.route_all(netlist_p1, {nid: 2.0 for nid in netlist_p1})
|
||||
results_p1 = pf.route_all(netlist_p1, dict.fromkeys(netlist_p1, 2.0))
|
||||
|
||||
# Lock all Phase 1 nets
|
||||
path_polys = []
|
||||
|
|
@ -50,10 +50,10 @@ def main() -> None:
|
|||
"cross_left": (Port(30, 10, 90), Port(30, 110, 90)),
|
||||
"cross_right": (Port(80, 110, 270), Port(80, 10, 270)), # Top to bottom
|
||||
}
|
||||
|
||||
|
||||
print("Phase 2: Routing crossing nets around locked bus...")
|
||||
# We use a slightly different width for variety
|
||||
results_p2 = pf.route_all(netlist_p2, {nid: 1.5 for nid in netlist_p2})
|
||||
results_p2 = pf.route_all(netlist_p2, dict.fromkeys(netlist_p2, 1.5))
|
||||
|
||||
# 4. Check Results
|
||||
for nid, res in results_p2.items():
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
from shapely.geometry import Polygon
|
||||
|
||||
from inire.geometry.collision import CollisionEngine
|
||||
from inire.geometry.primitives import Port
|
||||
|
|
|
|||
|
|
@ -16,26 +16,26 @@ def main() -> None:
|
|||
engine = CollisionEngine(clearance=2.0)
|
||||
danger_map = DangerMap(bounds=bounds)
|
||||
danger_map.precompute([])
|
||||
|
||||
|
||||
evaluator = CostEvaluator(engine, danger_map, greedy_h_weight=1.1)
|
||||
router = AStarRouter(evaluator, node_limit=100000)
|
||||
pf = PathFinder(router, evaluator)
|
||||
|
||||
|
||||
# 2. Define Netlist with various orientation challenges
|
||||
netlist = {
|
||||
# Opposite directions: requires two 90-degree bends to flip orientation
|
||||
"opposite": (Port(10, 80, 0), Port(90, 80, 180)),
|
||||
|
||||
|
||||
# 90-degree turn: standard L-shape
|
||||
"turn_90": (Port(10, 60, 0), Port(40, 90, 90)),
|
||||
|
||||
|
||||
# Output behind input: requires a full U-turn
|
||||
"behind": (Port(80, 40, 0), Port(20, 40, 0)),
|
||||
|
||||
|
||||
# Sharp return: output is behind and oriented towards the input
|
||||
"return_loop": (Port(80, 20, 0), Port(40, 10, 180)),
|
||||
}
|
||||
net_widths = {nid: 2.0 for nid in netlist}
|
||||
net_widths = dict.fromkeys(netlist, 2.0)
|
||||
|
||||
# 3. Route
|
||||
results = pf.route_all(netlist, net_widths)
|
||||
|
|
|
|||
BIN
examples/06_bend_collision_models.png
Normal file
BIN
examples/06_bend_collision_models.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
70
examples/06_bend_collision_models.py
Normal file
70
examples/06_bend_collision_models.py
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
from shapely.geometry import Polygon
|
||||
|
||||
from inire.geometry.collision import CollisionEngine
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.router.astar import AStarRouter
|
||||
from inire.router.cost import CostEvaluator
|
||||
from inire.router.danger_map import DangerMap
|
||||
from inire.router.pathfinder import PathFinder
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 06: Bend Collision Models...")
|
||||
|
||||
# 1. Setup Environment
|
||||
# Give room for 10um bends near the edges
|
||||
bounds = (-20, -20, 170, 170)
|
||||
engine = CollisionEngine(clearance=2.0)
|
||||
danger_map = DangerMap(bounds=bounds)
|
||||
|
||||
# Create three scenarios with identical obstacles
|
||||
# We'll space them out vertically
|
||||
obs_arc = Polygon([(40, 110), (60, 110), (60, 130), (40, 130)])
|
||||
obs_bbox = Polygon([(40, 60), (60, 60), (60, 80), (40, 80)])
|
||||
obs_clipped = Polygon([(40, 10), (60, 10), (60, 30), (40, 30)])
|
||||
|
||||
obstacles = [obs_arc, obs_bbox, obs_clipped]
|
||||
for obs in obstacles:
|
||||
engine.add_static_obstacle(obs)
|
||||
danger_map.precompute(obstacles)
|
||||
|
||||
# We'll run three separate routers since collision_type is a router-level config
|
||||
evaluator = CostEvaluator(engine, danger_map)
|
||||
|
||||
# Scenario 1: Standard 'arc' model (High fidelity)
|
||||
router_arc = AStarRouter(evaluator, bend_collision_type="arc")
|
||||
netlist_arc = {"arc_model": (Port(10, 120, 0), Port(90, 140, 90))}
|
||||
|
||||
# Scenario 2: 'bbox' model (Conservative axis-aligned box)
|
||||
router_bbox = AStarRouter(evaluator, bend_collision_type="bbox")
|
||||
netlist_bbox = {"bbox_model": (Port(10, 70, 0), Port(90, 90, 90))}
|
||||
|
||||
# Scenario 3: 'clipped_bbox' model (Balanced)
|
||||
router_clipped = AStarRouter(evaluator, bend_collision_type="clipped_bbox", bend_clip_margin=1.0)
|
||||
netlist_clipped = {"clipped_model": (Port(10, 20, 0), Port(90, 40, 90))}
|
||||
|
||||
# 2. Route each scenario
|
||||
print("Routing Scenario 1 (Arc)...")
|
||||
res_arc = PathFinder(router_arc, evaluator).route_all(netlist_arc, {"arc_model": 2.0})
|
||||
|
||||
print("Routing Scenario 2 (BBox)...")
|
||||
res_bbox = PathFinder(router_bbox, evaluator).route_all(netlist_bbox, {"bbox_model": 2.0})
|
||||
|
||||
print("Routing Scenario 3 (Clipped BBox)...")
|
||||
res_clipped = PathFinder(router_clipped, evaluator).route_all(netlist_clipped, {"clipped_model": 2.0})
|
||||
|
||||
# 3. Combine results for visualization
|
||||
all_results = {**res_arc, **res_bbox, **res_clipped}
|
||||
all_netlists = {**netlist_arc, **netlist_bbox, **netlist_clipped}
|
||||
|
||||
# 4. Visualize
|
||||
# Note: plot_routing_results will show the 'collision geometry' used by the router
|
||||
# since that's what's stored in res.path[i].geometry
|
||||
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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue