Skip to content

Route the HPA* coarse grid without value barriers#3659

Merged
brendancol merged 2 commits into
mainfrom
deep-sweep-accuracy-pathfinding-2026-07-08-02
Jul 9, 2026
Merged

Route the HPA* coarse grid without value barriers#3659
brendancol merged 2 commits into
mainfrom
deep-sweep-accuracy-pathfinding-2026-07-08-02

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3647

  • _hpa_star_search now routes the coarsened grid with an empty barrier list. Coarse cell values are block means of the non-barrier fine cells, so testing them against the exact barrier values could falsely block a passable block whose values average to a barrier value (alternating -1/+1 data with barriers=[0] makes every block mean exactly 0.0, blocking the whole coarse grid and returning all-NaN "no path" on a fully passable surface).
  • _coarsen_surface already marks fully-barrier blocks as NaN, and NaN cells stay impassable in the coarse search, so no blocking information is lost. Refinement still runs on the fine grid with the caller's barriers.

Backends: HPA* runs on the numpy and cupy (CPU-fallback) paths only; the dask sparse A* never coarsens.

Test plan:

  • test_hpa_star_barrier_valued_block_means (fails on main: 0 finite pixels)
  • Re-ran the issue's end-to-end repro (600x600, mocked RAM, auto-radius HPA*): goal reached after the fix
  • pytest xrspatial/tests/test_pathfinding.py — 58 passed, including the existing HPA* correctness and all-NaN no-path tests
  • flake8 clean on changed lines

Also includes this sweep's state-CSV update.

https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4

Coarse cell values are block means of the non-barrier fine cells, so
testing them against the exact barrier values can falsely block a
passable block whose values average to a barrier value (e.g. -1/+1
data with barriers=[0] gives every block mean 0.0), turning a fully
passable grid into all-NaN "no path". _coarsen_surface already
encodes fully-barrier blocks as NaN, so the coarse route now runs
with an empty barrier list.

Claude-Session: https://claude.ai/code/session_0155N4QGamQVxgpAAPbpQNq4

@brendancol brendancol left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Domain-aware review of the HPA* coarse-barrier fix.

Blockers

None.

Suggestions

  • The empty array reuses barriers.dtype, which keeps the numba signature of _a_star_search stable across the coarse and fine calls when callers pass integer barrier lists. Good; a bare np.array([]) would have forced a second float64 specialization but also worked. No change needed.

Nits

  • The fix only touches the coarse route. Refinement (_bounded_a_star_sub) still runs on the fine grid with the caller's barriers, so true barriers keep constraining the actual path; the change removes only the mean-aliasing false blocks. The pre-existing semantics that a block with any single crossable cell is coarse-passable are unchanged, and the radius-escalation loop plus the #3638 all-NaN contract still cover refinement dead-ends.

Verified locally: the new test returns 0 finite pixels on main and a connected start-to-goal path with the fix; the issue's end-to-end repro (600x600, mocked RAM so auto-radius HPA* engages, barriers=[0]) reaches the goal after the fix; test_hpa_star_correctness and test_hpa_star_unreachable_goal_all_nan still pass (58 total).

@brendancol brendancol merged commit 3469f2a into main Jul 9, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HPA* coarse routing falsely blocks passable blocks whose mean equals a barrier value

1 participant