Logistics Pure Electric Vehicle Routing Based on GA-PSO Algorithm

In this paper, with the current practical application in logistics industry as the background, from electric vehicle charging scheduling and path planning, a hybrid algorithm combining genetic-particle swarm algorithm is proposed to plan the best driving route for a group of electric logistics vehicles with vehicle load, vehicle battery life, charging facility location and customer time window as constraints and the total cost as the objective function. Based on the single distribution center, a more complex multi-distribution center electric vehicle path planning problem is considered. In this paper, multiple sets of Solomon VRPTW data sets are selected to test the prepared algorithm, and the results show that the algorithm can effectively plan the best distribution scheme.


Introduction
In the face of the increasingly serious energy and environmental problems, the vigorous development of electric vehicles has become an important means of the "double carbon" strategy, combined with the current good prospects of the logistics industry, the application of electric vehicles to logistics transport has great practical significance. Most of the research on traditional vehicles is to consider reducing energy consumption, mainly from two directions: optimization of path and optimization of speed [1].With the great development of transportation electrification, the path planning problem of electric vehicles has been gradually attracted attention, and increasing scholars have started to research the joint optimization problem between grid and transportation network [2].Reference [3] presents the electric vehicles path optimization problem under time-sharing tariff. Reference [4] focused on the coupling relationship between the electric power system and electric vehicle fleet and customer demand, and carried out the joint optimization of the system. Reference [5] considered the time-varying nature of the grid load state and the uncertainty of the road network traffic congestion to optimize the charging path of electric vehicles. Zhang [6] proposed a wireless charging technique based on reinforcement learning, which pointed out a new research direction for electric vehicle path planning.
The current algorithms for solving electric vehicle path planning problems mainly include exact algorithms, heuristic algorithms, and intelligent optimization algorithms. Hu [7] proposed a particle swarm algorithm to optimize the single-storage logistics distribution problem with good results, but did not consider the case of multiple warehouses; Liu [8] used a hybrid ant colony algorithm to solve the electric vehicle path problem in cold chain distribution, which has good solution effect for small-scale customer points, but poor solution effect for large-scale nodes. The VRP problem with time-varying speed has become a rese-arch hotspot in recent years [9]. Jia [10] considered the timevarying speed and dynamic demand, optimizes the initial path using SA-VNS algorithm first, and then handles the dynamic demand at the end moment of each time domain, and proposes a solution algorithm based on time domain division. Gmira [11] et al. consider the change of travel time and driving path between customers under time-varying conditions, and use the forbidden search algorithm to solve the problem. Li [12] used a dual-strategy ant colony algorithm to optimize the electric vehicle path for e-commerce terminal logistics delivery, and tested it using real data from Cainiao, and obtained good optimization results, but did not consider the time window factor. Intelligent optimization algorithm is essentially a stochastic search algorithm, which is easy to fall into local optimum, and the performance of the algorithm is greatly affected by the scale of the problem. In this paper, a hybrid genetic-particle swarm algorithm is proposed to address the above research shortcomings, which effectively improves the optimization performance of pure particle swarm algorithm and considers the soft time window, multi-distribution center problem with charging facilities. Through example tests, it is verified that the proposed algorithm in this paper has better performance in finding the optimal performance.

Variables and parameters definition
The variables and parameters involved in this paper are described in Table 1.

Objective function
From the perspective of logistics companies, the total economic cost is usually minimized as the optimization objective. And the specific costs include vehicle fixed cost, travel distance cost, and time window penalty cost as shown in Eq. (1).

Constraints
The mathematical model of the electric vehicle routing problem (EVRP) has three nodes: distribution center, customer, and charging station. Each vehicle can only perform one delivery task, so each vehicle can only depart from the distribution center once, as represented by Eq. (2).
In this paper, we study the problem of non-splittability of customer demand, so each customer can only be serviced by one vehicle, as described by Eq. (3).
For each vehicle with a distribution task, it is required to be able to fit the cargo requirements of all the customer points it is about to perform distribution services, as shown in Eq. (4). 0 jk w W j M ,k K .     (4) A vehicle arrives at the next customer node from one customer node and leaves a node with a load equal to the load leaving the previous node minus the demand at the next node, as expressed in Eq. (5). (1 ) .
The vehicle batteries all have a maximum charge of Q. The vehicle departs from the distribution center with a full charge and is charged to a full charge each time, as shown in Eq. (6).
The power consumption rate of the vehicle is h, which needs to meet with Eq. (7). 12 (1 ) .
The starting time at the distribution center is set to 0; the time spent between two nodes is the ratio of distance and vehicle speed, as defined by Eq. (8); Eq. (9) indicates that the vehicle needs to perform the service within the time requested by the customer point; Eq. (10) implies that the vehicle arrives early and then needs to wait until the earliest start time requested by the customer to perform the service.

