Skip to content

feat(routing): add A* geographic heuristic - #7

Open
404khai wants to merge 1 commit into
mainfrom
feat/phase-6-astar
Open

feat(routing): add A* geographic heuristic#7
404khai wants to merge 1 commit into
mainfrom
feat/phase-6-astar

Conversation

@404khai

@404khai 404khai commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • implement manual A* search with BinaryHeap, best-cost tracking, predecessor reconstruction, and deterministic tie-breaking
  • scale Haversine distance by the minimum graph edge cost per geodesic meter so the heuristic remains admissible for distance, travel-time, and custom nonnegative additive cost models
  • share endpoint validation, cost evaluation, sorted adjacency, and route reconstruction with Dijkstra
  • identify the selected algorithm in RouteResult
  • add correctness coverage for optimal-cost parity, travel-time routing, reduced exploration, zero-heuristic fallback, invalid endpoints, and unreachable destinations
  • add a reproducible 1K/10K/100K Criterion comparison and store the measured result

Heuristic correctness

For the selected model and context:

cost_per_meter = min(edge_cost / Haversine(edge.from, edge.to))
heuristic(node) = cost_per_meter * Haversine(node, destination)

Every traversable edge cost is bounded below by its scaled geographic distance. Combined with the Haversine triangle inequality, this keeps the heuristic admissible and consistent. Graphs without positive geographic span use a zero heuristic and safely fall back to Dijkstra search order.

Benchmark findings

The deterministic geographic benchmark verified identical optimal paths and costs. A* finalized 90% fewer nodes at 1K, 10K, and 100K nodes. End-to-end median latency was still 44.3%, 40.8%, and 23.7% slower because heuristic preparation is included in every routing call. The PR records this tradeoff and does not claim an unmeasured speedup.

Memory is explicitly marked unmeasured because no controlled allocator or profiler is configured.

Verification

  • cargo fmt --all -- --check
  • cargo test --workspace --all-features --locked
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo bench -p roadrunner-core --bench astar --locked

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.

1 participant