3.1. Model Development
In this section, based on the three stages of the delivery system in
Figure 1, and having met the requirements of both senders and recipients for delivery time windows, we established a POM with the goal of minimum total delivery time and designed the solution algorithm.
(1) Model assumptions
All recipients’ and senders’ needs are known.
We consider only express delivery between the collection hub and the distribution hub.
The collection hub is only responsible for collecting packages from senders. The distribution hub is only responsible for the distribution of packages to recipients.
The distance from the senders to the collection hub and the distance from the distribution hub to the recipients are both no more than half the maximum mileage of delivery vehicles.
The same vehicles are used throughout the ground network.
Each collection hub covers a certain range of senders. Each distribution hub covers a certain range of recipients.
(2) Parameter definition
i: senders who use the system to distribute their packages (i = 1 to N; i = 0 represents the collection hub).
j: sender who use the system to distribute their packages (j = 1 to N; j = 0 represents the collection hub).
i′: recipients who use the system to receive their packages (i′ = 1 to M; i′ = 0 represents the distribution hub).
j′: recipients who use the system to receive their packages (j′ = 1 to M; j′ = 0 represents the distribution hub).
(i,i′): the combination of a sender and recipient.
k: the vehicles used to pick up packages from senders (k = 1 to P).
k′: the vehicles used to deliver packages to the recipients (k′ = 1 to Q)
qmax: the maximum load capacity of the vehicles.
qi: the volume of sanders’ packages.
qi′: the volume of recipients’ packages.
ti,j the transportation time between points i and j.
[Ei,Li]: the delivery time window requirement (earliest and latest times, respectively) for client i
Li′: the latest time when client i’ must receive their packages.
DTn: the time of the n-th delivery along the subway line (n = 1 to W).
twk: the waiting time of packages collected by the vehicle k in the collection hub.
tm: the transportation time of along the subway line between the collection hub and the distribution hub.
twi′: the waiting time of each packages before delivery in the distribution hub.
Sk: the time when vehicles from the collection hub start to pick up packages.
Sk′: the time when vehicles from the distribution hub start to distribution packages.
Ti: the time when vehicles arrive at client i.
(3) Decision variables
We used the following decision variables:
xijk = 1 when vehicle k travels from client i to client j, or 0 otherwise.
yki = 1 when a package from client i is delivered by vehicle k, or 0 otherwise.
zkn = 1 when vehicle k arrives at the distribution hub at a time between DTn and DTn+1, or 0 otherwise.
(4) Objective function
Equation (1) represents the objective function, which is designed to minimize the total delivery time.
represents the total time for collecting all packages;
indicates the total time that all packages are waiting for transportation in the collection hub.
N tm indicates transportation time of all packages along the subway line;
indicates the total time for all packages waiting in the distribution hub; and
represents the total time of distribution all packages.
(5) Constraint conditions
Equations (2) and (3) represent the capacity limit for each vehicle. In other words, the volume of packages in a vehicle cannot exceed the vehicle’s capacity.
Equations (4) and (5) indicate that each client has only one vehicle for the delivery service.
Equation (6) indicates that vehicle k service for a sender
i, and Equation (7) indicates that vehicle
k′ service for a recipients’
i′. After the task is completed, the vehicle must leave that the client.
Equation (8) indicates that every vehicle arriving at point
j will provide a service to that point. Equation (9) indicates that every vehicle arriving at point
j′ will provide a service to that point.
Equations (10) and (11) indicate, respectively, that each vehicle starts from the collection hub and the distribution hub.
Equations (12) and (13) indicate respectively that each vehicle eventually returns to the collection hub and the distribution hub.
Equation (14) indicates that there is only one loop in the path of each vehicle; that is, the vehicle does not travel over the same path twice before it returns to the subway delivery hub.
Equations (15) and (16) indicate that the courier must pick up the package within the sender time window.
Equation (17) represents the waiting time of each vehicle in the collection hub. Equation (18) indicates that the variables have a value of 0 or 1. Equation (19) indicates that the waiting time is greater than or equal to 0.
Equations (20) and (21) describe the waiting time of each package in the distribution hub.
Equations (22) and (23) indicate that the courier must complete the delivery before the latest delivery time required by the recipient.
Equations (24) to (25) indicate that each variable has a value of 0 or 1.
3.2. Genetic Algorithm Design
In this section, we describe a POM that adds strict time window constraints to the classical VRP model and that contains nonlinear constraints. The genetic algorithm is quite mature, and it has been demonstrated that it can be used to solve many path planning problems. The basic idea of a genetic algorithm is to encode decision variables and then use global search to get the global optimal solution. Genetic algorithms are not dependent on function derivability and robustness. In this context, we designed an improved genetic algorithm suitable for embedding heuristic rules and a double-layer chromosome coding to solve the optimization problem. The implementation steps of the algorithm are as follows.
(1) Coding
In the model, the final decision is the delivery path for each vehicle, so chromosome coding is an array with a nonrepeat arrangement that contains all senders and recipients. We used natural number coding rules. Path segmentation requires that the total volume of the packages delivered by each vehicle cannot exceed the vehicle’s standard load capacity. According to the order, from left to right, the sequence of client points reaching vehicle load is determined as a vehicle path. For example, using 0 represents the distribution hub. The nine clients are numbered 1–9. For example, if we assume that there are 3 vehicles in a transfer center, if the loading capacity is satisfied, the initial code can be written as 0 1 2 3 0 4 5 6 0 7 8 9 0, which represents that the first vehicle starts from a collection hub, first goes to client 1 to pick up the packages, then to client 2 to pick up the packages, then to client 3 to pick up the packages, and finally returns to the collection hub, and so on.
(2) Population Initialization
According to the rules for seed coding, a large number of seeds are randomly generated to form the initial population. The population size directly affects the computational efficiency and rate of convergence of the genetic algorithm. Since there are both senders and recipients in this problem, we used double-chromosome coding (i.e., one chromosome for senders and another one for recipients) during population initialization.
Initialization of the upper chromosome: The upper chromosome represents the path the vehicle travels to pick up packages from senders. To improve the algorithm’s efficiency, we embedded a time window sort heuristic rule. We assumed that the sender’s point, with a larger upper bound for their pickup time window (LTn), can have its pickup task postponed temporarily. Therefore, the pickup order for each vehicle is sorted from the sender with the shortest pickup time window to the sender with the longest pickup time window, with the goal of generating a better initial population.
Initialization of the lower chromosome: The lower chromosome represents the path the vehicle travels do deliver packages to recipients. There is a logical correspondence between the lower chromosome and the upper chromosome because the delivery schedule cannot begin until the pickup schedule is complete. We took the following four steps for the encoding and initialization:
Step 1: We set the natural number code of the lower chromosome to the same value as for the upper chromosome. For example, if the upper chromosome encoding adopted the natural numbers from 0 to 9, the lower chromosome encoding adopted the same range.
Step 2: The initialization of the lower chromosome also adopted the time window heuristic rule. The bigger the delivery time window, the lower the client ranking (i.e., recipients with narrow delivery time windows received priority).
Step 3: We then checked the starting time for each dispatch path. If the starting time was after the arrival time at a certain point on the path, we defined that point as illegal.
Step 4: Illegality repair. We exchanged the illegal points with the last element on the chromosome and repeated the inspection in Step 3. If there was still at least one illegal point, we swapped those points with the second-to-last element on the chromosome. We repeated this process until no illegal points remained or all elements had been swapped.
(3) Selection Operation
In the selection process, the delivery time window constraints must be checked on each chromosome. Using an elimination strategy to eliminate unfeasible solutions will greatly reduce the search space and make it easier to identify the local optimal solution. Therefore, we used a penalty function to obtain the optimal solution that satisfies the delivery time window constraint.
The model’s objective function is f(x). The penalty function for outside the time window is g(x) = tefe + tlfl, where te indicates the total time of arrival before the specified time window, fe indicates the unit penalty cost if the courier must wait to pick up a package, tl indicates the time of arrival after the specified window, and fl indicates the unit penalty cost of the client waiting. The penalty function for a late delivery is F(x) = f(x) + g(x). As the number of iterations increases, solutions that do not conform to the time window constraints are gradually eliminated from the set of possible solutions by the penalty function. After a large number of iterations, the penalty value for the window is much higher than the delivery cost, so all solutions that do not conform to the window constraint will be eliminated.
We also constructed a fitness function. The penalty function
Fl(
x) that is used in the construction of the fitness function (Fit) is the minimum function, and it is transformed as follows:
The first 50% is reserved and the second 50% is crossed. We used the roulette wheel selection method in this analysis:
Step 1: We added the fitness value of the current population (i.e., the total Sum), which represents the total area of the roulette wheel.
Step 2: We generated random numbers in the interval [0,1], which we called “Rand”.
Step 3: We multiplied Rand by the total Sum to get a value between 0 and the total Sum, which is called the rotation wheel value. This value is the distance that the imaginary ball has traveled before it falls into a slot in the wheel.
Step 4: We checked the fitness value of an individual in a cumulative group until the cumulative fitness value of an individual was greater than or equal to the rotation wheel value, and then selected the individual.
(4) Interlace operation
If the sequentially encoded chromosome is crossed with the other chromosome using the traditional crossover operation, the crossed offspring are most likely to be in an illegal state, such as having two identical non-zero digits in the encoding. Hence, it was necessary to repair the chromosome to eliminate illegal values; to do so, we used loop crossover. Let the parent chromosomes be P1 and P2, and the offspring be C1 and C2. The specific steps are as follows:
Step 1: All zeroes in the parent chromosome are removed.
Step 2: The first element of P1 is selected as the first element of C1, and the first element of P2 is selected as the first element of C2.
Step 3: The first element of P2 in P1 is found and is assigned to the same relative position in C1. This process is repeated until the first element of P1 that is present in P2. This is called a loop.
Step 4: Steps 2 to 3 are repeated for the former gene according to the principle of P1, P2 gene replacement.
Step 5: Repeat steps 1 to 4 until all the bits are completed.
(5) Mutation operation
Using the method of transposition variation, two gene positions are randomly selected on each chromosome to exchange the bit numbers of genes. After completion of this operation, we followed the cargo quantity constraint and added a 0 code into the chromosome to form a complete descendant code.
(6) Recalculate the fitness and repeat steps (3) to (5).
(7) The number of iterations is pre-set. When the algorithm has performed this number of iterations, it stops. The final result is obtained at this point.