Coding process
According to principle of particle swarm algorithm, each particle has two basic attributes: location and speed settings. Location is divided into two attributes: xp and xs. And xp is a row vector of 1 n  , whose elements are the random number between 0 and k. k is the total number of vehicles and characterizes the number of vehicles that each customer is served; n is the number of customers; xs is a row vector of 1 n  , whose elements are random numbers between 0 and n. xs also characterizes the order in which each customer is served. Correspondingly, the speed is divided into two attributes vp and vs,which are used to update xp and xs respectively. vp is a row vector of1 n  with a random number of elements between [-0.1*k,0.1*k], and vs is a row vector of 1*n with a random number of elements between [-0.1*n,0.1*n].This coding rule ensures that each customer point is served, and that there are no multiple vehicles serving the same customer, which is consistent with the problem and simple to implement.

Decoding process
Rounding up xp, the vehicle number of each customer point being served can be obtained; the customer points with the same vehicle number are extracted, and the xs elements of these customer points are sorted from smallest to largest to characterize the order of service. Now we suppose there are 8 customer points, one distribution center and 3 electric vehicles in a distribution area, and the code of a particle is shown in Table 2.
According to the above decoding rules, the particle state is then decoded as in Table 3. Delivery tasks are shown in Table 4.

Illustrating example
An example is selected from the data set R105 of Solomon VRPTW, with the overall clustering distribution of customer points. The number of customer points is 15, the number of charging stations is 5, and the number of distribution centers is 1. The code is run 20 times independently, the number of iterations is set to 8000, and the results of the 20 iterations are recorded as shown in Table 4, and the optimal solution found within the finite number of runs is 18610.55, and the iterative process curve is shown in Fig. 1. Fig.1 shows that the above particle swarm algorithm can effectively jump out of the local optimal point in the process of finding the optimal point, and it must eventually converge to the global optimal solution under the current number of iterations. While, sometimes the searched suboptimal solution is relatively ineffective, thus the stability of this algorithm to search the optimal value needs to be improved. The best scheduling solution for this problem is to use three electric vehicles to complete the distribution task, and the total distribution cost is 18610.55. Subpath1 is 0-9-13-17-3-11-6-20-0, subpath2 is 0-1-7-19-4-17-10-0, and subpath3 is 0-12-15-5-18-14-8-2-18-0. Fig. 1 Iteration curve of particle swarm algorithm In this section, we propose an improved particle swarm algorithm, which integrates the genetic operator and the particle swarm algorithm to diversify the way of particle update and increase the genetic diversity of the population. The specific operation of the genetic operator is described as following: The particles with the top 50% of fitness in each generation are put into the genetic operation pool, and then the crossover and mutation operations are performed on the genetic population with a certain probability. Crossover means randomly selecting two chromosomes, then randomly selecting a crossover point, and swapping the genes after the crossover point of the two chromosomes. This genetic operation can replace a bad section of chromosome with a certain probability, and combine the good genes of two parental individuals, making the traits of the offspring superior to those of the parents. Mutation refers to randomly selecting a chromosome and then randomly generating a certain number of mutation points to transform into alleles respectively with a certain probability. This operation can fine-tune the particles in the solution space locally, making the search process more detailed, which can effectively avoid local optimum and increase the possibility of converging to the global optimum solution.
Flow chart of the proposed algorithm is shown in Fig. 2. Firstly, initialize the population according to the coding rules, calculate the fitness function of the initial population, and update the individual optimal and global optimal according to the fitness value; then select the top 50% of the individuals to perform crossover and mutation operations, and calculate this part of the particles the fitness value of , and update the individual and local optimum again; finally, update the position and velocity of all particles before entering the genetic operation, and judge whether the termination condition is reached. If so, terminate the algorithm and output the optimal solution under the current number of iterations; if not, calculate the fitness value of the new generation population.

