Route editor: "Optimise order" action (2-opt/Or-opt, one undo step) #45

Closed
opened 2026-11-02 08:54:27 +00:00 by maximus · 1 comment
Member

Follow-up to #44 (DWIM insert / undo history). Parked 2026-11-02, focus is the nas exodus.

Idea

An explicit "Optimise order" action in the route editor, rather than a TSP solve on every inserted point.

Why not TSP on every insert

  • Waypoint order is user intent (loop direction, out-and-back, summit before hut); reordering after each click would shuffle deliberate points and confuse undo.
  • The DWIM insert is already cheapest insertion; a solver would only add a reorder of the points already there.
  • The costly part is distances, not the solver: as far as we know BRouter has no matrix endpoint, so n waypoints mean about n² route calls.
  • Problem size is tiny (< 100 waypoints): 2-opt + Or-opt in TypeScript runs in under 1 ms, so there's no need for Rust/C/WASM.

Proposal

  • Button "Optimise order": fixed start (and fixed end unless the route is a loop).
  • 2-opt + Or-opt on haversine distances, then a single BRouter routing of the result.
  • Show the length before and after; apply only if shorter; one undo-history entry.
  • Optional "precise" mode for small routes (≤ 15 points, about 200 cached BRouter calls) using trail distances.

Solver options considered (not needed at this size)

  • LKH-3 (C): research-only licence, unsuitable.
  • Concorde (C): exact but academic licence, overkill.
  • OR-Tools (C++, Apache-2.0): heavy; better as a sidecar than as WASM.
  • VROOM (C++, BSD): built for OSRM/Valhalla/ORS distances, not BRouter.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMf4EHnnNBqMcGPkv3bzvQ

Follow-up to #44 (DWIM insert / undo history). Parked 2026-11-02, focus is the nas exodus. ## Idea An explicit **"Optimise order"** action in the route editor, rather than a TSP solve on every inserted point. ## Why not TSP on every insert - Waypoint order is user intent (loop direction, out-and-back, summit before hut); reordering after each click would shuffle deliberate points and confuse undo. - The DWIM insert is already cheapest insertion; a solver would only add a reorder of the points already there. - The costly part is distances, not the solver: as far as we know BRouter has no matrix endpoint, so n waypoints mean about n² route calls. - Problem size is tiny (< 100 waypoints): 2-opt + Or-opt in TypeScript runs in under 1 ms, so there's no need for Rust/C/WASM. ## Proposal - Button "Optimise order": fixed start (and fixed end unless the route is a loop). - 2-opt + Or-opt on haversine distances, then a single BRouter routing of the result. - Show the length before and after; apply only if shorter; one undo-history entry. - Optional "precise" mode for small routes (≤ 15 points, about 200 cached BRouter calls) using trail distances. ## Solver options considered (not needed at this size) - LKH-3 (C): research-only licence, unsuitable. - Concorde (C): exact but academic licence, overkill. - OR-Tools (C++, Apache-2.0): heavy; better as a sidecar than as WASM. - VROOM (C++, BSD): built for OSRM/Valhalla/ORS distances, not BRouter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XMf4EHnnNBqMcGPkv3bzvQ
Author
Member

Fixed in batch PR #72 (deploy 5577c715), live since 2026-11-05 ~22:10 CET in wanderer-web:deploy-5577c715 (homelab-flux #857). Verified with the live e2e suite and acceptance re-runs as claude_test.

🤖 Generated with Claude Code

Fixed in batch PR #72 (`deploy` 5577c715), live since 2026-11-05 ~22:10 CET in `wanderer-web:deploy-5577c715` (homelab-flux #857). Verified with the live e2e suite and acceptance re-runs as `claude_test`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/wanderer#45
No description provided.