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: 16 customers
- Kassel-Wilhelmshöhe (55 vol.)
- Düsseldorf Hbf (70 vol.)
- Frankfurt Hbf (70 vol.)
- Aachen Hbf (35 vol.)
- Stuttgart Hbf (95 vol.)
- Dresden Hbf (60 vol.)
- München Hbf (50 vol.)
- Bremen Hbf (95 vol.)
- Dortmund Hbf (35 vol.)
- Karlsruhe Hbf (100 vol.)
- Köln Hbf (60 vol.)
- Mannheim Hbf (40 vol.)
- Kiel Hbf (20 vol.)
- Mainz Hbf (40 vol.)
- Saarbrücken Hbf (45 vol.)
- Osnabrück Hbf (70 vol.)
Tour 1
COST: 1606.399 km
LOAD: 290 vol.
- Dortmund Hbf | 35 vol.
- Düsseldorf Hbf | 70 vol.
- Köln Hbf | 60 vol.
- Aachen Hbf | 35 vol.
- Osnabrück Hbf | 70 vol.
- Kiel Hbf | 20 vol.
Tour 2
COST: 1667.568 km
LOAD: 285 vol.
- Dresden Hbf | 60 vol.
- München Hbf | 50 vol.
- Stuttgart Hbf | 95 vol.
- Mannheim Hbf | 40 vol.
- Mainz Hbf | 40 vol.
Tour 3
COST: 1597.943 km
LOAD: 270 vol.
- Kassel-Wilhelmshöhe | 55 vol.
- Frankfurt Hbf | 70 vol.
- Karlsruhe Hbf | 100 vol.
- Saarbrücken Hbf | 45 vol.
Tour 4
COST: 781.807 km
LOAD: 95 vol.
- Bremen Hbf | 95 vol.
LOAD: 290 vol.
- Dortmund Hbf | 35 vol.
- Düsseldorf Hbf | 70 vol.
- Köln Hbf | 60 vol.
- Aachen Hbf | 35 vol.
- Osnabrück Hbf | 70 vol.
- Kiel Hbf | 20 vol.
LOAD: 285 vol.
- Dresden Hbf | 60 vol.
- München Hbf | 50 vol.
- Stuttgart Hbf | 95 vol.
- Mannheim Hbf | 40 vol.
- Mainz Hbf | 40 vol.
LOAD: 270 vol.
- Kassel-Wilhelmshöhe | 55 vol.
- Frankfurt Hbf | 70 vol.
- Karlsruhe Hbf | 100 vol.
- Saarbrücken Hbf | 45 vol.
LOAD: 95 vol.
- Bremen Hbf | 95 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: 940 vol. | Vehicle capacity: 300 vol. Loads: [55, 0, 70, 70, 0, 35, 95, 60, 0, 50, 95, 0, 35, 0, 100, 0, 60, 40, 20, 40, 0, 45, 70, 0] ITERATION Generation: #1 Best cost: 6480.972 | Path: [1, 0, 12, 2, 16, 5, 21, 1, 7, 14, 17, 3, 18, 1, 10, 22, 19, 6, 1, 9, 1] Best cost: 5678.307 | Path: [1, 2, 16, 5, 12, 22, 18, 1, 7, 6, 14, 17, 1, 0, 3, 19, 21, 9, 1, 10, 1] Best cost: 5676.207 | Path: [1, 5, 16, 2, 12, 22, 18, 1, 7, 19, 3, 17, 21, 1, 0, 14, 6, 9, 1, 10, 1] Best cost: 5656.290 | Path: [1, 5, 16, 2, 12, 22, 18, 1, 7, 9, 6, 17, 19, 1, 0, 3, 14, 21, 1, 10, 1] OPTIMIZING each tour... Current: [[1, 5, 16, 2, 12, 22, 18, 1], [1, 7, 9, 6, 17, 19, 1], [1, 0, 3, 14, 21, 1], [1, 10, 1]] [1] Cost: 1608.972 to 1606.399 | Optimized: [1, 12, 2, 16, 5, 22, 18, 1] ACO RESULTS [1/290 vol./1606.399 km] Berlin Hbf -> Dortmund Hbf -> Düsseldorf Hbf -> Köln Hbf -> Aachen Hbf -> Osnabrück Hbf -> Kiel Hbf --> Berlin Hbf [2/285 vol./1667.568 km] Berlin Hbf -> Dresden Hbf -> München Hbf -> Stuttgart Hbf -> Mannheim Hbf -> Mainz Hbf --> Berlin Hbf [3/270 vol./1597.943 km] Berlin Hbf -> Kassel-Wilhelmshöhe -> Frankfurt Hbf -> Karlsruhe Hbf -> Saarbrücken Hbf --> Berlin Hbf [4/ 95 vol./ 781.807 km] Berlin Hbf -> Bremen Hbf --> Berlin Hbf OPTIMIZATION RESULT: 4 tours | 5653.717 km.