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: 300 vol.
ACTIVE: 15 customers
- Kassel-Wilhelmshöhe (35 vol.)
- Frankfurt Hbf (55 vol.)
- Hannover Hbf (85 vol.)
- Aachen Hbf (80 vol.)
- Stuttgart Hbf (60 vol.)
- München Hbf (60 vol.)
- Leipzig Hbf (55 vol.)
- Dortmund Hbf (30 vol.)
- Karlsruhe Hbf (20 vol.)
- Mannheim Hbf (35 vol.)
- Kiel Hbf (70 vol.)
- Mainz Hbf (80 vol.)
- Saarbrücken Hbf (55 vol.)
- Osnabrück Hbf (90 vol.)
- Freiburg Hbf (20 vol.)
Tour 1
COST: 1492.512 km
LOAD: 285 vol.
- Kassel-Wilhelmshöhe | 35 vol.
- Frankfurt Hbf | 55 vol.
- Mainz Hbf | 80 vol.
- Mannheim Hbf | 35 vol.
- Karlsruhe Hbf | 20 vol.
- Stuttgart Hbf | 60 vol.
Tour 2
COST: 2140.436 km
LOAD: 300 vol.
- Leipzig Hbf | 55 vol.
- München Hbf | 60 vol.
- Freiburg Hbf | 20 vol.
- Saarbrücken Hbf | 55 vol.
- Aachen Hbf | 80 vol.
- Dortmund Hbf | 30 vol.
Tour 3
COST: 1090.231 km
LOAD: 245 vol.
- Hannover Hbf | 85 vol.
- Osnabrück Hbf | 90 vol.
- Kiel Hbf | 70 vol.
LOAD: 285 vol.
- Kassel-Wilhelmshöhe | 35 vol.
- Frankfurt Hbf | 55 vol.
- Mainz Hbf | 80 vol.
- Mannheim Hbf | 35 vol.
- Karlsruhe Hbf | 20 vol.
- Stuttgart Hbf | 60 vol.
LOAD: 300 vol.
- Leipzig Hbf | 55 vol.
- München Hbf | 60 vol.
- Freiburg Hbf | 20 vol.
- Saarbrücken Hbf | 55 vol.
- Aachen Hbf | 80 vol.
- Dortmund Hbf | 30 vol.
LOAD: 245 vol.
- Hannover Hbf | 85 vol.
- Osnabrück Hbf | 90 vol.
- Kiel Hbf | 70 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: [1] Berlin Hbf | Number of cities: 24 | Total loads: 830 vol. | Vehicle capacity: 300 vol. Loads: [35, 0, 0, 55, 85, 80, 60, 0, 0, 60, 0, 55, 30, 0, 20, 0, 0, 35, 70, 80, 0, 55, 90, 20] ITERATION Generation: #1 Best cost: 6065.078 | Path: [1, 0, 12, 22, 4, 11, 1, 18, 17, 14, 6, 3, 21, 1, 9, 19, 5, 23, 1] Best cost: 5363.202 | Path: [1, 3, 19, 17, 14, 6, 23, 12, 1, 11, 4, 22, 0, 1, 18, 5, 21, 9, 1] Best cost: 5300.228 | Path: [1, 5, 12, 22, 4, 1, 11, 0, 19, 3, 17, 14, 23, 1, 18, 21, 6, 9, 1] Best cost: 4725.536 | Path: [1, 6, 14, 17, 19, 3, 0, 1, 11, 9, 23, 21, 5, 12, 1, 4, 22, 18, 1] OPTIMIZING each tour... Current: [[1, 6, 14, 17, 19, 3, 0, 1], [1, 11, 9, 23, 21, 5, 12, 1], [1, 4, 22, 18, 1]] [1] Cost: 1494.869 to 1492.512 | Optimized: [1, 0, 3, 19, 17, 14, 6, 1] ACO RESULTS [1/285 vol./1492.512 km] Berlin Hbf -> Kassel-Wilhelmshöhe -> Frankfurt Hbf -> Mainz Hbf -> Mannheim Hbf -> Karlsruhe Hbf -> Stuttgart Hbf --> Berlin Hbf [2/300 vol./2140.436 km] Berlin Hbf -> Leipzig Hbf -> München Hbf -> Freiburg Hbf -> Saarbrücken Hbf -> Aachen Hbf -> Dortmund Hbf --> Berlin Hbf [3/245 vol./1090.231 km] Berlin Hbf -> Hannover Hbf -> Osnabrück Hbf -> Kiel Hbf --> Berlin Hbf OPTIMIZATION RESULT: 3 tours | 4723.179 km.