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: 14 customers
- Kassel-Wilhelmshöhe (80 vol.)
- Düsseldorf Hbf (35 vol.)
- Frankfurt Hbf (35 vol.)
- Hannover Hbf (75 vol.)
- Aachen Hbf (60 vol.)
- Bremen Hbf (100 vol.)
- Leipzig Hbf (95 vol.)
- Karlsruhe Hbf (95 vol.)
- Köln Hbf (95 vol.)
- Kiel Hbf (30 vol.)
- Mainz Hbf (95 vol.)
- Saarbrücken Hbf (45 vol.)
- Osnabrück Hbf (85 vol.)
- Freiburg Hbf (45 vol.)
Tour 1
COST: 1462.865 km
LOAD: 285 vol.
- Mainz Hbf | 95 vol.
- Köln Hbf | 95 vol.
- Aachen Hbf | 60 vol.
- Düsseldorf Hbf | 35 vol.
Tour 2
COST: 1125.936 km
LOAD: 300 vol.
- Leipzig Hbf | 95 vol.
- Hannover Hbf | 75 vol.
- Bremen Hbf | 100 vol.
- Kiel Hbf | 30 vol.
Tour 3
COST: 1792.893 km
LOAD: 300 vol.
- Kassel-Wilhelmshöhe | 80 vol.
- Frankfurt Hbf | 35 vol.
- Karlsruhe Hbf | 95 vol.
- Freiburg Hbf | 45 vol.
- Saarbrücken Hbf | 45 vol.
Tour 4
COST: 836.5 km
LOAD: 85 vol.
- Osnabrück Hbf | 85 vol.
LOAD: 285 vol.
- Mainz Hbf | 95 vol.
- Köln Hbf | 95 vol.
- Aachen Hbf | 60 vol.
- Düsseldorf Hbf | 35 vol.
LOAD: 300 vol.
- Leipzig Hbf | 95 vol.
- Hannover Hbf | 75 vol.
- Bremen Hbf | 100 vol.
- Kiel Hbf | 30 vol.
LOAD: 300 vol.
- Kassel-Wilhelmshöhe | 80 vol.
- Frankfurt Hbf | 35 vol.
- Karlsruhe Hbf | 95 vol.
- Freiburg Hbf | 45 vol.
- Saarbrücken Hbf | 45 vol.
LOAD: 85 vol.
- Osnabrück Hbf | 85 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: 970 vol. | Vehicle capacity: 300 vol. Loads: [80, 0, 35, 35, 75, 60, 0, 0, 0, 0, 100, 95, 0, 0, 95, 0, 95, 0, 30, 95, 0, 45, 85, 45] ITERATION Generation: #1 Best cost: 5709.658 | Path: [1, 0, 4, 10, 18, 1, 11, 3, 19, 21, 1, 22, 2, 16, 5, 1, 23, 14, 1] Best cost: 5679.544 | Path: [1, 0, 19, 3, 21, 23, 1, 11, 4, 10, 18, 1, 22, 2, 16, 5, 1, 14, 1] Best cost: 5613.776 | Path: [1, 5, 16, 2, 22, 1, 11, 4, 10, 18, 1, 0, 3, 19, 21, 23, 1, 14, 1] Best cost: 5257.181 | Path: [1, 16, 2, 5, 19, 1, 11, 4, 10, 18, 1, 0, 3, 14, 23, 21, 1, 22, 1] Generation: #2 Best cost: 5237.656 | Path: [1, 2, 16, 5, 19, 1, 11, 4, 10, 18, 1, 0, 3, 14, 23, 21, 1, 22, 1] OPTIMIZING each tour... Current: [[1, 2, 16, 5, 19, 1], [1, 11, 4, 10, 18, 1], [1, 0, 3, 14, 23, 21, 1], [1, 22, 1]] [1] Cost: 1482.327 to 1462.865 | Optimized: [1, 19, 16, 5, 2, 1] ACO RESULTS [1/285 vol./1462.865 km] Berlin Hbf -> Mainz Hbf -> Köln Hbf -> Aachen Hbf -> Düsseldorf Hbf --> Berlin Hbf [2/300 vol./1125.936 km] Berlin Hbf -> Leipzig Hbf -> Hannover Hbf -> Bremen Hbf -> Kiel Hbf --> Berlin Hbf [3/300 vol./1792.893 km] Berlin Hbf -> Kassel-Wilhelmshöhe -> Frankfurt Hbf -> Karlsruhe Hbf -> Freiburg Hbf -> Saarbrücken Hbf --> Berlin Hbf [4/ 85 vol./ 836.500 km] Berlin Hbf -> Osnabrück Hbf --> Berlin Hbf OPTIMIZATION RESULT: 4 tours | 5218.194 km.