examples work
This commit is contained in:
parent
9fac436c50
commit
7b0dddfe45
22 changed files with 579 additions and 334 deletions
46
examples/09_unroutable_best_effort.py
Normal file
46
examples/09_unroutable_best_effort.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
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, RoutingResult
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
from shapely.geometry import box
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 09: Unroutable Nets & Best Effort Display...")
|
||||
|
||||
bounds = (0, 0, 100, 100)
|
||||
engine = CollisionEngine(clearance=2.0)
|
||||
|
||||
# A large obstacle that completely blocks the target port
|
||||
blocking_obs = box(40, 0, 60, 100)
|
||||
engine.add_static_obstacle(blocking_obs)
|
||||
|
||||
danger_map = DangerMap(bounds=bounds)
|
||||
danger_map.precompute([blocking_obs])
|
||||
evaluator = CostEvaluator(engine, danger_map)
|
||||
|
||||
# Use a low node limit to fail quickly
|
||||
router = AStarRouter(evaluator, node_limit=5000)
|
||||
|
||||
netlist = {
|
||||
"blocked_net": (Port(10, 50, 0), Port(90, 50, 180))
|
||||
}
|
||||
|
||||
print("Routing blocked net (expecting failure)...")
|
||||
# Manually call route with return_partial=True
|
||||
path = router.route(netlist["blocked_net"][0], netlist["blocked_net"][1], 2.0,
|
||||
net_id="blocked_net", return_partial=True)
|
||||
|
||||
# Wrap in RoutingResult. Even if path is returned, is_valid=False
|
||||
results = {
|
||||
"blocked_net": RoutingResult("blocked_net", path if path else [], False, 1)
|
||||
}
|
||||
|
||||
fig, ax = plot_routing_results(results, [blocking_obs], bounds, netlist=netlist)
|
||||
fig.savefig("examples/09_unroutable_best_effort.png")
|
||||
print("Saved plot to examples/09_unroutable_best_effort.png")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue