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: 14 customers
- Düsseldorf Hbf (50 vol.)
- Frankfurt Hbf (25 vol.)
- Hannover Hbf (50 vol.)
- Aachen Hbf (30 vol.)
- Stuttgart Hbf (35 vol.)
- Dresden Hbf (100 vol.)
- München Hbf (100 vol.)
- Bremen Hbf (75 vol.)
- Nürnberg Hbf (45 vol.)
- Karlsruhe Hbf (45 vol.)
- Köln Hbf (20 vol.)
- Mannheim Hbf (60 vol.)
- Kiel Hbf (90 vol.)
- Freiburg Hbf (90 vol.)
Tour 1
COST: 1399.418 km
LOAD: 400 vol.
- Nürnberg Hbf | 45 vol.
- München Hbf | 100 vol.
- Stuttgart Hbf | 35 vol.
- Karlsruhe Hbf | 45 vol.
- Freiburg Hbf | 90 vol.
- Mannheim Hbf | 60 vol.
- Frankfurt Hbf | 25 vol.
Tour 2
COST: 1346.654 km
LOAD: 315 vol.
- Aachen Hbf | 30 vol.
- Köln Hbf | 20 vol.
- Düsseldorf Hbf | 50 vol.
- Bremen Hbf | 75 vol.
- Kiel Hbf | 90 vol.
- Hannover Hbf | 50 vol.
Tour 3
COST: 745.255 km
LOAD: 100 vol.
- Dresden Hbf | 100 vol.
LOAD: 400 vol.
- Nürnberg Hbf | 45 vol.
- München Hbf | 100 vol.
- Stuttgart Hbf | 35 vol.
- Karlsruhe Hbf | 45 vol.
- Freiburg Hbf | 90 vol.
- Mannheim Hbf | 60 vol.
- Frankfurt Hbf | 25 vol.
LOAD: 315 vol.
- Aachen Hbf | 30 vol.
- Köln Hbf | 20 vol.
- Düsseldorf Hbf | 50 vol.
- Bremen Hbf | 75 vol.
- Kiel Hbf | 90 vol.
- Hannover Hbf | 50 vol.
LOAD: 100 vol.
- Dresden Hbf | 100 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: 815 vol. | Vehicle capacity: 400 vol. Loads: [0, 0, 50, 25, 50, 30, 35, 100, 0, 100, 75, 0, 0, 45, 45, 0, 20, 60, 90, 0, 0, 0, 0, 90] ITERATION Generation: #1 Best cost: 4119.346 | Path: [0, 2, 16, 5, 3, 17, 14, 6, 23, 13, 0, 4, 10, 18, 7, 0, 9, 0] Best cost: 4095.457 | Path: [0, 4, 10, 18, 16, 2, 5, 17, 3, 0, 13, 6, 14, 23, 9, 0, 7, 0] Best cost: 4017.879 | Path: [0, 7, 13, 9, 6, 14, 17, 0, 4, 10, 18, 16, 2, 5, 3, 0, 23, 0] Best cost: 3925.130 | Path: [0, 14, 17, 3, 13, 9, 6, 23, 0, 4, 10, 18, 2, 16, 5, 0, 7, 0] Best cost: 3829.431 | Path: [0, 3, 17, 14, 6, 13, 9, 23, 0, 4, 10, 18, 2, 16, 5, 0, 7, 0] Best cost: 3804.242 | Path: [0, 4, 10, 18, 2, 16, 5, 17, 3, 0, 13, 9, 6, 14, 23, 0, 7, 0] Best cost: 3727.141 | Path: [0, 3, 17, 14, 6, 23, 9, 13, 0, 4, 10, 18, 16, 2, 5, 0, 7, 0] Generation: #5 Best cost: 3698.911 | Path: [0, 3, 17, 14, 6, 23, 9, 13, 0, 4, 10, 18, 2, 16, 5, 0, 7, 0] OPTIMIZING each tour... Current: [[0, 3, 17, 14, 6, 23, 9, 13, 0], [0, 4, 10, 18, 2, 16, 5, 0], [0, 7, 0]] [1] Cost: 1540.212 to 1399.418 | Optimized: [0, 13, 9, 6, 14, 23, 17, 3, 0] [2] Cost: 1413.444 to 1346.654 | Optimized: [0, 5, 16, 2, 10, 18, 4, 0] ACO RESULTS [1/400 vol./1399.418 km] Kassel-Wilhelmshöhe -> Nürnberg Hbf -> München Hbf -> Stuttgart Hbf -> Karlsruhe Hbf -> Freiburg Hbf -> Mannheim Hbf -> Frankfurt Hbf --> Kassel-Wilhelmshöhe [2/315 vol./1346.654 km] Kassel-Wilhelmshöhe -> Aachen Hbf -> Köln Hbf -> Düsseldorf Hbf -> Bremen Hbf -> Kiel Hbf -> Hannover Hbf --> Kassel-Wilhelmshöhe [3/100 vol./ 745.255 km] Kassel-Wilhelmshöhe -> Dresden Hbf --> Kassel-Wilhelmshöhe OPTIMIZATION RESULT: 3 tours | 3491.327 km.