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: 15 customers
- Kassel-Wilhelmshöhe (60 vol.)
- Düsseldorf Hbf (75 vol.)
- Hannover Hbf (40 vol.)
- Aachen Hbf (80 vol.)
- Dresden Hbf (30 vol.)
- Hamburg Hbf (75 vol.)
- Leipzig Hbf (95 vol.)
- Dortmund Hbf (90 vol.)
- Nürnberg Hbf (100 vol.)
- Ulm Hbf (70 vol.)
- Köln Hbf (40 vol.)
- Mannheim Hbf (50 vol.)
- Kiel Hbf (65 vol.)
- Osnabrück Hbf (85 vol.)
- Freiburg Hbf (90 vol.)
Tour 1
COST: 1308.428 km
LOAD: 285 vol.
- Dortmund Hbf | 90 vol.
- Düsseldorf Hbf | 75 vol.
- Köln Hbf | 40 vol.
- Aachen Hbf | 80 vol.
Tour 2
COST: 1414.275 km
LOAD: 295 vol.
- Ulm Hbf | 70 vol.
- Nürnberg Hbf | 100 vol.
- Leipzig Hbf | 95 vol.
- Dresden Hbf | 30 vol.
Tour 3
COST: 1102.366 km
LOAD: 265 vol.
- Hannover Hbf | 40 vol.
- Osnabrück Hbf | 85 vol.
- Hamburg Hbf | 75 vol.
- Kiel Hbf | 65 vol.
Tour 4
COST: 1666.207 km
LOAD: 200 vol.
- Kassel-Wilhelmshöhe | 60 vol.
- Mannheim Hbf | 50 vol.
- Freiburg Hbf | 90 vol.
LOAD: 285 vol.
- Dortmund Hbf | 90 vol.
- Düsseldorf Hbf | 75 vol.
- Köln Hbf | 40 vol.
- Aachen Hbf | 80 vol.
LOAD: 295 vol.
- Ulm Hbf | 70 vol.
- Nürnberg Hbf | 100 vol.
- Leipzig Hbf | 95 vol.
- Dresden Hbf | 30 vol.
LOAD: 265 vol.
- Hannover Hbf | 40 vol.
- Osnabrück Hbf | 85 vol.
- Hamburg Hbf | 75 vol.
- Kiel Hbf | 65 vol.
LOAD: 200 vol.
- Kassel-Wilhelmshöhe | 60 vol.
- Mannheim Hbf | 50 vol.
- Freiburg Hbf | 90 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: 1045 vol. | Vehicle capacity: 300 vol. Loads: [60, 0, 75, 0, 40, 80, 0, 30, 75, 0, 0, 95, 90, 100, 0, 70, 40, 50, 65, 0, 0, 0, 85, 90] ITERATION Generation: #1 Best cost: 6175.986 | Path: [1, 0, 4, 22, 12, 1, 11, 7, 13, 15, 1, 8, 18, 2, 16, 1, 5, 17, 23, 1] Best cost: 5929.778 | Path: [1, 8, 18, 4, 22, 7, 1, 11, 13, 15, 1, 0, 12, 2, 16, 1, 17, 23, 5, 1] Best cost: 5686.866 | Path: [1, 12, 2, 16, 5, 1, 11, 7, 13, 15, 1, 4, 8, 18, 22, 1, 0, 17, 23, 1] Best cost: 5518.624 | Path: [1, 12, 2, 16, 5, 1, 11, 7, 13, 15, 1, 4, 22, 8, 18, 1, 0, 17, 23, 1] OPTIMIZING each tour... Current: [[1, 12, 2, 16, 5, 1], [1, 11, 7, 13, 15, 1], [1, 4, 22, 8, 18, 1], [1, 0, 17, 23, 1]] [2] Cost: 1441.623 to 1414.275 | Optimized: [1, 15, 13, 11, 7, 1] ACO RESULTS [1/285 vol./1308.428 km] Berlin Hbf -> Dortmund Hbf -> Düsseldorf Hbf -> Köln Hbf -> Aachen Hbf --> Berlin Hbf [2/295 vol./1414.275 km] Berlin Hbf -> Ulm Hbf -> Nürnberg Hbf -> Leipzig Hbf -> Dresden Hbf --> Berlin Hbf [3/265 vol./1102.366 km] Berlin Hbf -> Hannover Hbf -> Osnabrück Hbf -> Hamburg Hbf -> Kiel Hbf --> Berlin Hbf [4/200 vol./1666.207 km] Berlin Hbf -> Kassel-Wilhelmshöhe -> Mannheim Hbf -> Freiburg Hbf --> Berlin Hbf OPTIMIZATION RESULT: 4 tours | 5491.276 km.