Reuse benchmark and reference runs, combine related geometry and replay checks, and run example outcome and timing checks from the same cases. Keep every benchmark board and retry holdout independently selectable.
97 lines
3.4 KiB
Python
97 lines
3.4 KiB
Python
from inire import CongestionOptions, RoutingOptions, RoutingProblem, SearchOptions
|
|
from inire.geometry.collision import RoutingWorld
|
|
from inire.geometry.primitives import Port
|
|
from inire.model import NetSpec
|
|
from inire.router._astar_types import AStarContext
|
|
from inire.router._router import PathFinder
|
|
from inire.router.cost import CostEvaluator
|
|
from inire.router.danger_map import DangerMap
|
|
|
|
|
|
def _build_pathfinder(
|
|
evaluator: CostEvaluator,
|
|
*,
|
|
bounds: tuple[float, float, float, float],
|
|
netlist: dict[str, tuple[Port, Port]],
|
|
net_widths: dict[str, float],
|
|
search: SearchOptions | None = None,
|
|
congestion: CongestionOptions | None = None,
|
|
) -> PathFinder:
|
|
nets = tuple(
|
|
NetSpec(net_id=net_id, start=start, target=target, width=net_widths.get(net_id, 2.0))
|
|
for net_id, (start, target) in netlist.items()
|
|
)
|
|
return PathFinder(
|
|
AStarContext(
|
|
evaluator,
|
|
RoutingProblem(bounds=bounds, nets=nets),
|
|
RoutingOptions(
|
|
search=SearchOptions() if search is None else search,
|
|
congestion=CongestionOptions() if congestion is None else congestion,
|
|
),
|
|
),
|
|
)
|
|
|
|
def test_verify_all_nets_cases():
|
|
"""
|
|
Validate that verify_all_nets catches some common cases and doesn't flag reasonable non-failing cases.
|
|
"""
|
|
engine = RoutingWorld(clearance=2.0)
|
|
danger_map = DangerMap(bounds=(0, 0, 100, 100))
|
|
danger_map.precompute([])
|
|
evaluator = CostEvaluator(collision_engine=engine, danger_map=danger_map)
|
|
|
|
# Case 1: Parallel paths exactly at clearance (Should be VALID)
|
|
netlist_parallel_ok = {
|
|
"net1": (Port(0, 50, 0), Port(100, 50, 0)),
|
|
"net2": (Port(0, 54, 0), Port(100, 54, 0)),
|
|
}
|
|
net_widths = {"net1": 2.0, "net2": 2.0}
|
|
|
|
results = _build_pathfinder(
|
|
evaluator,
|
|
bounds=(0, 0, 100, 100),
|
|
netlist=netlist_parallel_ok,
|
|
net_widths=net_widths,
|
|
congestion=CongestionOptions(warm_start_enabled=False, max_iterations=1),
|
|
).route_all()
|
|
assert results["net1"].is_valid, f"Exactly at clearance should be valid, collisions={results['net1'].collisions}"
|
|
assert results["net2"].is_valid
|
|
|
|
# Case 2: Parallel paths slightly within clearance (Should be INVALID)
|
|
netlist_parallel_fail = {
|
|
"net3": (Port(0, 20, 0), Port(100, 20, 0)),
|
|
"net4": (Port(0, 23, 0), Port(100, 23, 0)),
|
|
}
|
|
# Reset engine
|
|
engine.remove_path("net1")
|
|
engine.remove_path("net2")
|
|
|
|
results_p = _build_pathfinder(
|
|
evaluator,
|
|
bounds=(0, 0, 100, 100),
|
|
netlist=netlist_parallel_fail,
|
|
net_widths=net_widths,
|
|
congestion=CongestionOptions(warm_start_enabled=False, max_iterations=1),
|
|
).route_all()
|
|
# verify_all_nets should flag both as invalid because they cross-collide
|
|
assert not results_p["net3"].is_valid
|
|
assert not results_p["net4"].is_valid
|
|
|
|
# Case 3: Crossing paths (Should be INVALID)
|
|
netlist_cross = {
|
|
"net5": (Port(0, 75, 0), Port(100, 75, 0)),
|
|
"net6": (Port(50, 0, 90), Port(50, 100, 90)),
|
|
}
|
|
engine.remove_path("net3")
|
|
engine.remove_path("net4")
|
|
|
|
results_c = _build_pathfinder(
|
|
evaluator,
|
|
bounds=(0, 0, 100, 100),
|
|
netlist=netlist_cross,
|
|
net_widths=net_widths,
|
|
congestion=CongestionOptions(warm_start_enabled=False, max_iterations=1),
|
|
).route_all()
|
|
assert not results_c["net5"].is_valid
|
|
assert not results_c["net6"].is_valid
|