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: 18 customers
- Kassel-Wilhelmshöhe (25 vol.)
- Frankfurt Hbf (80 vol.)
- Hannover Hbf (85 vol.)
- Aachen Hbf (30 vol.)
- Dresden Hbf (30 vol.)
- München Hbf (60 vol.)
- Bremen Hbf (40 vol.)
- Leipzig Hbf (65 vol.)
- Dortmund Hbf (25 vol.)
- Nürnberg Hbf (65 vol.)
- Karlsruhe Hbf (45 vol.)
- Ulm Hbf (70 vol.)
- Köln Hbf (50 vol.)
- Kiel Hbf (35 vol.)
- Mainz Hbf (45 vol.)
- Würzburg Hbf (85 vol.)
- Osnabrück Hbf (90 vol.)
- Freiburg Hbf (70 vol.)
Tour 1
COST: 1857.438 km
LOAD: 300 vol.
- München Hbf | 60 vol.
- Freiburg Hbf | 70 vol.
- Karlsruhe Hbf | 45 vol.
- Mainz Hbf | 45 vol.
- Frankfurt Hbf | 80 vol.
Tour 2
COST: 1852.894 km
LOAD: 300 vol.
- Dresden Hbf | 30 vol.
- Leipzig Hbf | 65 vol.
- Kassel-Wilhelmshöhe | 25 vol.
- Dortmund Hbf | 25 vol.
- Köln Hbf | 50 vol.
- Aachen Hbf | 30 vol.
- Bremen Hbf | 40 vol.
- Kiel Hbf | 35 vol.
Tour 3
COST: 1366.321 km
LOAD: 220 vol.
- Nürnberg Hbf | 65 vol.
- Würzburg Hbf | 85 vol.
- Ulm Hbf | 70 vol.
Tour 4
COST: 840.959 km
LOAD: 175 vol.
- Osnabrück Hbf | 90 vol.
- Hannover Hbf | 85 vol.
LOAD: 300 vol.
- München Hbf | 60 vol.
- Freiburg Hbf | 70 vol.
- Karlsruhe Hbf | 45 vol.
- Mainz Hbf | 45 vol.
- Frankfurt Hbf | 80 vol.
LOAD: 300 vol.
- Dresden Hbf | 30 vol.
- Leipzig Hbf | 65 vol.
- Kassel-Wilhelmshöhe | 25 vol.
- Dortmund Hbf | 25 vol.
- Köln Hbf | 50 vol.
- Aachen Hbf | 30 vol.
- Bremen Hbf | 40 vol.
- Kiel Hbf | 35 vol.
LOAD: 220 vol.
- Nürnberg Hbf | 65 vol.
- Würzburg Hbf | 85 vol.
- Ulm Hbf | 70 vol.
LOAD: 175 vol.
- Osnabrück Hbf | 90 vol.
- Hannover 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: 995 vol. | Vehicle capacity: 300 vol. Loads: [25, 0, 0, 80, 85, 30, 0, 30, 0, 60, 40, 65, 25, 65, 45, 70, 50, 0, 35, 45, 85, 0, 90, 70] ITERATION Generation: #1 Best cost: 6641.719 | Path: [1, 0, 4, 10, 22, 12, 5, 1, 7, 11, 13, 20, 19, 1, 18, 16, 3, 14, 23, 1, 9, 15, 1] Best cost: 6332.889 | Path: [1, 4, 10, 22, 16, 5, 1, 11, 7, 20, 3, 12, 1, 18, 0, 19, 14, 23, 15, 1, 13, 9, 1] Best cost: 6203.469 | Path: [1, 18, 10, 22, 12, 16, 5, 0, 1, 11, 7, 13, 20, 19, 1, 4, 3, 14, 23, 1, 15, 9, 1] Best cost: 6113.893 | Path: [1, 9, 15, 14, 3, 19, 1, 7, 11, 0, 4, 10, 18, 1, 22, 12, 16, 5, 23, 1, 13, 20, 1] Best cost: 5948.670 | Path: [1, 19, 3, 14, 23, 9, 1, 7, 11, 0, 12, 16, 5, 10, 18, 1, 13, 20, 15, 1, 4, 22, 1] OPTIMIZING each tour... Current: [[1, 19, 3, 14, 23, 9, 1], [1, 7, 11, 0, 12, 16, 5, 10, 18, 1], [1, 13, 20, 15, 1], [1, 4, 22, 1]] [1] Cost: 1886.951 to 1857.438 | Optimized: [1, 9, 23, 14, 19, 3, 1] [4] Cost: 842.504 to 840.959 | Optimized: [1, 22, 4, 1] ACO RESULTS [1/300 vol./1857.438 km] Berlin Hbf -> München Hbf -> Freiburg Hbf -> Karlsruhe Hbf -> Mainz Hbf -> Frankfurt Hbf --> Berlin Hbf [2/300 vol./1852.894 km] Berlin Hbf -> Dresden Hbf -> Leipzig Hbf -> Kassel-Wilhelmshöhe -> Dortmund Hbf -> Köln Hbf -> Aachen Hbf -> Bremen Hbf -> Kiel Hbf --> Berlin Hbf [3/220 vol./1366.321 km] Berlin Hbf -> Nürnberg Hbf -> Würzburg Hbf -> Ulm Hbf --> Berlin Hbf [4/175 vol./ 840.959 km] Berlin Hbf -> Osnabrück Hbf -> Hannover Hbf --> Berlin Hbf OPTIMIZATION RESULT: 4 tours | 5917.612 km.