Tighter A* estimate on the orthogonal track, and --heuristic-weight
The grid search estimated the remaining distance as a straight line even when only orthogonal steps exist; Manhattan is the tighter estimate those moves admit and still never overestimates. --heuristic-weight W (default 1) makes it weighted A*: routes at most W times the shortest (tested).
This commit is contained in:
@@ -73,3 +73,24 @@ def test_resolution_one_has_no_halo_so_the_grid_is_unchanged():
|
||||
assert GridRouter(board, trace_width=2500, clearance=1500)._halo_offsets == []
|
||||
fine = GridRouter(board, trace_width=2500, clearance=1500, resolution=2)
|
||||
assert fine.step == 2000 and (1, 0) in fine._halo_offsets and (2, 0) not in fine._halo_offsets
|
||||
|
||||
|
||||
def test_heuristic_weight_bounds_route_length():
|
||||
# weighted A* may take a longer route, but never more than W times the shortest
|
||||
places = "(place A 3000 -3000 front 0) (place B 17000 -17000 front 0)"
|
||||
|
||||
def length(weight):
|
||||
result, _, _ = route_dsn_board_exact(
|
||||
parse_dsn(_dsn(f"(component P {places})", "(net N (pins A-1 B-1))")),
|
||||
heuristic_weight=weight,
|
||||
)
|
||||
return sum(
|
||||
math.hypot(q.x - p.x, q.y - p.y)
|
||||
for segs in result.result.wires.values()
|
||||
for _layer, pts in segs
|
||||
for p, q in zip(pts, pts[1:], strict=False)
|
||||
)
|
||||
|
||||
shortest = length(1.0)
|
||||
assert shortest > 0
|
||||
assert length(2.0) <= 2.0 * shortest
|
||||
|
||||
Reference in New Issue
Block a user