Vehicle routing
Problem description
Using a fleet of vehicles, pick up the objects of each customer and bring them to the depot. Each vehicle can service multiple customers, but it has a limited capacity.
Besides the basic case (CVRP), there is also a variant with time windows (CVRPTW).
Hard constraints:

Vehicle capacity: a vehicle cannot carry more items then its capacity.

Time windows (only in CVRPTW):

Travel time: Traveling from one location to another takes time.

Customer service duration: a vehicle must stay at the customer for the length of the service duration.

Customer ready time: a vehicle may arrive before the customer’s ready time, but it must wait until the ready time before servicing.

Customer due time: a vehicle must arrive on time, before the customer’s due time.

Soft constraints:

Total distance: minimize the total distance driven (fuel consumption) of all vehicles.
The capacitated vehicle routing problem (CVRP) and its timewindowed variant (CVRPTW) are defined by the VRP web.
Problem size
CVRP instances (without time windows):
belgiumn50k10 has 1 depots, 10 vehicles and 49 customers with a search space of 10^74.
belgiumn100k10 has 1 depots, 10 vehicles and 99 customers with a search space of 10^170.
belgiumn500k20 has 1 depots, 20 vehicles and 499 customers with a search space of 10^1168.
belgiumn1000k20 has 1 depots, 20 vehicles and 999 customers with a search space of 10^2607.
belgiumn2750k55 has 1 depots, 55 vehicles and 2749 customers with a search space of 10^8380.
belgiumroadkmn50k10 has 1 depots, 10 vehicles and 49 customers with a search space of 10^74.
belgiumroadkmn100k10 has 1 depots, 10 vehicles and 99 customers with a search space of 10^170.
belgiumroadkmn500k20 has 1 depots, 20 vehicles and 499 customers with a search space of 10^1168.
belgiumroadkmn1000k20 has 1 depots, 20 vehicles and 999 customers with a search space of 10^2607.
belgiumroadkmn2750k55 has 1 depots, 55 vehicles and 2749 customers with a search space of 10^8380.
belgiumroadtimen50k10 has 1 depots, 10 vehicles and 49 customers with a search space of 10^74.
belgiumroadtimen100k10 has 1 depots, 10 vehicles and 99 customers with a search space of 10^170.
belgiumroadtimen500k20 has 1 depots, 20 vehicles and 499 customers with a search space of 10^1168.
belgiumroadtimen1000k20 has 1 depots, 20 vehicles and 999 customers with a search space of 10^2607.
belgiumroadtimen2750k55 has 1 depots, 55 vehicles and 2749 customers with a search space of 10^8380.
belgiumd2n50k10 has 2 depots, 10 vehicles and 48 customers with a search space of 10^74.
belgiumd3n100k10 has 3 depots, 10 vehicles and 97 customers with a search space of 10^170.
belgiumd5n500k20 has 5 depots, 20 vehicles and 495 customers with a search space of 10^1168.
belgiumd8n1000k20 has 8 depots, 20 vehicles and 992 customers with a search space of 10^2607.
belgiumd10n2750k55 has 10 depots, 55 vehicles and 2740 customers with a search space of 10^8380.
An32k5 has 1 depots, 5 vehicles and 31 customers with a search space of 10^40.
An33k5 has 1 depots, 5 vehicles and 32 customers with a search space of 10^41.
An33k6 has 1 depots, 6 vehicles and 32 customers with a search space of 10^42.
An34k5 has 1 depots, 5 vehicles and 33 customers with a search space of 10^43.
An36k5 has 1 depots, 5 vehicles and 35 customers with a search space of 10^46.
An37k5 has 1 depots, 5 vehicles and 36 customers with a search space of 10^48.
An37k6 has 1 depots, 6 vehicles and 36 customers with a search space of 10^49.
An38k5 has 1 depots, 5 vehicles and 37 customers with a search space of 10^49.
An39k5 has 1 depots, 5 vehicles and 38 customers with a search space of 10^51.
An39k6 has 1 depots, 6 vehicles and 38 customers with a search space of 10^52.
An44k7 has 1 depots, 7 vehicles and 43 customers with a search space of 10^61.
An45k6 has 1 depots, 6 vehicles and 44 customers with a search space of 10^62.
An45k7 has 1 depots, 7 vehicles and 44 customers with a search space of 10^63.
An46k7 has 1 depots, 7 vehicles and 45 customers with a search space of 10^65.
An48k7 has 1 depots, 7 vehicles and 47 customers with a search space of 10^68.
An53k7 has 1 depots, 7 vehicles and 52 customers with a search space of 10^77.
An54k7 has 1 depots, 7 vehicles and 53 customers with a search space of 10^79.
An55k9 has 1 depots, 9 vehicles and 54 customers with a search space of 10^82.
An60k9 has 1 depots, 9 vehicles and 59 customers with a search space of 10^91.
An61k9 has 1 depots, 9 vehicles and 60 customers with a search space of 10^93.
An62k8 has 1 depots, 8 vehicles and 61 customers with a search space of 10^94.
An63k9 has 1 depots, 9 vehicles and 62 customers with a search space of 10^97.
An63k10 has 1 depots, 10 vehicles and 62 customers with a search space of 10^98.
An64k9 has 1 depots, 9 vehicles and 63 customers with a search space of 10^99.
An65k9 has 1 depots, 9 vehicles and 64 customers with a search space of 10^101.
An69k9 has 1 depots, 9 vehicles and 68 customers with a search space of 10^108.
An80k10 has 1 depots, 10 vehicles and 79 customers with a search space of 10^130.
Fn45k4 has 1 depots, 4 vehicles and 44 customers with a search space of 10^60.
Fn72k4 has 1 depots, 4 vehicles and 71 customers with a search space of 10^108.
Fn135k7 has 1 depots, 7 vehicles and 134 customers with a search space of 10^240.
CVRPTW instances (with time windows):
belgiumtwd2n50k10 has 2 depots, 10 vehicles and 48 customers with a search space of 10^74.
belgiumtwd3n100k10 has 3 depots, 10 vehicles and 97 customers with a search space of 10^170.
belgiumtwd5n500k20 has 5 depots, 20 vehicles and 495 customers with a search space of 10^1168.
belgiumtwd8n1000k20 has 8 depots, 20 vehicles and 992 customers with a search space of 10^2607.
belgiumtwd10n2750k55 has 10 depots, 55 vehicles and 2740 customers with a search space of 10^8380.
belgiumtwn50k10 has 1 depots, 10 vehicles and 49 customers with a search space of 10^74.
belgiumtwn100k10 has 1 depots, 10 vehicles and 99 customers with a search space of 10^170.
belgiumtwn500k20 has 1 depots, 20 vehicles and 499 customers with a search space of 10^1168.
belgiumtwn1000k20 has 1 depots, 20 vehicles and 999 customers with a search space of 10^2607.
belgiumtwn2750k55 has 1 depots, 55 vehicles and 2749 customers with a search space of 10^8380.
Solomon_025_C101 has 1 depots, 25 vehicles and 25 customers with a search space of 10^40.
Solomon_025_C201 has 1 depots, 25 vehicles and 25 customers with a search space of 10^40.
Solomon_025_R101 has 1 depots, 25 vehicles and 25 customers with a search space of 10^40.
Solomon_025_R201 has 1 depots, 25 vehicles and 25 customers with a search space of 10^40.
Solomon_025_RC101 has 1 depots, 25 vehicles and 25 customers with a search space of 10^40.
Solomon_025_RC201 has 1 depots, 25 vehicles and 25 customers with a search space of 10^40.
Solomon_100_C101 has 1 depots, 25 vehicles and 100 customers with a search space of 10^185.
Solomon_100_C201 has 1 depots, 25 vehicles and 100 customers with a search space of 10^185.
Solomon_100_R101 has 1 depots, 25 vehicles and 100 customers with a search space of 10^185.
Solomon_100_R201 has 1 depots, 25 vehicles and 100 customers with a search space of 10^185.
Solomon_100_RC101 has 1 depots, 25 vehicles and 100 customers with a search space of 10^185.
Solomon_100_RC201 has 1 depots, 25 vehicles and 100 customers with a search space of 10^185.
Homberger_0200_C1_2_1 has 1 depots, 50 vehicles and 200 customers with a search space of 10^429.
Homberger_0200_C2_2_1 has 1 depots, 50 vehicles and 200 customers with a search space of 10^429.
Homberger_0200_R1_2_1 has 1 depots, 50 vehicles and 200 customers with a search space of 10^429.
Homberger_0200_R2_2_1 has 1 depots, 50 vehicles and 200 customers with a search space of 10^429.
Homberger_0200_RC1_2_1 has 1 depots, 50 vehicles and 200 customers with a search space of 10^429.
Homberger_0200_RC2_2_1 has 1 depots, 50 vehicles and 200 customers with a search space of 10^429.
Homberger_0400_C1_4_1 has 1 depots, 100 vehicles and 400 customers with a search space of 10^978.
Homberger_0400_C2_4_1 has 1 depots, 100 vehicles and 400 customers with a search space of 10^978.
Homberger_0400_R1_4_1 has 1 depots, 100 vehicles and 400 customers with a search space of 10^978.
Homberger_0400_R2_4_1 has 1 depots, 100 vehicles and 400 customers with a search space of 10^978.
Homberger_0400_RC1_4_1 has 1 depots, 100 vehicles and 400 customers with a search space of 10^978.
Homberger_0400_RC2_4_1 has 1 depots, 100 vehicles and 400 customers with a search space of 10^978.
Homberger_0600_C1_6_1 has 1 depots, 150 vehicles and 600 customers with a search space of 10^1571.
Homberger_0600_C2_6_1 has 1 depots, 150 vehicles and 600 customers with a search space of 10^1571.
Homberger_0600_R1_6_1 has 1 depots, 150 vehicles and 600 customers with a search space of 10^1571.
Homberger_0600_R2_6_1 has 1 depots, 150 vehicles and 600 customers with a search space of 10^1571.
Homberger_0600_RC1_6_1 has 1 depots, 150 vehicles and 600 customers with a search space of 10^1571.
Homberger_0600_RC2_6_1 has 1 depots, 150 vehicles and 600 customers with a search space of 10^1571.
Homberger_0800_C1_8_1 has 1 depots, 200 vehicles and 800 customers with a search space of 10^2195.
Homberger_0800_C2_8_1 has 1 depots, 200 vehicles and 800 customers with a search space of 10^2195.
Homberger_0800_R1_8_1 has 1 depots, 200 vehicles and 800 customers with a search space of 10^2195.
Homberger_0800_R2_8_1 has 1 depots, 200 vehicles and 800 customers with a search space of 10^2195.
Homberger_0800_RC1_8_1 has 1 depots, 200 vehicles and 800 customers with a search space of 10^2195.
Homberger_0800_RC2_8_1 has 1 depots, 200 vehicles and 800 customers with a search space of 10^2195.
Homberger_1000_C110_1 has 1 depots, 250 vehicles and 1000 customers with a search space of 10^2840.
Homberger_1000_C210_1 has 1 depots, 250 vehicles and 1000 customers with a search space of 10^2840.
Homberger_1000_R110_1 has 1 depots, 250 vehicles and 1000 customers with a search space of 10^2840.
Homberger_1000_R210_1 has 1 depots, 250 vehicles and 1000 customers with a search space of 10^2840.
Homberger_1000_RC110_1 has 1 depots, 250 vehicles and 1000 customers with a search space of 10^2840.
Homberger_1000_RC210_1 has 1 depots, 250 vehicles and 1000 customers with a search space of 10^2840.
Domain model
The vehicle routing with timewindows domain model makes heavily use of shadow variables.
This allows it to express its constraints more naturally, because properties such as arrivalTime
and departureTime
, are directly available on the domain model.
Road distances instead of air distances
In the real world, vehicles cannot follow a straight line from location to location: they have to use roads and highways. From a business point of view, this matters a lot:
For the optimization algorithm, this does not matter much, as long as the distance between two points can be looked up (and are preferably precalculated). The road cost does not even need to be a distance, it can also be travel time, fuel cost, or a weighted function of those. There are several technologies available to precalculate road costs, such as GraphHopper (embeddable, offline Java engine), Open MapQuest (web service) and Google Maps Client API (web service).
There are also several technologies to render it, such as Leaflet and Google Maps for developers:
It is even possible to render the actual road routes with GraphHopper or Google Map Directions, but because of route overlaps on highways, it can become harder to see the standstill order:
Take special care that the road costs between two points use the same optimization criteria as the one used in Timefold Solver. For example, GraphHopper etc will by default return the fastest route, not the shortest route. Don’t use the km (or miles) distances of the fastest GPS routes to optimize the shortest trip in Timefold Solver; this leads to a suboptimal solution as shown below:
Contrary to popular belief, most users do not want the shortest route: they want the fastest route instead. They prefer highways over normal roads. They prefer normal roads over dirt roads. In the real world, the fastest and shortest route are rarely the same.