Solving CVRP with ACO
Minimizing Travel Cost for Complex Delivery Problems
This scenario involves the Capacitated Vehicle Routing Problem,
solved using the meta-heuristics algorithm Ant Colony Optimization. Basically, VRP is a network consisting of a number of nodes
(sometimes called cities) and arcs connecting one to all others along with the corresponding costs.
Mostly, the aim is to minimize the cost in visiting each customer once and only once. The term
"capacitated" is added due to some capacity constraints on the vehicles (vcap).
Enter the problem. Some company wants to deliver loads to a number of customers. In this case, we
have 24 nodes based on the location of Germany's train stations (don't ask why). The delivery
always starts from and ends at the depot, visiting a list of customers in other cities. And then
a number of questions arise:
- How do we minimize the travel cost in terms of distance?
- How many trucks are required?
- Which cities are visited by the truck #1, #2. etc.?
- depot: [0..23], def = 0
- vcap: [200..400], def = 400
There is a way to set all the demands, but I don't think you are ready for that. 😉
VCAP: 400 vol.
ACTIVE: 18 customers
- Berlin Hbf (80 vol.)
- Düsseldorf Hbf (90 vol.)
- Frankfurt Hbf (65 vol.)
- Hannover Hbf (30 vol.)
- Stuttgart Hbf (90 vol.)
- Dresden Hbf (25 vol.)
- Hamburg Hbf (75 vol.)
- München Hbf (45 vol.)
- Leipzig Hbf (90 vol.)
- Dortmund Hbf (60 vol.)
- Nürnberg Hbf (25 vol.)
- Karlsruhe Hbf (65 vol.)
- Köln Hbf (70 vol.)
- Mannheim Hbf (100 vol.)
- Mainz Hbf (65 vol.)
- Würzburg Hbf (75 vol.)
- Saarbrücken Hbf (90 vol.)
- Freiburg Hbf (85 vol.)
Tour 1
COST: 830.622 km
LOAD: 385 vol.
- Frankfurt Hbf | 65 vol.
- Mainz Hbf | 65 vol.
- Mannheim Hbf | 100 vol.
- Karlsruhe Hbf | 65 vol.
- Stuttgart Hbf | 90 vol.
Tour 2
COST: 1194.391 km
LOAD: 395 vol.
- Freiburg Hbf | 85 vol.
- Saarbrücken Hbf | 90 vol.
- Köln Hbf | 70 vol.
- Düsseldorf Hbf | 90 vol.
- Dortmund Hbf | 60 vol.
Tour 3
COST: 1845.7 km
LOAD: 370 vol.
- Nürnberg Hbf | 25 vol.
- München Hbf | 45 vol.
- Leipzig Hbf | 90 vol.
- Dresden Hbf | 25 vol.
- Berlin Hbf | 80 vol.
- Hamburg Hbf | 75 vol.
- Hannover Hbf | 30 vol.
Tour 4
COST: 427.695 km
LOAD: 75 vol.
- Würzburg Hbf | 75 vol.
LOAD: 385 vol.
- Frankfurt Hbf | 65 vol.
- Mainz Hbf | 65 vol.
- Mannheim Hbf | 100 vol.
- Karlsruhe Hbf | 65 vol.
- Stuttgart Hbf | 90 vol.
LOAD: 395 vol.
- Freiburg Hbf | 85 vol.
- Saarbrücken Hbf | 90 vol.
- Köln Hbf | 70 vol.
- Düsseldorf Hbf | 90 vol.
- Dortmund Hbf | 60 vol.
LOAD: 370 vol.
- Nürnberg Hbf | 25 vol.
- München Hbf | 45 vol.
- Leipzig Hbf | 90 vol.
- Dresden Hbf | 25 vol.
- Berlin Hbf | 80 vol.
- Hamburg Hbf | 75 vol.
- Hannover Hbf | 30 vol.
LOAD: 75 vol.
- Würzburg Hbf | 75 vol.
#generations: 10 for global, 5 for local
#ants: 5 times #active_customers
ACO
Rel. importance of pheromones α = 1.0
Rel. importance of visibility β = 10.0
Trail persistance ρ = 0.5
Pheromone intensity Q = 10
See this wikipedia page to learn more.
NETWORK Depo: [0] Kassel-Wilhelmshöhe | Number of cities: 24 | Total loads: 1225 vol. | Vehicle capacity: 400 vol. Loads: [0, 80, 90, 65, 30, 0, 90, 25, 75, 45, 0, 90, 60, 25, 65, 0, 70, 100, 0, 65, 75, 90, 0, 85] ITERATION Generation: #1 Best cost: 4867.929 | Path: [0, 1, 11, 7, 13, 20, 3, 4, 0, 12, 2, 16, 19, 17, 0, 14, 6, 9, 23, 21, 0, 8, 0] Best cost: 4534.761 | Path: [0, 6, 14, 17, 19, 3, 0, 12, 2, 16, 21, 23, 0, 4, 8, 1, 7, 11, 13, 20, 0, 9, 0] Best cost: 4533.912 | Path: [0, 3, 19, 17, 14, 6, 0, 12, 2, 16, 21, 23, 0, 4, 8, 1, 7, 11, 13, 20, 0, 9, 0] Best cost: 4437.900 | Path: [0, 6, 14, 17, 3, 19, 0, 20, 13, 9, 7, 11, 1, 4, 0, 12, 2, 16, 21, 23, 0, 8, 0] Best cost: 4384.130 | Path: [0, 6, 14, 17, 19, 3, 0, 12, 2, 16, 21, 23, 0, 20, 13, 9, 11, 7, 1, 4, 0, 8, 0] Best cost: 4343.154 | Path: [0, 19, 3, 17, 14, 6, 0, 4, 8, 1, 7, 11, 13, 9, 0, 12, 2, 16, 21, 23, 0, 20, 0] Generation: #4 Best cost: 4331.026 | Path: [0, 3, 19, 17, 14, 6, 0, 12, 2, 16, 21, 23, 0, 4, 8, 1, 11, 7, 9, 13, 0, 20, 0] OPTIMIZING each tour... Current: [[0, 3, 19, 17, 14, 6, 0], [0, 12, 2, 16, 21, 23, 0], [0, 4, 8, 1, 11, 7, 9, 13, 0], [0, 20, 0]] [2] Cost: 1199.090 to 1194.391 | Optimized: [0, 23, 21, 16, 2, 12, 0] [3] Cost: 1873.619 to 1845.700 | Optimized: [0, 13, 9, 11, 7, 1, 8, 4, 0] ACO RESULTS [1/385 vol./ 830.622 km] Kassel-Wilhelmshöhe -> Frankfurt Hbf -> Mainz Hbf -> Mannheim Hbf -> Karlsruhe Hbf -> Stuttgart Hbf --> Kassel-Wilhelmshöhe [2/395 vol./1194.391 km] Kassel-Wilhelmshöhe -> Freiburg Hbf -> Saarbrücken Hbf -> Köln Hbf -> Düsseldorf Hbf -> Dortmund Hbf --> Kassel-Wilhelmshöhe [3/370 vol./1845.700 km] Kassel-Wilhelmshöhe -> Nürnberg Hbf -> München Hbf -> Leipzig Hbf -> Dresden Hbf -> Berlin Hbf -> Hamburg Hbf -> Hannover Hbf --> Kassel-Wilhelmshöhe [4/ 75 vol./ 427.695 km] Kassel-Wilhelmshöhe -> Würzburg Hbf --> Kassel-Wilhelmshöhe OPTIMIZATION RESULT: 4 tours | 4298.408 km.