Illustrating comparison example
The improved genetic-particle swarm hybrid algorithm was tested for the example in Section 2.2, and the code was run 20 times independently in the same hardware environment. The results are shown in Table 5.
According to Table 5, the improved particle swarm algorithm searches for the optimal solution within 20 times more often, the worst solution is better than the worst solution of the pure particle swarm algorithm, and the average value of 20 tests is also better than the original. Therefore, the improved hybrid algorithm obviously has better search performance than the pure particle swarm algorithm. An example with customer points in an overall uni form distribution is selected from the dataset R101 of Solomon VRPTW, where the number of customer points is 15, the number of charging stations is 5, and the number of distribution centers is 1. The number of iterations is set to 5000, and the program is run several times, resulting in the optimal distribution solution within a limited number of runs using Fig. 3 Iteration curve of GA-PSO algorithm 4 vehicles, with a distribution cost of 23988.96 (Fig. 3), subpath 1: 0-12-19-15-6-17-13-0, subpath 2: 0-14-16-8-10-18-0, subpath 3: 0-11-7-18-9-1-0, and subpath 4: 0-5-2-19-3-4-19-0. These results show that the hybrid genetic-particle swarm algorithm also has good performance in finding the optimal solution for the data set of type R101, which indicates that the proposed algorithm has strong robustness.

Parameter sensitivity analysis
In the mathematical model of the electric vehicle path planning problem, there are many parameters that need to be adjusted according to the actual situation, which are directly or indirectly related to the expression of the objective function, and thus affect the distribution scheme. In this section, a hybrid genetic-particle swarm algorithm is used to conduct a sensitivity study on the example in Section 3.2 and analyze the specific impact of each parameter on the distribution scheme and the total distribution cost.

Vehicle load factor
Vehicle loads can limit the number of customer points served, thus affecting the overall distribution program. Distribution costs are compared in Table 6.
From Table 6, we find that: 1. The cost of dispatching five vehicles is the highest and the number of vehicles theoretically required decreases as the vehicle load increases. 2. Even if the minimum number of vehicles to be dispatched is only 3, the firm will send 4 vehicles. Although the fixed cost of 3 vehicles is lower, the sum of the resulting time window cost and distance cost will be more than that of 4 vehicles. 3. Vehicle capacity redundancy is greater when the vehicle load is 110 and 220, which will result in many empty loads and lead to waste of resources; therefore, the vehicle load factor is the most basic constraint for a feasible solution in path planning, but it is not an important deciding factor that affects the result of the optimization search.

Time window factor
Providing services to customers according to the time window as much as possible can improve the service quality of the company and has a positive effect on establishing a good corporate service image. Therefore, it is necessary to consider the impact of time windows on the distribution scheme. Changing the time window penalty factor, the distribution cost changes as shown in Table 7. Table 7 indicate that: if there is no time window, the order of serving customers only affects the distance cost, thus sending 3 vehicles can meet the service demand and the total cost of distribution is lower. As the time penalty factor becomes larger and larger, the demand for service time becomes higher and higher, more vehicles can only be dispatched to carry out distribution tasks at the same time to try to meet the customer time window requirements and reduce the total time cost, thus minimizing the total distribution cost.

Vehicle fixed cost factors
For logistics enterprises, the acquisition cost of each vehicle, the repair and maintenance cost, the average to each vehicle's site rental cost, the labor cost of moving goods, etc. are additional costs to complete each distribution task, which are mainly related to the number of vehicles used, so this paper classifies these costs into vehicle fixed costs. The results are shown in Table 8.    Tables 7 and 8, we could conclude that: 1. The capacity of each vehicle in this calculation is 80, and the total customer demand is 206, so at least 3 vehicles need to be dispatched.
2. In order to meet the time window requirement, companies will choose to send more vehicles, but when the fixed cost of vehicles increases, companies will choose to reduce the number of delivery vehicles, to balance the time window cost and the fixed cost of vehicles. 3. The number of vehicles will not be reduced indefinitely due to the capacity limit. 4. As the number of vehicles decreases, the total number of recharges decreases. On the contrary, the more customer points a vehicle serves, the higher its utilization of power.

