improve exmples

This commit is contained in:
jan 2026-03-08 23:03:07 -07:00
commit ba76589ffb
5 changed files with 49 additions and 54 deletions

View file

@ -1,4 +1,3 @@
from inire.geometry.collision import CollisionEngine
from inire.geometry.primitives import Port
from inire.router.astar import AStarRouter
@ -9,7 +8,7 @@ from inire.utils.visualization import plot_routing_results
def main() -> None:
print("Running Example 02: Congestion Resolution (Crossing)...")
print("Running Example 02: Congestion Resolution (Triple Crossing)...")
# 1. Setup Environment (Open space)
bounds = (0, 0, 100, 100)
@ -22,23 +21,24 @@ def main() -> None:
pf = PathFinder(router, evaluator)
# 2. Define Netlist
# Two nets that MUST cross.
# Since crossings are illegal in single-layer routing, one net must detour around the other.
# Three nets that all converge on the same central area.
# Negotiated Congestion must find non-overlapping paths for all of them.
netlist = {
"horizontal": (Port(10, 50, 0), Port(90, 50, 0)),
"vertical": (Port(50, 10, 90), Port(50, 90, 90)),
"vertical_up": (Port(45, 10, 90), Port(45, 90, 90)),
"vertical_down": (Port(55, 90, 270), Port(55, 10, 270)),
}
net_widths = {"horizontal": 2.0, "vertical": 2.0}
net_widths = {nid: 2.0 for nid in netlist}
# 3. Route with Negotiated Congestion
# We increase the base penalty to encourage faster divergence
pf.base_congestion_penalty = 500.0
pf.base_congestion_penalty = 1000.0
results = pf.route_all(netlist, net_widths)
# 4. Check Results
all_valid = all(r.is_valid for r in results.values())
if all_valid:
print("Success! Congestion resolved (one net detoured).")
print("Success! Congestion resolved for all nets.")
else:
print("Some nets failed or have collisions.")
for nid, res in results.items():