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: 14 customers
- Düsseldorf Hbf (40 vol.)
- Frankfurt Hbf (35 vol.)
- Hannover Hbf (35 vol.)
- Aachen Hbf (45 vol.)
- Stuttgart Hbf (100 vol.)
- Dresden Hbf (95 vol.)
- Hamburg Hbf (80 vol.)
- München Hbf (50 vol.)
- Dortmund Hbf (90 vol.)
- Mannheim Hbf (75 vol.)
- Kiel Hbf (75 vol.)
- Würzburg Hbf (70 vol.)
- Osnabrück Hbf (50 vol.)
- Freiburg Hbf (100 vol.)
Tour 1
COST: 1392.821 km
LOAD: 280 vol.
- Würzburg Hbf | 70 vol.
- Stuttgart Hbf | 100 vol.
- Mannheim Hbf | 75 vol.
- Frankfurt Hbf | 35 vol.
Tour 2
COST: 1327.0 km
LOAD: 260 vol.
- Dortmund Hbf | 90 vol.
- Düsseldorf Hbf | 40 vol.
- Aachen Hbf | 45 vol.
- Osnabrück Hbf | 50 vol.
- Hannover Hbf | 35 vol.
Tour 3
COST: 1874.133 km
LOAD: 245 vol.
- Dresden Hbf | 95 vol.
- München Hbf | 50 vol.
- Freiburg Hbf | 100 vol.
Tour 4
COST: 732.557 km
LOAD: 155 vol.
- Hamburg Hbf | 80 vol.
- Kiel Hbf | 75 vol.
LOAD: 280 vol.
- Würzburg Hbf | 70 vol.
- Stuttgart Hbf | 100 vol.
- Mannheim Hbf | 75 vol.
- Frankfurt Hbf | 35 vol.
LOAD: 260 vol.
- Dortmund Hbf | 90 vol.
- Düsseldorf Hbf | 40 vol.
- Aachen Hbf | 45 vol.
- Osnabrück Hbf | 50 vol.
- Hannover Hbf | 35 vol.
LOAD: 245 vol.
- Dresden Hbf | 95 vol.
- München Hbf | 50 vol.
- Freiburg Hbf | 100 vol.
LOAD: 155 vol.
- Hamburg Hbf | 80 vol.
- Kiel Hbf | 75 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: [0, 0, 40, 35, 35, 45, 100, 95, 80, 50, 0, 0, 90, 0, 0, 0, 0, 75, 75, 0, 70, 0, 50, 100] ITERATION Generation: #1 Best cost: 6485.140 | Path: [1, 2, 12, 22, 4, 8, 1, 7, 20, 3, 17, 1, 18, 5, 6, 9, 1, 23, 1] Best cost: 6211.682 | Path: [1, 3, 17, 6, 20, 1, 7, 18, 8, 4, 1, 22, 12, 2, 5, 9, 1, 23, 1] Best cost: 5392.558 | Path: [1, 20, 3, 17, 6, 1, 4, 22, 12, 2, 5, 1, 7, 9, 23, 1, 8, 18, 1] OPTIMIZING each tour... Current: [[1, 20, 3, 17, 6, 1], [1, 4, 22, 12, 2, 5, 1], [1, 7, 9, 23, 1], [1, 8, 18, 1]] [1] Cost: 1450.494 to 1392.821 | Optimized: [1, 20, 6, 17, 3, 1] [2] Cost: 1335.374 to 1327.000 | Optimized: [1, 12, 2, 5, 22, 4, 1] ACO RESULTS [1/280 vol./1392.821 km] Berlin Hbf -> Würzburg Hbf -> Stuttgart Hbf -> Mannheim Hbf -> Frankfurt Hbf --> Berlin Hbf [2/260 vol./1327.000 km] Berlin Hbf -> Dortmund Hbf -> Düsseldorf Hbf -> Aachen Hbf -> Osnabrück Hbf -> Hannover Hbf --> Berlin Hbf [3/245 vol./1874.133 km] Berlin Hbf -> Dresden Hbf -> München Hbf -> Freiburg Hbf --> Berlin Hbf [4/155 vol./ 732.557 km] Berlin Hbf -> Hamburg Hbf -> Kiel Hbf --> Berlin Hbf OPTIMIZATION RESULT: 4 tours | 5326.511 km.