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 (25 vol.)
- Düsseldorf Hbf (90 vol.)
- Frankfurt Hbf (95 vol.)
- Aachen Hbf (20 vol.)
- Stuttgart Hbf (75 vol.)
- Hamburg Hbf (50 vol.)
- München Hbf (95 vol.)
- Bremen Hbf (30 vol.)
- Leipzig Hbf (70 vol.)
- Dortmund Hbf (50 vol.)
- Köln Hbf (70 vol.)
- Mannheim Hbf (75 vol.)
- Kiel Hbf (90 vol.)
- Mainz Hbf (50 vol.)
- Osnabrück Hbf (75 vol.)
Tour 1
COST: 1422.901 km
LOAD: 300 vol.
- Dortmund Hbf | 50 vol.
- Düsseldorf Hbf | 90 vol.
- Köln Hbf | 70 vol.
- Aachen Hbf | 20 vol.
- Leipzig Hbf | 70 vol.
Tour 2
COST: 1256.055 km
LOAD: 270 vol.
- Kassel-Wilhelmshöhe | 25 vol.
- Osnabrück Hbf | 75 vol.
- Bremen Hbf | 30 vol.
- Hamburg Hbf | 50 vol.
- Kiel Hbf | 90 vol.
Tour 3
COST: 1430.8 km
LOAD: 295 vol.
- Stuttgart Hbf | 75 vol.
- Mannheim Hbf | 75 vol.
- Mainz Hbf | 50 vol.
- Frankfurt Hbf | 95 vol.
Tour 4
COST: 1170.132 km
LOAD: 95 vol.
- München Hbf | 95 vol.
LOAD: 300 vol.
- Dortmund Hbf | 50 vol.
- Düsseldorf Hbf | 90 vol.
- Köln Hbf | 70 vol.
- Aachen Hbf | 20 vol.
- Leipzig Hbf | 70 vol.
LOAD: 270 vol.
- Kassel-Wilhelmshöhe | 25 vol.
- Osnabrück Hbf | 75 vol.
- Bremen Hbf | 30 vol.
- Hamburg Hbf | 50 vol.
- Kiel Hbf | 90 vol.
LOAD: 295 vol.
- Stuttgart Hbf | 75 vol.
- Mannheim Hbf | 75 vol.
- Mainz Hbf | 50 vol.
- Frankfurt Hbf | 95 vol.
LOAD: 95 vol.
- München 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: 960 vol. | Vehicle capacity: 300 vol. Loads: [25, 0, 90, 95, 0, 20, 75, 0, 50, 95, 30, 70, 50, 0, 0, 0, 70, 75, 90, 50, 0, 0, 75, 0] ITERATION Generation: #1 Best cost: 5566.619 | Path: [1, 0, 3, 19, 17, 5, 10, 1, 11, 9, 6, 12, 1, 22, 16, 2, 8, 1, 18, 1] Best cost: 5534.514 | Path: [1, 5, 16, 2, 12, 0, 10, 1, 11, 22, 8, 18, 1, 3, 19, 17, 6, 1, 9, 1] Best cost: 5395.161 | Path: [1, 8, 18, 10, 22, 12, 1, 11, 0, 2, 16, 5, 1, 19, 3, 17, 6, 1, 9, 1] Best cost: 5364.565 | Path: [1, 8, 18, 10, 22, 12, 1, 11, 0, 2, 16, 5, 1, 6, 17, 19, 3, 1, 9, 1] Best cost: 5316.017 | Path: [1, 11, 12, 2, 16, 5, 1, 8, 18, 10, 22, 0, 1, 3, 19, 17, 6, 1, 9, 1] OPTIMIZING each tour... Current: [[1, 11, 12, 2, 16, 5, 1], [1, 8, 18, 10, 22, 0, 1], [1, 3, 19, 17, 6, 1], [1, 9, 1]] [1] Cost: 1425.199 to 1422.901 | Optimized: [1, 12, 2, 16, 5, 11, 1] [2] Cost: 1281.716 to 1256.055 | Optimized: [1, 0, 22, 10, 8, 18, 1] [3] Cost: 1438.970 to 1430.800 | Optimized: [1, 6, 17, 19, 3, 1] ACO RESULTS [1/300 vol./1422.901 km] Berlin Hbf -> Dortmund Hbf -> Düsseldorf Hbf -> Köln Hbf -> Aachen Hbf -> Leipzig Hbf --> Berlin Hbf [2/270 vol./1256.055 km] Berlin Hbf -> Kassel-Wilhelmshöhe -> Osnabrück Hbf -> Bremen Hbf -> Hamburg Hbf -> Kiel Hbf --> Berlin Hbf [3/295 vol./1430.800 km] Berlin Hbf -> Stuttgart Hbf -> Mannheim Hbf -> Mainz Hbf -> Frankfurt Hbf --> Berlin Hbf [4/ 95 vol./1170.132 km] Berlin Hbf -> München Hbf --> Berlin Hbf OPTIMIZATION RESULT: 4 tours | 5279.888 km.