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 (65 vol.)
- Frankfurt Hbf (30 vol.)
- Hannover Hbf (80 vol.)
- Aachen Hbf (65 vol.)
- Stuttgart Hbf (95 vol.)
- Dresden Hbf (35 vol.)
- Hamburg Hbf (45 vol.)
- Dortmund Hbf (30 vol.)
- Nürnberg Hbf (65 vol.)
- Mannheim Hbf (65 vol.)
- Mainz Hbf (35 vol.)
- Würzburg Hbf (65 vol.)
- Osnabrück Hbf (90 vol.)
- Freiburg Hbf (65 vol.)
Tour 1
COST: 1594.663 km
LOAD: 290 vol.
- Dortmund Hbf | 30 vol.
- Düsseldorf Hbf | 65 vol.
- Aachen Hbf | 65 vol.
- Mainz Hbf | 35 vol.
- Mannheim Hbf | 65 vol.
- Frankfurt Hbf | 30 vol.
Tour 2
COST: 1316.109 km
LOAD: 275 vol.
- Dresden Hbf | 35 vol.
- Kassel-Wilhelmshöhe | 25 vol.
- Osnabrück Hbf | 90 vol.
- Hannover Hbf | 80 vol.
- Hamburg Hbf | 45 vol.
Tour 3
COST: 1648.501 km
LOAD: 290 vol.
- Würzburg Hbf | 65 vol.
- Stuttgart Hbf | 95 vol.
- Freiburg Hbf | 65 vol.
- Nürnberg Hbf | 65 vol.
LOAD: 290 vol.
- Dortmund Hbf | 30 vol.
- Düsseldorf Hbf | 65 vol.
- Aachen Hbf | 65 vol.
- Mainz Hbf | 35 vol.
- Mannheim Hbf | 65 vol.
- Frankfurt Hbf | 30 vol.
LOAD: 275 vol.
- Dresden Hbf | 35 vol.
- Kassel-Wilhelmshöhe | 25 vol.
- Osnabrück Hbf | 90 vol.
- Hannover Hbf | 80 vol.
- Hamburg Hbf | 45 vol.
LOAD: 290 vol.
- Würzburg Hbf | 65 vol.
- Stuttgart Hbf | 95 vol.
- Freiburg Hbf | 65 vol.
- Nürnberg Hbf | 65 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: 855 vol. | Vehicle capacity: 300 vol. Loads: [25, 0, 65, 30, 80, 65, 95, 35, 45, 0, 0, 0, 30, 65, 0, 0, 0, 65, 0, 35, 65, 0, 90, 65] ITERATION Generation: #1 Best cost: 5334.200 | Path: [1, 0, 4, 8, 22, 12, 3, 1, 7, 13, 20, 6, 19, 1, 2, 5, 17, 23, 1] Best cost: 5043.118 | Path: [1, 2, 12, 22, 4, 0, 1, 7, 13, 20, 3, 19, 17, 1, 8, 5, 23, 6, 1] Best cost: 4645.704 | Path: [1, 12, 2, 5, 19, 3, 17, 1, 8, 4, 22, 0, 7, 1, 13, 20, 6, 23, 1] Generation: #2 Best cost: 4643.126 | Path: [1, 12, 2, 5, 19, 3, 17, 1, 7, 0, 22, 4, 8, 1, 13, 20, 6, 23, 1] OPTIMIZING each tour... Current: [[1, 12, 2, 5, 19, 3, 17, 1], [1, 7, 0, 22, 4, 8, 1], [1, 13, 20, 6, 23, 1]] [1] Cost: 1621.584 to 1594.663 | Optimized: [1, 12, 2, 5, 19, 17, 3, 1] [3] Cost: 1705.433 to 1648.501 | Optimized: [1, 20, 6, 23, 13, 1] ACO RESULTS [1/290 vol./1594.663 km] Berlin Hbf -> Dortmund Hbf -> Düsseldorf Hbf -> Aachen Hbf -> Mainz Hbf -> Mannheim Hbf -> Frankfurt Hbf --> Berlin Hbf [2/275 vol./1316.109 km] Berlin Hbf -> Dresden Hbf -> Kassel-Wilhelmshöhe -> Osnabrück Hbf -> Hannover Hbf -> Hamburg Hbf --> Berlin Hbf [3/290 vol./1648.501 km] Berlin Hbf -> Würzburg Hbf -> Stuttgart Hbf -> Freiburg Hbf -> Nürnberg Hbf --> Berlin Hbf OPTIMIZATION RESULT: 3 tours | 4559.273 km.