CVRP & VRPTW Fleet Optimization: Go ALNS Routing Engine

Answer-first: Combinatorial fleet routing at scale requires decoupling road-network distance calculation from vehicle assignment. By pairing an in-memory OSRM table engine with an Adaptive Large Neighborhood Search (ALNS) solver written in Go 1.24, engineering teams can solve Capacitated Vehicle Routing with Time Windows (VRPTW) for 500+ stops in under 800ms while eliminating 99% of third-party map API costs. Key Architectural Takeaways NP-Hard Complexity Separation: Point-to-point routing (A*, Dijkstra, Contraction Hierarchies) solves the shortest path between 2 physical nodes in O(E + V log V) time. Combinatorial vehicle routing (CVRP/VRPTW) optimizes the permutation of N stops across K heterogeneous vehicles in O(K * N!) search space. Combining them into a single monolithic loop causes catastrophic CPU bottlenecks. ALNS as the Industry Gold Standard: Exact solvers (Branch-and-Cut, Mixed Integer Linear Programming) fail when N > 40. Adaptive Large Neighborhood Search (ALNS) dynamically orchestrates coupled Destroy (Shaw, Worst, Random) and Repair (Regret-k, Greedy) heuristics with Simulated Annealing cooling, converging to within 1% to 3% of the theoretical global optimum. Zero-Allocation Memory Topology: High-frequency solver loops incur severe Garbage Collection (GC) pauses when using nested slices ([][]float64). Laying out N x N cost matrices into single contiguous 1D arrays ([from * N + to]) and recycling candidate states via sync.Pool maximizes CPU L1/L2 cache line hits (64 bytes) and sustains sub-millisecond execution. FinOps ROI: Self-hosting an in-memory OSRM Table cluster paired with a Go ALNS microservice reduces fleet mileage by 15% to 25% and saves tens of thousands of dollars monthly compared to quadratic O(N^2) billing on Google Routes Matrix APIs. 1. Problem Taxonomy: From TSP to Multi-Depot VRPTW Before writing a single line of optimization code, systems architects must classify the operational constraints of their logistics domain. Real-world delivery networks rarely resemble the idealized Traveling Salesperson Problem (TSP). ...

August 15, 2026 · 15 min · Lê Tuấn Anh

Part 1: Core Routing Algorithms — A* & Dijkstra Visualized

Prerequisite: This part builds on the concepts introduced in the Executive Summary. Part 1: Core Routing Algorithms — A* & Dijkstra Visualized Answer-first: A* pathfinding uses Euclidean heuristics to accelerate 1-to-1 point routing, whereas Single-Source Dijkstra is mathematically superior for 1-to-N distance matrix calculations because it builds a single shortest-path search tree to all reachable destinations in one pass. Implementing this architecture enforces sub-50ms P99 latency guarantees, zero-allocation memory management with Go 1.24 unique.Handle, and fault-tolerant Dapr 1.15 component orchestration. ...

June 14, 2026 · 11 min · Lê Tuấn Anh