Refactor: Remove AStarRouter, introduce AStarContext/AStarMetrics
This commit is contained in:
parent
62d357c147
commit
a77ae781a7
23 changed files with 226 additions and 276 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from inire.geometry.collision import CollisionEngine
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.router.astar import AStarRouter
|
||||
from inire.router.astar import AStarContext, route_astar
|
||||
from inire.router.cost import CostEvaluator
|
||||
from inire.router.danger_map import DangerMap
|
||||
from inire.router.pathfinder import PathFinder
|
||||
|
|
@ -8,7 +8,7 @@ from inire.utils.visualization import plot_routing_results
|
|||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 04: S-Bends and Multiple Radii...")
|
||||
print("Running Example 04: SBends and Radii Strategy...")
|
||||
|
||||
# 1. Setup Environment
|
||||
bounds = (0, 0, 100, 100)
|
||||
|
|
@ -16,45 +16,33 @@ def main() -> None:
|
|||
danger_map = DangerMap(bounds=bounds)
|
||||
danger_map.precompute([])
|
||||
|
||||
# 2. Configure Router
|
||||
evaluator = CostEvaluator(
|
||||
engine,
|
||||
danger_map,
|
||||
unit_length_cost=1.0,
|
||||
bend_penalty=10.0,
|
||||
sbend_penalty=20.0,
|
||||
)
|
||||
|
||||
router = AStarRouter(
|
||||
evaluator = CostEvaluator(engine, danger_map, bend_penalty=200.0, sbend_penalty=400.0)
|
||||
|
||||
# Define a custom router with multiple SBend radii and specific offsets
|
||||
context = AStarContext(
|
||||
evaluator,
|
||||
node_limit=50000,
|
||||
snap_size=1.0,
|
||||
bend_radii=[10.0, 30.0],
|
||||
sbend_offsets=[5.0], # Use a simpler offset
|
||||
bend_penalty=10.0,
|
||||
sbend_penalty=20.0,
|
||||
snap_to_target_dist=50.0, # Large snap range
|
||||
bend_radii=[20.0, 50.0],
|
||||
sbend_radii=[5.0, 10.0, 50.0],
|
||||
sbend_offsets=[2.0, 5.0, 10.0, 20.0, 50.0]
|
||||
)
|
||||
pf = PathFinder(context)
|
||||
|
||||
pf = PathFinder(router, evaluator)
|
||||
# 2. Define Netlist
|
||||
# High-density parallel nets with varying offsets
|
||||
netlist = {}
|
||||
for i in range(10):
|
||||
# Starts at x=50, y=50+i*10. Targets at x=450, y=60+i*10.
|
||||
# This forces small vertical jogs (SBends)
|
||||
netlist[f"net_{i}"] = (Port(50, 50 + i * 10, 0), Port(450, 55 + i * 10, 0))
|
||||
|
||||
net_widths = {nid: 2.0 for nid in netlist}
|
||||
|
||||
# 3. Define Netlist
|
||||
# start (10, 50), target (60, 55) -> 5um offset
|
||||
netlist = {
|
||||
"sbend_only": (Port(10, 50, 0), Port(60, 55, 0)),
|
||||
"multi_radii": (Port(10, 10, 0), Port(90, 90, 0)),
|
||||
}
|
||||
net_widths = {"sbend_only": 2.0, "multi_radii": 2.0}
|
||||
# 3. Route
|
||||
print(f"Routing {len(netlist)} nets with custom SBend strategy...")
|
||||
results = pf.route_all(netlist, net_widths, shuffle_nets=True)
|
||||
|
||||
# 4. Route
|
||||
results = pf.route_all(netlist, net_widths)
|
||||
|
||||
# 5. Check Results
|
||||
for nid, res in results.items():
|
||||
status = "Success" if res.is_valid else "Failed"
|
||||
print(f"{nid}: {status}, collisions={res.collisions}")
|
||||
|
||||
# 6. Visualize
|
||||
# 4. Visualize
|
||||
fig, ax = plot_routing_results(results, [], bounds, netlist=netlist)
|
||||
fig.savefig("examples/04_sbends_and_radii.png")
|
||||
print("Saved plot to examples/04_sbends_and_radii.png")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue