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: 14 customers
- Berlin Hbf (55 vol.)
- Düsseldorf Hbf (50 vol.)
- Frankfurt Hbf (55 vol.)
- Dresden Hbf (85 vol.)
- München Hbf (45 vol.)
- Bremen Hbf (30 vol.)
- Nürnberg Hbf (55 vol.)
- Karlsruhe Hbf (60 vol.)
- Ulm Hbf (40 vol.)
- Köln Hbf (65 vol.)
- Kiel Hbf (50 vol.)
- Saarbrücken Hbf (55 vol.)
- Osnabrück Hbf (80 vol.)
- Freiburg Hbf (70 vol.)
Tour 1
COST: 2005.567 km
LOAD: 400 vol.
- Nürnberg Hbf | 55 vol.
- München Hbf | 45 vol.
- Dresden Hbf | 85 vol.
- Berlin Hbf | 55 vol.
- Kiel Hbf | 50 vol.
- Bremen Hbf | 30 vol.
- Osnabrück Hbf | 80 vol.
Tour 2
COST: 1501.652 km
LOAD: 395 vol.
- Frankfurt Hbf | 55 vol.
- Karlsruhe Hbf | 60 vol.
- Ulm Hbf | 40 vol.
- Freiburg Hbf | 70 vol.
- Saarbrücken Hbf | 55 vol.
- Köln Hbf | 65 vol.
- Düsseldorf Hbf | 50 vol.
LOAD: 400 vol.
- Nürnberg Hbf | 55 vol.
- München Hbf | 45 vol.
- Dresden Hbf | 85 vol.
- Berlin Hbf | 55 vol.
- Kiel Hbf | 50 vol.
- Bremen Hbf | 30 vol.
- Osnabrück Hbf | 80 vol.
LOAD: 395 vol.
- Frankfurt Hbf | 55 vol.
- Karlsruhe Hbf | 60 vol.
- Ulm Hbf | 40 vol.
- Freiburg Hbf | 70 vol.
- Saarbrücken Hbf | 55 vol.
- Köln Hbf | 65 vol.
- Düsseldorf Hbf | 50 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: 795 vol. | Vehicle capacity: 400 vol. Loads: [0, 55, 50, 55, 0, 0, 0, 85, 0, 45, 30, 0, 0, 55, 60, 40, 65, 0, 50, 0, 0, 55, 80, 70] ITERATION Generation: #1 Best cost: 3716.468 | Path: [0, 1, 7, 13, 9, 15, 14, 3, 0, 22, 10, 18, 16, 2, 21, 23, 0] Best cost: 3648.817 | Path: [0, 2, 16, 3, 14, 23, 21, 15, 0, 22, 10, 18, 1, 7, 13, 9, 0] Best cost: 3647.977 | Path: [0, 2, 16, 3, 14, 21, 23, 15, 0, 22, 10, 18, 1, 7, 13, 9, 0] Best cost: 3556.712 | Path: [0, 15, 14, 23, 21, 3, 16, 2, 0, 22, 10, 18, 1, 7, 13, 9, 0] Generation: #6 Best cost: 3519.944 | Path: [0, 22, 10, 18, 1, 7, 13, 9, 0, 3, 14, 15, 23, 21, 16, 2, 0] OPTIMIZING each tour... Current: [[0, 22, 10, 18, 1, 7, 13, 9, 0], [0, 3, 14, 15, 23, 21, 16, 2, 0]] [1] Cost: 2018.292 to 2005.567 | Optimized: [0, 13, 9, 7, 1, 18, 10, 22, 0] ACO RESULTS [1/400 vol./2005.567 km] Kassel-Wilhelmshöhe -> Nürnberg Hbf -> München Hbf -> Dresden Hbf -> Berlin Hbf -> Kiel Hbf -> Bremen Hbf -> Osnabrück Hbf --> Kassel-Wilhelmshöhe [2/395 vol./1501.652 km] Kassel-Wilhelmshöhe -> Frankfurt Hbf -> Karlsruhe Hbf -> Ulm Hbf -> Freiburg Hbf -> Saarbrücken Hbf -> Köln Hbf -> Düsseldorf Hbf --> Kassel-Wilhelmshöhe OPTIMIZATION RESULT: 2 tours | 3507.219 km.