Multiple depot electric vehicle routing
The Multiple Depot Electric Vehicle Routing Problem (MDEVRP) is more complex to model and solve as the problem scales up, the difficulty of algorithm optimization also greatly increases. Through References [13 -20], it is found that there are two main solutions (integral method and division method) for the multiple distribution center problem.

Integral method
The integral method is the simultaneous optimization strategy of multiple distribution centers, considers the customer points in the distribution area as an integral whole and the distribution centers as another one. The difference is that for a single distribution center, there is no difference between vehicles because each vehicle has the same parameters and starts from the same starting point and returns to the same end point; however, for a multi-distribution center, although the vehicle parameters of different distribution centers are the same, their starting points and end points are different, so there is a difference between vehicles of different distribution centers. There is a difference between them.

Division method
The division method is to consider the distribution centers as independent individuals, and the customers in the distribution area are divided into several sub-regions according to some classification criteria, and then the distribution centers correspond to the sub-regions one by one, which transforms the multi-distribution centre problem into a single distribution center, and then the solutions obtained from each single distribution center are aggregated to obtain an optimal solution for the MDEVRP problem.

Illustrative example of MDEVRP
In the examples given in this section, numbers 1-45 are customers, numbers 46-55 are charging facilities, and numbers 56-58 are distribution centers. The hybrid geneticparticle swarm algorithm is adopted to solve the two solution ideas with the integral method and the division method, respectively.
1. Integral method test results. The code was written using MATLAB 2016b software, and the number of iterations was set to 3000. The distribution scheme obtained by the algorithm is shown in Table 9 (For clarity, Figs. 5 and 6 show only part of the routes), and the iteration curve of the optimization search process is shown in Fig.4.  Table 9 Fig. 6 Partial visualization of routes in Table 10 The addition of customer nodes, distribution centers, and charging station nodes makes the problem scale up, thus increasing the computational complexity significantly and increasing the time and difficulty of the algorithm to find the best solution. In this test, after 3000 iterations, the algorithm run terminated, resulting in a delivery solution using 11 vehicles with a total delivery cost of 108,500 and a running time of 291 seconds.
2. Division method test results. In this paper, according to the location, demand and time window of customer points, customers 1-19 are assigned to distribution center 1, customers 31-39 are assigned to distribution center 2, and customers 20-30 and 40-45 are assigned to distribution center 3. The single distribution center problem is solved for three distribution centers respectively, and the number of iterations is set to 3000, the algorithm comes up with the distribution scheme as shown in Table 10, and the total cost of completing all tasks require a total of 8 vehicles, the total distribution cost is 62348.9, and the total algorithm operation time is 278 seconds. 57-44-55-2-30-51-57 57- 12-52-33-47-16-52-57 57-41-53-18-52-6-17-7-46-57 57-21-57 57-34-45-32-47-15-26-54-57 57-40-20-54-38-57  56- 14-1-46-15-6-10-11-9-46-56 56-12-4-46-19-17-56 56-16-52-2-18-52-7-3-5-13-8- From theexperimental results of the above test cases, due to the increase in the size of the problem, the optimization time of the algorithm becomes longer, and according to the different principles of the algorithm, the division method can effectively reduce the running time of the algorithm, because this method does not need to traverse all the customer points in each distribution center, thus reducing the complexity of the algorithm. Both the integral method and the division method can effectively solve the multi-distribution center electric vehicle path planning problem proposed in this paper, but the division method obviously has a shorter finding time and lower distribution cost.

Conclusions
In this paper, we study the soft time window electric vehicle path planning problem with charging facilities. The solution was first solved using the algorithm for pure particles, and the test found that the optimization efficiency needs to be improved. Then the genetic-particle swarm algorithm is proposed to make up for the shortcomings of the pure particle swarm algorithm, and it is found that the performance of the algorithm is significantly improved. Finally, the more complex multi-distribution center problem is considered based on single distribution center, and the solution effects of the integral method and the division method are compared, and the conclusion that the division method is faster and has better solution effects is drawn. For the EVRPSTW problem, the future can consider the scenarios of different departure of each vehicle and dynamic changes of customer points, thus making the research more application value.