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 (65 vol.)
- Aachen Hbf (25 vol.)
- Stuttgart Hbf (20 vol.)
- Dresden Hbf (95 vol.)
- Hamburg Hbf (40 vol.)
- Bremen Hbf (30 vol.)
- Leipzig Hbf (35 vol.)
- Dortmund Hbf (95 vol.)
- Karlsruhe Hbf (50 vol.)
- Ulm Hbf (25 vol.)
- Köln Hbf (35 vol.)
- Kiel Hbf (95 vol.)
- Mainz Hbf (100 vol.)
- Saarbrücken Hbf (85 vol.)
- Osnabrück Hbf (95 vol.)
Tour 1
COST: 1485.248 km
LOAD: 295 vol.
- Kiel Hbf | 95 vol.
- Hamburg Hbf | 40 vol.
- Bremen Hbf | 30 vol.
- Osnabrück Hbf | 95 vol.
- Köln Hbf | 35 vol.
Tour 2
COST: 1351.973 km
LOAD: 295 vol.
- Kassel-Wilhelmshöhe | 65 vol.
- Mainz Hbf | 100 vol.
- Leipzig Hbf | 35 vol.
- Dresden Hbf | 95 vol.
Tour 3
COST: 1842.12 km
LOAD: 300 vol.
- Dortmund Hbf | 95 vol.
- Aachen Hbf | 25 vol.
- Saarbrücken Hbf | 85 vol.
- Karlsruhe Hbf | 50 vol.
- Stuttgart Hbf | 20 vol.
- Ulm Hbf | 25 vol.
LOAD: 295 vol.
- Kiel Hbf | 95 vol.
- Hamburg Hbf | 40 vol.
- Bremen Hbf | 30 vol.
- Osnabrück Hbf | 95 vol.
- Köln Hbf | 35 vol.
LOAD: 295 vol.
- Kassel-Wilhelmshöhe | 65 vol.
- Mainz Hbf | 100 vol.
- Leipzig Hbf | 35 vol.
- Dresden Hbf | 95 vol.
LOAD: 300 vol.
- Dortmund Hbf | 95 vol.
- Aachen Hbf | 25 vol.
- Saarbrücken Hbf | 85 vol.
- Karlsruhe Hbf | 50 vol.
- Stuttgart Hbf | 20 vol.
- Ulm Hbf | 25 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: 890 vol. | Vehicle capacity: 300 vol. Loads: [65, 0, 0, 0, 0, 25, 20, 95, 40, 0, 30, 35, 95, 0, 50, 25, 35, 0, 95, 100, 0, 85, 95, 0] ITERATION Generation: #1 Best cost: 7677.924 | Path: [1, 0, 22, 10, 8, 11, 15, 1, 7, 18, 16, 5, 6, 1, 12, 14, 19, 1, 21, 1] Best cost: 6265.206 | Path: [1, 5, 16, 12, 22, 10, 6, 1, 11, 7, 8, 18, 15, 1, 0, 19, 14, 21, 1] Best cost: 5741.930 | Path: [1, 6, 14, 15, 21, 19, 1, 11, 7, 8, 10, 22, 1, 18, 12, 16, 5, 1, 0, 1] Best cost: 5657.133 | Path: [1, 7, 11, 0, 12, 1, 8, 18, 10, 22, 16, 1, 15, 6, 14, 21, 19, 1, 5, 1] Best cost: 5063.012 | Path: [1, 12, 16, 5, 19, 6, 15, 1, 11, 7, 0, 22, 1, 8, 18, 10, 21, 14, 1] Best cost: 5037.504 | Path: [1, 15, 6, 14, 21, 19, 1, 7, 11, 10, 22, 8, 1, 0, 12, 16, 5, 1, 18, 1] Best cost: 5020.995 | Path: [1, 18, 8, 10, 22, 16, 1, 11, 7, 19, 14, 6, 1, 0, 12, 5, 21, 15, 1] Best cost: 4923.699 | Path: [1, 8, 10, 22, 12, 16, 1, 11, 7, 0, 19, 1, 18, 5, 21, 14, 6, 15, 1] Best cost: 4828.687 | Path: [1, 7, 11, 0, 19, 1, 8, 10, 22, 12, 16, 1, 18, 5, 21, 14, 6, 15, 1] Best cost: 4707.264 | Path: [1, 18, 8, 10, 22, 16, 1, 7, 11, 0, 19, 1, 12, 5, 21, 14, 6, 15, 1] OPTIMIZING each tour... Current: [[1, 18, 8, 10, 22, 16, 1], [1, 7, 11, 0, 19, 1], [1, 12, 5, 21, 14, 6, 15, 1]] [2] Cost: 1379.896 to 1351.973 | Optimized: [1, 0, 19, 11, 7, 1] ACO RESULTS [1/295 vol./1485.248 km] Berlin Hbf -> Kiel Hbf -> Hamburg Hbf -> Bremen Hbf -> Osnabrück Hbf -> Köln Hbf --> Berlin Hbf [2/295 vol./1351.973 km] Berlin Hbf -> Kassel-Wilhelmshöhe -> Mainz Hbf -> Leipzig Hbf -> Dresden Hbf --> Berlin Hbf [3/300 vol./1842.120 km] Berlin Hbf -> Dortmund Hbf -> Aachen Hbf -> Saarbrücken Hbf -> Karlsruhe Hbf -> Stuttgart Hbf -> Ulm Hbf --> Berlin Hbf OPTIMIZATION RESULT: 3 tours | 4679.341 km.