routing: add a real heuristic to public route search#19
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ec700ecca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let Some(to_node) = self.graph.node_weight(to) else { | ||
| return 0.0; | ||
| }; | ||
| haversine_distance(from_node.coord(), to_node.coord()) |
There was a problem hiding this comment.
Avoid non-admissible heuristics on
from_test_data graphs
When a graph comes from from_test_data or any other synthetic source where distance_m / travel_time_s are not derived from the node coordinates, haversine_distance is not a safe lower bound. from_test_data explicitly accepts arbitrary weights (the example in this file uses nodes ~28 km apart with a 1 km edge), so distance_lower_bound_between and time_lower_bound_between can exceed the true remaining cost. Because src/routing/algo.rs::astar returns on the first goal pop, these new heuristics can now make route* return a non-optimal path on custom/test networks, whereas the previous zero-heuristic behavior stayed correct.
Useful? React with 👍 / 👎.
Summary
The public routing entry points were still calling
astarwith a zero heuristic, so route search behaved like Dijkstra even though the API and docs implied A*-style search.This change adds admissible straight-line lower bounds to every public A* route search:
Validation
Notes
The repository does not currently have a dedicated route-search benchmark harness, so this PR implements the heuristic change and correctness coverage but does not add benchmark artifacts.
Fixes #6