Home▸Transport & Urbanism▸VRP with NN & 2-opt

Vehicle Routing Problem: Nearest-Neighbor + 2-opt Simulator

Interactive vehicle routing problem (VRP) solver: place a depot and customer delivery points, set vehicle capacity and fleet size, and watch a real nearest-neighbor construction heuristic followed by real 2-opt local search cut total route distance live.

Transport & Urbanism2DModerate60 FPS📱 Mobile-adapted
supply-chain-transportation-optimization-simulation ↗ Open standalone

This simulator solves a real Capacitated Vehicle Routing Problem (CVRP) in your browser: a depot ships to a set of customer points, each with its own demand, using a fleet whose vehicles each carry a fixed capacity. A nearest-neighbor construction heuristic builds an initial set of routes greedily, then a genuine 2-opt local search repeatedly tests reversing pairs of route edges and keeps only the reversals that strictly shorten total Euclidean travel distance, converging toward a local optimum the way production routing engines do. Add or remove customers, drag the depot, and tune vehicle capacity and fleet size to see how the constructed routes, their total length, and the number of vehicles needed all change in response — with a live before/after comparison of nearest-neighbor distance versus the 2-opt-improved distance.

⚙ Under the hood

Solve Capacitated VRP using nearest-neighbor and 2-opt to optimize delivery routes.

vrpnearest-neighbor2-optoperations-researchlogistics

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)