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 (75 vol.)
- Düsseldorf Hbf (75 vol.)
- Hannover Hbf (20 vol.)
- Aachen Hbf (85 vol.)
- Dresden Hbf (80 vol.)
- München Hbf (35 vol.)
- Bremen Hbf (25 vol.)
- Leipzig Hbf (50 vol.)
- Dortmund Hbf (25 vol.)
- Nürnberg Hbf (40 vol.)
- Karlsruhe Hbf (65 vol.)
- Ulm Hbf (75 vol.)
- Mannheim Hbf (55 vol.)
- Kiel Hbf (40 vol.)
- Mainz Hbf (85 vol.)
- Freiburg Hbf (30 vol.)
Tour 1
COST: 1768.666 km
LOAD: 390 vol.
- Leipzig Hbf | 50 vol.
- Dresden Hbf | 80 vol.
- Berlin Hbf | 75 vol.
- Kiel Hbf | 40 vol.
- Bremen Hbf | 25 vol.
- Hannover Hbf | 20 vol.
- Dortmund Hbf | 25 vol.
- Düsseldorf Hbf | 75 vol.
Tour 2
COST: 1430.249 km
LOAD: 385 vol.
- Mainz Hbf | 85 vol.
- Mannheim Hbf | 55 vol.
- Karlsruhe Hbf | 65 vol.
- Freiburg Hbf | 30 vol.
- Ulm Hbf | 75 vol.
- München Hbf | 35 vol.
- Nürnberg Hbf | 40 vol.
Tour 3
COST: 603.634 km
LOAD: 85 vol.
- Aachen Hbf | 85 vol.
LOAD: 390 vol.
- Leipzig Hbf | 50 vol.
- Dresden Hbf | 80 vol.
- Berlin Hbf | 75 vol.
- Kiel Hbf | 40 vol.
- Bremen Hbf | 25 vol.
- Hannover Hbf | 20 vol.
- Dortmund Hbf | 25 vol.
- Düsseldorf Hbf | 75 vol.
LOAD: 385 vol.
- Mainz Hbf | 85 vol.
- Mannheim Hbf | 55 vol.
- Karlsruhe Hbf | 65 vol.
- Freiburg Hbf | 30 vol.
- Ulm Hbf | 75 vol.
- München Hbf | 35 vol.
- Nürnberg Hbf | 40 vol.
LOAD: 85 vol.
- Aachen 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: [0] Kassel-Wilhelmshöhe | Number of cities: 24 | Total loads: 860 vol. | Vehicle capacity: 400 vol. Loads: [0, 75, 75, 0, 20, 85, 0, 80, 0, 35, 25, 50, 25, 40, 65, 75, 0, 55, 40, 85, 0, 0, 0, 30] ITERATION Generation: #1 Best cost: 4293.916 | Path: [0, 1, 11, 7, 13, 9, 15, 23, 0, 4, 10, 18, 12, 2, 5, 19, 0, 17, 14, 0] Best cost: 3951.830 | Path: [0, 11, 7, 1, 4, 10, 18, 12, 2, 0, 19, 17, 14, 23, 15, 9, 13, 0, 5, 0] Best cost: 3893.176 | Path: [0, 7, 11, 1, 18, 10, 4, 12, 2, 0, 19, 17, 14, 23, 15, 9, 13, 0, 5, 0] Generation: #2 Best cost: 3802.549 | Path: [0, 11, 7, 1, 18, 10, 4, 12, 2, 0, 19, 17, 14, 23, 15, 9, 13, 0, 5, 0] OPTIMIZING each tour... Current: [[0, 11, 7, 1, 18, 10, 4, 12, 2, 0], [0, 19, 17, 14, 23, 15, 9, 13, 0], [0, 5, 0]] No changes made. ACO RESULTS [1/390 vol./1768.666 km] Kassel-Wilhelmshöhe -> Leipzig Hbf -> Dresden Hbf -> Berlin Hbf -> Kiel Hbf -> Bremen Hbf -> Hannover Hbf -> Dortmund Hbf -> Düsseldorf Hbf --> Kassel-Wilhelmshöhe [2/385 vol./1430.249 km] Kassel-Wilhelmshöhe -> Mainz Hbf -> Mannheim Hbf -> Karlsruhe Hbf -> Freiburg Hbf -> Ulm Hbf -> München Hbf -> Nürnberg Hbf --> Kassel-Wilhelmshöhe [3/ 85 vol./ 603.634 km] Kassel-Wilhelmshöhe -> Aachen Hbf --> Kassel-Wilhelmshöhe OPTIMIZATION RESULT: 3 tours | 3802.549 km.