Logistics & Optimization

The Vehicle Routing Problem (VRP) Explained

The Traveling Salesperson Problem deals with one driver. The Vehicle Routing Problem deals with an entire fleet. Discover the algorithms that power modern supply chains, FedEx deliveries, and Uber routing.

18 Min Read Updated: June 2026 Advanced Level
Mohammed Islam Hadjoudj
Mohammed Islam Hadjoudj
Expert Operations Research Engineer

1. What is the Vehicle Routing Problem?

The Vehicle Routing Problem (VRP) is a combinatorial optimization and integer programming problem that asks: "What is the optimal set of routes for a fleet of vehicles to traverse in order to deliver to a given set of customers?"

Introduced in 1959 by George Dantzig and John Ramser, the VRP is a central problem in the fields of transportation, distribution, and logistics. The goal is typically to minimize the total route cost (which could mean minimizing distance, time, fuel, or the number of vehicles used) while ensuring that every customer is visited exactly once.

In a standard VRP:

2. VRP vs. TSP: Understanding the Difference

If you are familiar with graph theory, the VRP sounds suspiciously like the Traveling Salesperson Problem (TSP). In fact, the VRP is a generalization of the TSP.

The core difference is the number of actors:

Because the TSP is already NP-Hard (computationally intractable for exact solutions at large scales), the VRP is also NP-Hard, but significantly more complex due to the added clustering dimension.

Side by side comparison. On the left, TSP uses a single vehicle whose one loop passes through the depot and all six stops. On the right, VRP splits the same six stops into two clusters, each served by its own vehicle looping out from and back to the central depot.
TSP is one loop through every stop. VRP first clusters the stops, then runs a route for each vehicle out of a shared depot.

3. Common Variations of VRP

The basic VRP assumes infinite vehicle capacity and no time constraints. In the real world, a FedEx truck cannot carry infinite packages. This has led to the creation of several highly practical variations of the VRP.

Capacitated Vehicle Routing Problem (CVRP)

In the CVRP, every vehicle has a maximum carrying capacity (e.g., a truck can hold 500 lbs), and every customer has a specific demand (e.g., Customer A needs 50 lbs of goods). A vehicle's route must end, and it must return to the depot, before the sum of the demands on its route exceeds its capacity. This is the most common variation studied in operations research.

A depot with six customers, each labeled with a demand in units. A blue route serves customers 2, 3 and 4 with demands 40, 30 and 30 that sum to exactly the 100-unit truck capacity, so the truck is full and returns to the depot. A green route serves customers 1, 6 and 5 with demands 30, 25 and 20 summing to 75. Total demand of 175 exceeds the capacity, so one truck cannot serve everyone.
In the CVRP, the blue route fills the truck to its 100-unit limit and must head back to the depot, so a second route is needed for the remaining demand.

Vehicle Routing Problem with Time Windows (VRPTW)

In the VRPTW, customers require deliveries within specific time frames. For example, a restaurant might need its ingredients delivered between 8:00 AM and 10:00 AM. If a truck arrives at 7:30 AM, it must wait. If it arrives at 10:15 AM, the delivery fails. This adds severe timing constraints to the routing logic.

Other Notable Variations

Interactive VRP Simulator

Watch a fleet of vehicles navigate a city grid. Add capacity constraints and watch how the algorithm forces trucks back to the depot when they run out of space.

Launch the VRP Visualizer

4. How is the VRP Solved?

Because the VRP is NP-Hard, calculating the absolute perfect set of routes for hundreds of customers is practically impossible. Instead, logistics companies rely on a two-phase approach to find "near-optimal" routes very quickly.

Phase 1: Cluster First, Route Second

The most intuitive human approach is also used by algorithms. First, group the customers into clusters based on geographical proximity and vehicle capacity. Once you have a cluster of customers assigned to a specific truck, you treat that cluster as a standalone Traveling Salesperson Problem and solve for the shortest path.

Phase 2: Metaheuristics

Once an initial set of routes is established, algorithms attempt to continuously improve them. These are known as metaheuristics.

5. The Clarke and Wright Savings Algorithm

If you want to write a VRP solver, the best place to start is the Clarke and Wright Savings Algorithm, developed in 1964. It remains one of the most famous and widely implemented heuristics for the Capacitated VRP (CVRP).

The logic is based on the concept of "savings."

  1. Start with the worst case: Imagine you have 10 customers. You send 10 separate trucks out from the depot. Truck 1 goes to Customer 1 and returns. Truck 2 goes to Customer 2 and returns, etc.
  2. Calculate Savings: If you combine the routes (Depot -> Customer 1 -> Customer 2 -> Depot), how much distance do you save compared to sending two separate trucks? You calculate this "savings" value for every possible pair of customers.
  3. Sort and Merge: You sort the pairs by the highest savings. You then aggressively merge routes together, starting with the biggest savings, provided that the combined route does not exceed the vehicle's maximum capacity.
Two panels. On the left, two separate out-and-back trips: the depot to customer A and back, and the depot to customer B and back, each edge of length 10, for a total of 40. On the right, the trips are merged into one loop depot to A to B to depot with edge lengths 10, 4 and 10, for a total of 24. The savings equals 10 plus 10 minus 4, which is 16.
The savings for merging A and B is d(Depot,A) + d(Depot,B) − d(A,B). Clarke-Wright merges the pairs with the largest savings first, as long as capacity allows.

This algorithm runs in O(n^2 log n) time and produces highly efficient routes almost instantly, serving as the baseline upon which metaheuristics can improve.

6. Real-World Applications

A 5% improvement in VRP optimization translates to millions of dollars in savings for major corporations.

Frequently Asked Questions

What is the difference between TSP and the Vehicle Routing Problem (VRP)?

TSP asks for a single route visiting all cities. VRP generalizes this to finding optimal routes for a fleet of multiple vehicles starting from a central depot to service customers.

What is Capacitated Vehicle Routing (CVRP)?

CVRP is a VRP variant where each vehicle has a maximum carrying capacity. Vehicles must return to the depot to reload once they reach their capacity limit.

How do modern delivery companies solve VRP?

Because VRP is NP-hard, companies use metaheuristics (like Tabu Search, Genetic Algorithms, or Simulated Annealing) combined with specialized routing software to calculate routes in minutes.

Further Exploration

Route Your Own Fleet

Stop theorizing and start optimizing. Create a depot, place 50 customers on a map, assign capacity limits to three trucks, and watch the Clarke-Wright algorithm calculate the optimal routes in real-time.

Launch the VRP Visualizer