make sure to check self-intersections
This commit is contained in:
parent
d2d619fe1f
commit
de7254f8f5
4 changed files with 154 additions and 10 deletions
74
inire/tests/test_failed_net_congestion.py
Normal file
74
inire/tests/test_failed_net_congestion.py
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
|
||||
import pytest
|
||||
import numpy
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.geometry.collision import CollisionEngine
|
||||
from inire.router.cost import CostEvaluator
|
||||
from inire.router.astar import AStarRouter
|
||||
from inire.router.pathfinder import PathFinder
|
||||
from inire.router.danger_map import DangerMap
|
||||
|
||||
def test_failed_net_visibility():
|
||||
"""
|
||||
Verifies that nets that fail to reach their target (return partial paths)
|
||||
ARE added to the collision engine, making them visible to other nets
|
||||
for negotiated congestion.
|
||||
"""
|
||||
# 1. Setup
|
||||
engine = CollisionEngine(clearance=2.0)
|
||||
|
||||
# Create a simple danger map (bounds 0-100)
|
||||
# We don't strictly need obstacles in it for this test.
|
||||
dm = DangerMap(bounds=(0, 0, 100, 100))
|
||||
|
||||
evaluator = CostEvaluator(engine, dm)
|
||||
|
||||
# 2. Configure Router with low limit to FORCE failure
|
||||
# node_limit=5 is extremely low, likely allowing only a few moves.
|
||||
# Start (0,0) -> Target (100,0) is 100um away.
|
||||
# If snap is 1.0, direct jump S100 might be tried.
|
||||
# If direct jump works, it might succeed in 1 expansion.
|
||||
# So we need to block the direct jump or make the limit VERY small (0?).
|
||||
# Or place a static obstacle that forces a search.
|
||||
|
||||
# Let's add a static obstacle that blocks the direct path.
|
||||
from shapely.geometry import box
|
||||
obstacle = box(40, -10, 60, 10) # Wall at x=50
|
||||
engine.add_static_obstacle(obstacle)
|
||||
|
||||
# With obstacle, direct jump fails. A* must search around.
|
||||
# Limit=10 should be enough to fail to find a path around.
|
||||
router = AStarRouter(evaluator, node_limit=10)
|
||||
|
||||
# 3. Configure PathFinder
|
||||
# max_iterations=1 because we only need to check the state after the first attempt.
|
||||
pf = PathFinder(router, evaluator, max_iterations=1, warm_start=None)
|
||||
|
||||
netlist = {
|
||||
"net1": (Port(0, 0, 0), Port(100, 0, 0))
|
||||
}
|
||||
net_widths = {"net1": 1.0}
|
||||
|
||||
# 4. Route
|
||||
print("\nStarting Route...")
|
||||
results = pf.route_all(netlist, net_widths)
|
||||
|
||||
res = results["net1"]
|
||||
print(f"Result: is_valid={res.is_valid}, reached={res.reached_target}, path_len={len(res.path)}")
|
||||
|
||||
# 5. Verify Failure Condition
|
||||
# We expect reached_target to be False because of node_limit + obstacle
|
||||
assert not res.reached_target, "Test setup failed: Net reached target despite low limit!"
|
||||
assert len(res.path) > 0, "Test setup failed: No partial path returned!"
|
||||
|
||||
# 6. Verify Visibility
|
||||
# Check if net1 is in the collision engine
|
||||
found_nets = set()
|
||||
# CollisionEngine.dynamic_geometries: dict[obj_id, (net_id, poly)]
|
||||
for obj_id, (nid, poly) in engine.dynamic_geometries.items():
|
||||
found_nets.add(nid)
|
||||
|
||||
print(f"Nets found in engine: {found_nets}")
|
||||
|
||||
# The FIX Expectation: "net1" SHOULD be present
|
||||
assert "net1" in found_nets, "Bug present: Net1 is invisible despite having partial path!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue