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: 400 vol.
ACTIVE: 16 customers
- Berlin Hbf (80 vol.)
- Düsseldorf Hbf (95 vol.)
- Frankfurt Hbf (55 vol.)
- Hannover Hbf (50 vol.)
- Aachen Hbf (75 vol.)
- Stuttgart Hbf (35 vol.)
- Dresden Hbf (75 vol.)
- Hamburg Hbf (60 vol.)
- Bremen Hbf (80 vol.)
- Leipzig Hbf (30 vol.)
- Dortmund Hbf (65 vol.)
- Nürnberg Hbf (85 vol.)
- Köln Hbf (75 vol.)
- Kiel Hbf (55 vol.)
- Saarbrücken Hbf (90 vol.)
- Osnabrück Hbf (80 vol.)
Tour 1
COST: 981.401 km
LOAD: 400 vol.
- Saarbrücken Hbf | 90 vol.
- Aachen Hbf | 75 vol.
- Köln Hbf | 75 vol.
- Düsseldorf Hbf | 95 vol.
- Dortmund Hbf | 65 vol.
Tour 2
COST: 1584.229 km
LOAD: 360 vol.
- Frankfurt Hbf | 55 vol.
- Stuttgart Hbf | 35 vol.
- Nürnberg Hbf | 85 vol.
- Dresden Hbf | 75 vol.
- Berlin Hbf | 80 vol.
- Leipzig Hbf | 30 vol.
Tour 3
COST: 937.097 km
LOAD: 325 vol.
- Hannover Hbf | 50 vol.
- Hamburg Hbf | 60 vol.
- Kiel Hbf | 55 vol.
- Bremen Hbf | 80 vol.
- Osnabrück Hbf | 80 vol.
LOAD: 400 vol.
- Saarbrücken Hbf | 90 vol.
- Aachen Hbf | 75 vol.
- Köln Hbf | 75 vol.
- Düsseldorf Hbf | 95 vol.
- Dortmund Hbf | 65 vol.
LOAD: 360 vol.
- Frankfurt Hbf | 55 vol.
- Stuttgart Hbf | 35 vol.
- Nürnberg Hbf | 85 vol.
- Dresden Hbf | 75 vol.
- Berlin Hbf | 80 vol.
- Leipzig Hbf | 30 vol.
LOAD: 325 vol.
- Hannover Hbf | 50 vol.
- Hamburg Hbf | 60 vol.
- Kiel Hbf | 55 vol.
- Bremen Hbf | 80 vol.
- Osnabrück Hbf | 80 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: [0] Kassel-Wilhelmshöhe | Number of cities: 24 | Total loads: 1085 vol. | Vehicle capacity: 400 vol. Loads: [0, 80, 95, 55, 50, 75, 35, 75, 60, 0, 80, 30, 65, 85, 0, 0, 75, 0, 55, 0, 0, 90, 80, 0] ITERATION Generation: #1 Best cost: 4307.596 | Path: [0, 1, 7, 11, 4, 10, 8, 0, 22, 12, 2, 16, 5, 0, 3, 21, 6, 13, 18, 0] Best cost: 4096.365 | Path: [0, 5, 16, 2, 12, 22, 0, 4, 10, 18, 8, 1, 7, 0, 3, 6, 13, 11, 21, 0] Best cost: 3967.345 | Path: [0, 7, 11, 1, 8, 18, 10, 0, 12, 16, 2, 5, 21, 0, 22, 4, 3, 6, 13, 0] Best cost: 3757.012 | Path: [0, 8, 18, 10, 4, 22, 12, 0, 2, 16, 5, 21, 3, 0, 11, 7, 1, 13, 6, 0] Best cost: 3747.555 | Path: [0, 11, 7, 1, 8, 18, 10, 0, 22, 12, 16, 2, 5, 0, 4, 3, 21, 6, 13, 0] Best cost: 3593.704 | Path: [0, 22, 12, 2, 16, 5, 0, 4, 10, 8, 18, 1, 7, 0, 3, 21, 6, 13, 11, 0] Best cost: 3555.446 | Path: [0, 1, 11, 7, 13, 6, 3, 0, 12, 2, 16, 5, 21, 0, 22, 10, 8, 18, 4, 0] Best cost: 3530.752 | Path: [0, 3, 6, 13, 11, 7, 1, 0, 12, 2, 16, 5, 21, 0, 22, 10, 8, 18, 4, 0] Generation: #4 Best cost: 3528.624 | Path: [0, 21, 5, 16, 2, 12, 0, 3, 6, 13, 11, 7, 1, 0, 22, 10, 8, 18, 4, 0] OPTIMIZING each tour... Current: [[0, 21, 5, 16, 2, 12, 0], [0, 3, 6, 13, 11, 7, 1, 0], [0, 22, 10, 8, 18, 4, 0]] [2] Cost: 1603.388 to 1584.229 | Optimized: [0, 3, 6, 13, 7, 1, 11, 0] [3] Cost: 943.835 to 937.097 | Optimized: [0, 4, 8, 18, 10, 22, 0] ACO RESULTS [1/400 vol./ 981.401 km] Kassel-Wilhelmshöhe -> Saarbrücken Hbf -> Aachen Hbf -> Köln Hbf -> Düsseldorf Hbf -> Dortmund Hbf --> Kassel-Wilhelmshöhe [2/360 vol./1584.229 km] Kassel-Wilhelmshöhe -> Frankfurt Hbf -> Stuttgart Hbf -> Nürnberg Hbf -> Dresden Hbf -> Berlin Hbf -> Leipzig Hbf --> Kassel-Wilhelmshöhe [3/325 vol./ 937.097 km] Kassel-Wilhelmshöhe -> Hannover Hbf -> Hamburg Hbf -> Kiel Hbf -> Bremen Hbf -> Osnabrück Hbf --> Kassel-Wilhelmshöhe OPTIMIZATION RESULT: 3 tours | 3502.727 km.