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

Order Splitting Algorithm: Graph Coloring & OPA in Golang

Prerequisite: Review Part 8: Intelligent Order Release for previous context on order batching and VRPTW before starting this guide. Order Splitting at Scale: Graph Coloring, Bin Packing, and OPA in Go Answer-first: Real-time e-commerce order splitting is a Constraint Satisfaction Problem (CSP). The standard pipeline relies on Open Policy Agent (OPA) for dynamic rules, Golang (gonum) for Graph Coloring to resolve logical conflicts, and First-Fit Decreasing Bin Packing for physical constraints, executing in sub-50ms during synchronous checkout. Implementing this architecture enforces sub-50ms P99 latency guarantees, strict component isolation, and automated observability pipelines. ...

August 1, 2026 · 6 min · Lê Tuấn Anh

Warehouse Picker Routing: GraphHopper, OR-Tools & C++

Prerequisite: Review Part 9: Order Splitting Algorithm for the previous module on box estimation and graph coloring algorithms. Warehouse Picker Routing Optimization (GraphHopper & OR-Tools) Answer-first: Minimizing walking distance for warehouse pickers requires solving the Traveling Salesperson Problem (TSP) inside a physical building. The 2026 standard architecture uses a Java-based Indoor GraphHopper instance to generate a 100x100 Distance Matrix from custom OpenStreetMap (OSM) data, which is then fed into a C++ Google OR-Tools gRPC Microservice to calculate the absolute optimal pick sequence in under 15 milliseconds. ...

August 1, 2026 · 5 min · Lê Tuấn Anh

GPS Map Matching for Urban Canyon Noise: HMM & Kafka

GPS Map Matching for Urban Canyon Noise: HMM & Kafka Answer-first: Raw GPS data from IoT devices in dense urban environments suffers severe degradation due to the Urban Canyon effect. Traditional filters like Kalman fail because they lack spatial awareness (topology). The standard architectural solution is a Streaming Pipeline (using Kafka for backpressure) paired with a Map Matching Engine (OSRM or GraphHopper) powered by a Hidden Markov Model (HMM) to snap coordinates back to the road network at sub-50ms latency. ...

August 12, 2026 · 8 min · Tuan Anh

OSRM vs GraphHopper: Routing Engine Benchmarks & RAM

OSRM vs GraphHopper: Routing Engine Benchmarks & RAM Answer-first: Comparing OSRM and GraphHopper shows OSRM excelling in raw speed (<2ms single queries, <20ms 100x100 matrix) via C++ Contraction Hierarchies and Linux POSIX shared memory (mmap), while GraphHopper provides flexible Java-based runtime Custom Models, turn restrictions, and multi-profile vehicle fleets. For static ride-hailing matrices, choose OSRM; for heterogeneous delivery fleets with weight/height limits, choose GraphHopper. Introduction: When Do You Outgrow Cloud Route APIs? Building early-stage logistics applications with cloud routing APIs provides immediate reliability, accurate ETAs, and zero infrastructure maintenance. However, when daily traffic exceeds 100,000 requests or requires massive distance matrices for vehicle route optimization, proprietary API costs explode while rigid routing profiles prevent injecting custom fleet constraints. ...

July 17, 2026 · 10 min · Lê Tuấn Anh

GraphHopper Distance Matrix: API & OSM Hosting Guide

GraphHopper Distance Matrix: API & OSM Hosting Guide Answer-first: Self-hosting GraphHopper for distance matrix calculations leverages OpenStreetMap (OSM) PBF data, memory-mapped graph caches, and Java Contraction Hierarchies (CH) to compute 100x100 matrix queries in under 50ms at zero API cost (99.7% cost savings over Google Maps API). Pairing GraphHopper with H3 hexagonal spatial indexing and Redis semantic caching offloads 85%+ of repetitive route calculations in high-scale logistics and fleet dispatch systems. ...

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

Order Fulfillment Algorithm: Warehouse to Last-Mile

Order Fulfillment Algorithm: Warehouse to Last-Mile Answer-first: Optimizing e-commerce order fulfillment combines graph coloring for multi-item cart splitting, bin packing algorithms for packaging, and TSP routing for last-mile delivery dispatch. Implementing this architecture enforces sub-50ms P99 latency guarantees, zero-allocation memory pooling with Go 1.24 unique.Handle, and fault-tolerant Dapr 1.15 component orchestration for resilient production scaling. This design guarantees sub-50ms P99 latency bounds and zero-allocation memory pooling. Executive Summary & Fulfillment Fundamentals When an order is confirmed, the fulfillment system executes a multi-step decision pipeline: ...

June 1, 2026 · 7 min · Lê Tuấn Anh