Application of Genetic Algorithm, A Mega-Heuristic Approach, To Solve A Real-Size Vehicle Routing Problem: A Case Study
Application of Genetic Algorithm, A Mega-Heuristic Approach, To Solve A Real-Size Vehicle Routing Problem: A Case Study
and Practices
2023, Vol. 2, No. 1, pp. 10–16
DOI: 10.54646/bijomrp.2023.12
www.bohrpub.com
METHODS
*Correspondence:
Phong Nguyen Nhu,
[email protected]
Most of the 3PL companies that provide transportation services are handling thousands of orders per day. Vehicle
routing problems (VRPs) help plan the distribution of goods with the optimum fleet of vehicles and delivery routes
and play an important role in helping businesses reduce transportation costs while ensuring service level. VRPs
are NP-hard combinatorial optimization problems. It is quite difficult to achieve an optimal solution for real-size
problems with a mathematical modeling approach because of its NP-hard structure. Genetic algorithm (GA) plays
a major role in searching for near-optimal solutions for NP-hard optimization problems. This article develops the
GA model for VRPs. The result shows that the delivery cost is reduced by 17.88%, while the service level increase
from 88.7 to 100%. It indicates that the model can be a good technique for VRPs.
Keywords: distribution planning, mathematical modeling, vehicle routing problems, genetic algorithm
10
10.54646/bijomrp.2023.12 11
classic VRP because either the vehicles are not required to The VRP is a challenging combinatorial optimization
return to the depot or they have to return by revisiting the problem (7). Complexity in solving the problem increases
customers assigned to them in the reverse order (4). exponentially as the problem size increases. GA is a
The capacitated VRP is a problem risen in the fields of widely applied search method to complex problems such
transportation, distribution, and logistics in which a fleet as VRPs (2).
of delivery vehicles must service known customer demands
for a single commodity from a common depot at minimum
cost (5). In the well-known VRP, a set of identical vehicles, 2.2. Genetic algorithm
based at a central depot, is to be optimally routed to supply
customers with known demands subject to vehicle capacity Genetic algorithm, first introduced by Holland in 1975, is
constraints (6). an artificial intelligence search method that uses the process
of evolution and natural selection of individuals called
chromosomes. It is an efficient tool for solving optimization
TABLE 1 | Loads, time limits, and fleet costs. problems. In order to apply GA to a problem, generally the
solution space of the problem is represented by a population
v 1 2 3 4 5 6 of chromosomes where each chromosome is a possible
Qv (kg) 300 300 300 400 400 500
solution to the problem. Chromosomes are represented by
fv (M) 3 3 3 4 4 5
strings. A method of coding is the selection of a string
Tv (h) 8 8 8 8 8 8
format for the chromosomes. A fitness value is associated
with each chromosome. The fitness function is a measure of
the extent to which the objective of the problem is achieved.
The fitness function is derived from the objective function of
TABLE 2 | Demand, unloading time at delivery points. the problem. A certain number of chromosomes are chosen
i 1 2 3 4 5 6 7 8 to form the initial generation. The chromosomes of the
next generation are generated by applying genetic operators,
di (kg) 50 300 200 150 100 150 50 100 including selection, crossover, mutation, and replacement, to
Si (h) 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 the chromosomes of the existing generation.
Starting from an initial population, the algorithm produces
a new population of individuals, which are presumably more
TABLE 3 | Travel time Tij (h) between nodes.
fit than their ancestors. The process is repeated until a pre-
specified termination rule becomes true. At each generation,
i\j 0 1 2 3 4 5 6 7 8 every new chromosome corresponds to a solution.
3. The vehicle routing problem The objective of the problem is to minimize the total
delivery cost. The constraints of the problem include the
The problem to be solved is an OVRP, where vehicles after following: Each route starts at the warehouse and ends at
delivery to customers do not need to return to the starting a customer point. The number of vehicles starting at the
point. The distribution system consists of a warehouse and real warehouse and ending at the virtual warehouse is equal
a fleet of vehicles Vv , v = 1÷V. Each vehicle Vv has max and does not exceed the limited number of vehicles. The
load Qv , limited delivery time Tv , and operating cost fv . number of cars arriving and leaving at each node is equal.
The system distributes for N customers, and each customer Each customer is only served once by one vehicle. The
is 1 point on the distribution network. The distribution total delivery time does not exceed the time limit. The total
network consists of N + 1 nodes, with node 0 being the demand of the customers in each route does not exceed the
warehouse, node i, i = 1÷N corresponding to the ith vehicle tonnage.
customer. Customers at node i have demand di, unloading The model is set up with the decision variable yij v ,
time Si, i = 1÷N. On a distributed network, the travel time i = 0÷N−1, j = 1÷N, v = 1÷V. If vehicle v moves from node
from node i to node j is Tij , i = 0÷N−1, j = 1÷N. i to node j, then yij v is 1; otherwise, yij v is 0. The model is as
follows:
V X
X N
v
TABLE 8 | The crossover population PC = {C5, C6}. Min Z, Z = fv y0j
v = 1j = 1
PC S1 S2
C5 [6, 4, 3, 8, 1, 7, 5, 2] [3, 1, 2, 4, 5, 6] V X
X N V X
X N
v v
C6 [1, 4, 2, 8, 3, 5, 6, 7] [1, 3, 4, 5, 2, 6] St. : y0j = yi0 ≤ V
v = 1j = 1 v = 1i = 1
V X
N
TABLE 9 | The mutation list Pm = {C1}. X
yijv = 1, j ∈ N\{0}, i 6 = j
PE (0) C2 C1 C3 C3 v = 1i = 0
N X
X N
[(tij + sj )yijv ] ≤ T, v ∈ V, i 6 = j
TABLE 11 | The genetic population PG (0) . i = 0j = 0
PG (0) S1 S2 Z
yijv ∈ {0, 1}, v ∈ V, j ∈ N, i ∈ N, i 6 = j
C5 [7, 4, 3, 8, 2, 6, 1, 5] [3, 1, 6, 4, 5, 2] 13
C6 [2, 8, 7, 1, 4, 3, 6, 5] [3, 4, 5, 1, 2, 6] 14
C7 [6, 8, 2, 4, 7, 5, 1, 3] [4, 5, 2, 3, 1, 6] 14 4. The GA model for the pilot VRP
The pilot problem is a VRP problem with six trucks and eight
TABLE 12 | The next population. customers (V = 6, N = 8). The parameters of fleet, customers,
and travel time between nodes are as in Tables 1–3. The pilot
P(1) S1 S2 Z F problem model is set up according to the above parameters.
The GA model is used to solve the problem by the following
C2 [1, 4, 3, 8, 2, 6, 7, 5] [3, 1, 2, 4, 5, 6] 13 2
procedure:
C5 [7, 4, 3, 8, 2, 6, 1, 5] [3, 1, 6, 4, 5, 2] 13 2
C6 [2, 8, 7, 1, 4, 3, 6, 5] [3, 4, 5, 1, 2, 6] 14 1 Step 1: Initialize the GA model.
C7 [6, 8, 2, 4, 7, 5, 1, 3] [4, 5, 2, 3, 1, 6] 14 1
Step 2: Generate the initial population P(0) . Set k = 0.
10.54646/bijomrp.2023.12 13
Step 3: Generate elite population PE (k) . Customers are numbered from 1 to 8. Each sub-
chromosome S1 is a string of eight genes, Gci , i = 1÷8,
Step 4: Generate the genetic population PG (k) .
corresponding to eight customers. The sequence of genes in a
Step 5: Generate the next population P(k+1) . Set k = k sub-chromosome represents the sequence of customers being
+1. served: S1 = (Gc1 , Gc2 , Gc3 , Gc4 , Gc5 , Gc6 , Gc7 , Gc8 ). Vehicles
Step 6: Check the termination rule. If no, return to Step are numbered from 1 to 6. Each sub-chromosome S2 is a
3. If yes, finish the loop. string of six genes, Gvj , j = 1÷6, corresponding to six vehicles.
The sequence of genes in a sub-chromosome represents the
Step 1: Initialize the GA model sequence of vehicles being used:
This step sets up factors of GA models, including the
method of coding, the population size, the fitness function,
the parameters of GA operators, and the termination rule. S2 = (Gv1 , Gv2 , Gv3 , Gv4 , Gv5 , Gv6 )
The method of coding: Each chromosome C is a string of
The population size P is chosen to be 4:
two sub-chromosomes, S1 is corresponding to the customer
sequence, and S2 is corresponding to the vehicle sequence:
P = 4.
C = [S1, S2] The fitness function F is defined as Fi = Zmax − Zi , where
Fi and Zi are the fitness and objective values of chromosome
i and Zmax is the maximum objective value in the population.
The GA operators include selection, crossover, mutation,
and replacement operators. The selection method is based
on selection probabilities, determined by fitness values. The
crossover method is OX (Order Crossover), the mutation
method is SWAP, and the replacement method is acceptance
threshold. The crossover probability Pc , the mutation
probability Pm , and threshold K are chosen as follows:
Pc = 0.8; Pm = 0.2; K = 2.
Step 2: Generate the initial population P(0) , set k = 0. Step 5: Generate the next population P(k+1)
The initial population consists of four chromosomes. Each This step uses the replacement operator to generate the
initial individual is created including customer sequence next population P(k+1) from the populations P(k) & PG (k) .
and vehicle sequence, by randomizing the customer delivery The chromosomes from PG (k) will be added to the current
points and available vehicles. The initial population P(0) is population P(k) to make the next population P(k+1) if their
shown in Table 4: P(0) = {C1, C2, C3, C4}. objective values are better than the acceptable threshold,
From customer sequence S1 , vehicle sequence S2 , based on defined by the objective value of the threshold chromosome.
the constraints, the vehicles used, and their corresponding The threshold chromosome is a chromosome in P(k) with
routes are determined, as shown in Table 4. From that, position n defined by population size P and threshold
the objective values Z and fitness values F of each parameter K: n = P/k. With a population size of 4, and the
chromosome can be determined. In the initial population replacement parameter K of 2, the acceptable threshold is
P(0) , the best chromosomes are C2, with the best objective selected as the value of the second chromosome of P(k) in the
value Z of 13 (M). top–down ranking.
Step 3: Generate elite population PE (k) . On the other side, in order to keep the next population
This step uses the selection operator to generate elite size constant, some chromosomes in P(k) with the lowest
population PE (k) from P(k) . Each chromosome in the current fitness values are removed. In P(0) , C1 is the second
population has a corresponding fitness value Fi and is chromosome in the top–down list, and the acceptable
selected for inclusion in the elite population PE (k) with threshold is 14. Looking at the objective values of the
selection probability Pi determined as follows: chromosomes in population PG (0) , C5, C6, and C7 move
into P(1) and C1, C3, and C4 have to move out
Pi = Fi /6 i = 1÷4 (Fi ). to keep P(1) population size constant. Table 12 shows
the chromosomes in the next population P(1) . In P(1) ,
With population P(0) , the values of Fi , Pi , and the the best chromosomes are C2 and C3, with the best
cumulative probability function (CPF) are calculated as objective value of 13.
shown in Table 5. Random numbers Ri are generated 4 times.
Based on CPF, the chromosomes selected into the population
PE (0) are as Table 6. P(1) = {C2, C5, C6, C7}
Step 4: Generate the genetic population PG (k) .
This step uses the crossover and mutation operators
to generate genetic population PG (k) from the elite TABLE 13 | Loads, time limits, and fleet costs.
population PE (k) . The genetic population PG (k) includes V 1÷6 7÷9 10 11÷12
the new chromosome generated from the crossover and
mutation operators. Qv (kg) 1000 1400 1900 2000
The chromosomes of PE (0) are selected to be included fv (M) 1.150 1.600 1.800 2.000
in the crossover list Pc with the crossover probability of Tv (h) 8 8 8 8
0.8. After generating four random numbers Ri , the set Pc is
determined as shown in Table 7. Each pair of chromosomes
in Pc is selected to cross over by the OX method, on both TABLE 14 | Demand, unloading time at delivery points.
sub-chromosomes, resulting in two new chromosomes in
i 1 2 3 4 ... 97
population PC . C2 and C3 are crossed over to each other
and generate two children, C5 and C6. The population PC di (kg) 14.5 17 9 14.5 ... 1000
is shown in Table 8. Si (h) 0.25 0.25 0.25 0.25 ... 0.25
The chromosomes of PE (0) are also selected to be included
in the mutation list Pm with the mutation probability of
0.2. After generating four random numbers Ri , the set
TABLE 15 | Travel time Tij (h) between nodes.
Pm is determined as shown in Table 9. Each chromosome
in Pm is selected to mutate by the SWAP method, on 0 1 2 3 4 ... 97
both sub-chromosomes, resulting in one new chromosome
in population PM . C1 is mutated and generates C7. The 0 – 0.313 0.214 0.124 0.521 ... 0.365
population PM is shown in Table 10. 1 – 0.651 0.145 0.689 ... 0.287
After crossover and mutation, three new chromosomes are 2 – 0.09 0.871 ... 0.697
created in the population PG (0) . Chromosomes in PG (0) with 3 – 0.416 ... 1.010
their genes and objective values are shown in Table 11. 4 – ... 0.723
... – ...
97 –
PG (0) = {C5, C6, C7}
10.54646/bijomrp.2023.12 15
2 [0, 12, 77, 82, 64, 50, 60, 42, 69, 93, 28, 87, 30, 11, 21, 32, 96, 25, 56, 91, 7. Conclusion
53, 5, 23]
5 [0, 6, 75, 66, 57, 9, 72, 73, 22, 16, 41, 89, 81, 13, 19, 36, 20, 79, 92, 74, 24, The GA model has been used to solve the VRP in a
43, 2, 90] distribution system with one warehouse, 12 trucks, and
7 [0, 97, 26, 44, 95, 48, 15, 4] 97 customers. The results show that the GA model gives
8 [0, 71, 94, 45, 18, 51, 14, 3, 59, 84, 70, 65,88, 52, 8, 38, 61, 63, 86, 58, 10, lower cost and higher service level than the heuristic
54, 62]
method, being used. However, the parameters of the
9 [0, 7, 31, 47, 1, 29, 80, 40, 76, 67, 39, 49, 37, 35, 68, 46, 83, 17, 78, 34, 55,
27, 33, 85]
model are only selected empirically, so the results are
not very good. Future research is to use experimental
design DOE to determine the model parameters to get
suboptimal results.
TABLE 17 | Total cost between the current method and the genetic
algorithm (GA) model.
Model Total cost Number of late Service level (%) Author contributions
(million) delivery nodes