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
- Kassel-Wilhelmshöhe (55 vol.)
- Düsseldorf Hbf (40 vol.)
- Frankfurt Hbf (60 vol.)
- Hannover Hbf (65 vol.)
- Aachen Hbf (60 vol.)
- Stuttgart Hbf (30 vol.)
- Dresden Hbf (65 vol.)
- München Hbf (40 vol.)
- Leipzig Hbf (50 vol.)
- Karlsruhe Hbf (30 vol.)
- Ulm Hbf (75 vol.)
- Mannheim Hbf (65 vol.)
- Mainz Hbf (70 vol.)
- Osnabrück Hbf (100 vol.)
Tour 1
COST: 1601.147 km
LOAD: 300 vol.
- München Hbf | 40 vol.
- Ulm Hbf | 75 vol.
- Stuttgart Hbf | 30 vol.
- Karlsruhe Hbf | 30 vol.
- Mannheim Hbf | 65 vol.
- Frankfurt Hbf | 60 vol.
Tour 2
COST: 1175.198 km
LOAD: 270 vol.
- Dresden Hbf | 65 vol.
- Leipzig Hbf | 50 vol.
- Kassel-Wilhelmshöhe | 55 vol.
- Osnabrück Hbf | 100 vol.
Tour 3
COST: 1448.492 km
LOAD: 235 vol.
- Mainz Hbf | 70 vol.
- Aachen Hbf | 60 vol.
- Düsseldorf Hbf | 40 vol.
- Hannover Hbf | 65 vol.
LOAD: 300 vol.
- München Hbf | 40 vol.
- Ulm Hbf | 75 vol.
- Stuttgart Hbf | 30 vol.
- Karlsruhe Hbf | 30 vol.
- Mannheim Hbf | 65 vol.
- Frankfurt Hbf | 60 vol.
LOAD: 270 vol.
- Dresden Hbf | 65 vol.
- Leipzig Hbf | 50 vol.
- Kassel-Wilhelmshöhe | 55 vol.
- Osnabrück Hbf | 100 vol.
LOAD: 235 vol.
- Mainz Hbf | 70 vol.
- Aachen Hbf | 60 vol.
- Düsseldorf Hbf | 40 vol.
- Hannover 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: 805 vol. | Vehicle capacity: 300 vol. Loads: [55, 0, 40, 60, 65, 60, 30, 65, 0, 40, 0, 50, 0, 0, 30, 75, 0, 65, 0, 70, 0, 0, 100, 0] ITERATION Generation: #1 Best cost: 5703.782 | Path: [1, 0, 22, 4, 2, 14, 1, 11, 7, 19, 3, 6, 1, 15, 9, 17, 5, 1] Best cost: 4383.761 | Path: [1, 2, 5, 19, 3, 17, 1, 7, 11, 4, 22, 1, 0, 14, 6, 15, 9, 1] Best cost: 4242.821 | Path: [1, 9, 15, 6, 14, 17, 3, 1, 7, 11, 4, 22, 1, 0, 2, 5, 19, 1] Best cost: 4228.544 | Path: [1, 9, 15, 6, 14, 17, 3, 1, 7, 11, 0, 22, 1, 4, 2, 5, 19, 1] OPTIMIZING each tour... Current: [[1, 9, 15, 6, 14, 17, 3, 1], [1, 7, 11, 0, 22, 1], [1, 4, 2, 5, 19, 1]] [3] Cost: 1452.199 to 1448.492 | Optimized: [1, 19, 5, 2, 4, 1] ACO RESULTS [1/300 vol./1601.147 km] Berlin Hbf -> München Hbf -> Ulm Hbf -> Stuttgart Hbf -> Karlsruhe Hbf -> Mannheim Hbf -> Frankfurt Hbf --> Berlin Hbf [2/270 vol./1175.198 km] Berlin Hbf -> Dresden Hbf -> Leipzig Hbf -> Kassel-Wilhelmshöhe -> Osnabrück Hbf --> Berlin Hbf [3/235 vol./1448.492 km] Berlin Hbf -> Mainz Hbf -> Aachen Hbf -> Düsseldorf Hbf -> Hannover Hbf --> Berlin Hbf OPTIMIZATION RESULT: 3 tours | 4224.837 km.