Check reference route clearance against peers and fixed routes
This commit is contained in:
parent
8c8cbe569b
commit
495bf8d307
1 changed files with 10 additions and 6 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
from dataclasses import replace
|
from dataclasses import replace
|
||||||
from itertools import combinations
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from shapely import union_all
|
from shapely import union_all
|
||||||
|
|
@ -136,16 +135,21 @@ def _check_reference_paths(case) -> RoutingRunResult:
|
||||||
assert run.metrics.nodes_expanded == 0
|
assert run.metrics.nodes_expanded == 0
|
||||||
assert run.results_by_net.keys() == reference.keys()
|
assert run.results_by_net.keys() == reference.keys()
|
||||||
board = box(*problem.bounds)
|
board = box(*problem.bounds)
|
||||||
footprints = []
|
occupied = [polygon for fixed in problem.fixed_routes for polygon in fixed.polygons]
|
||||||
|
clearance = problem.clearance
|
||||||
|
separation = clearance - TOLERANCE_LINEAR * min(1.0, clearance)
|
||||||
for result in run.results_by_net.values():
|
for result in run.results_by_net.values():
|
||||||
assert result.is_valid
|
assert result.is_valid
|
||||||
assert result.as_seed() == reference[result.net_id]
|
assert result.as_seed() == reference[result.net_id]
|
||||||
footprint = union_all(result.locked_geometry)
|
footprint = union_all(result.locked_geometry)
|
||||||
assert board.covers(footprint)
|
assert board.covers(footprint)
|
||||||
assert all(footprint.distance(obstacle) >= problem.clearance - TOLERANCE_LINEAR for obstacle in problem.static_obstacles)
|
if clearance:
|
||||||
footprints.append(footprint)
|
assert all(footprint.distance(obstacle) >= separation for obstacle in problem.static_obstacles)
|
||||||
for a, b in combinations(footprints, 2):
|
assert all(footprint.distance(other) >= separation for other in occupied)
|
||||||
assert a.distance(b) >= problem.clearance - TOLERANCE_LINEAR
|
else:
|
||||||
|
assert all(footprint.disjoint(obstacle) or footprint.touches(obstacle) for obstacle in problem.static_obstacles)
|
||||||
|
assert all(footprint.disjoint(other) for other in occupied)
|
||||||
|
occupied.append(footprint)
|
||||||
return run
|
return run
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue