# A Study on the Vehicle Routing Planning Method for Fresh Food Distribution
## 3 Algorithm Design
### Combining GA with PSO to Solve Double-Layer Model  
The fusion of multiple heuristic algorithms can compensate for the shortcomings of a single algorithm. This paper combines the crossover and mutation operations in a genetic algorithm (GA) with particle swarm optimization (PSO) to improve the convergence speed of the GA and avoid defects of the PSO algorithm falling into local optima. By utilizing crossover and mutation operations in the GA, randomness and diversity are provided for particles in the PSO, while replacing the worst particles with the best chromosomes in offspring, resulting in continuous population evolution. The adaptive hybrid algorithm combining the PSO algorithm and GA (APSOGA) is used to reallocate the location information of backup points in the front warehouse, ultimately determining the facility location of the front warehouse and planning the end path from the front warehouse to the customer point, achieving joint optimization of the front warehouse location and path. 1. Generation of initial solution. The PSO algorithm uses the floating point encoding method to generate two groups of data according to the number of demand points. One group of data is used to determine the corresponding distribution point of the demand point, and the other group of data is used to determine the distribution order of each demand point, to obtain the initial particle position and speed and to calculate the fitness of all particles. This is denoted as \(X_{i}=\{x_{1},x_{2},x_{3},\ldots x_{n-1},x_{n}\}(i\in[1,n])\), where \(X_{n}\) is the particle position, \(V_{i}\) is the particle velocity and \(n\) is the number of particles. 2. Update particle position. In the initial solution, the local optimal particle position (Pbest) and the global optimal particle position (Gbest) of all the current particles are calculated, corresponding to different arrangement orders of customer points. Particle \(P_{i}\) is the local optimal particle with the smallest fitness among the current population particles, that is \[F(P_{i})=\min_{i=1}^{n}\{F(Pbest_{i})\},i\in n\] (27) \(F(P_{i})\) iteratively updates the position of the particle, and its position and velocity are calculated according to Formulas (28) and (29) \[X_{i}^{k+1}=X_{i}^{k}+V_{i}^{k}\] (28) \[V_{i}^{k+1}=\omega V_{i}^{k}+C_{1}\times\text{rand}_{(1)}\times(X_{Pbest}^{k}- X_{i}^{k})+C_{2}\times\text{rand}_{(2)}\times(X_{Gbest}^{k}-X_{i}^{k})\] (29) where \(V_{i}^{k}\) represents the rate of particle \(k\), \(\text{rand}_{(1)}\) and \(\text{rand}_{(2)}\) represent random numbers within the range of 0 to 1, and \(C_{1}\) and \(C_{2}\) represent learning factor constants. \(\omega\) represents the inertia weight, reflecting the ability of particles to inherit previous velocities. After updating the fitness value of the particle, we can recalculate the fitness function value. If the current particle fitness function value is better than \(Pbest_{i}\), we can replace it and use the replacement Formula (30) to update the position of particle. \[F(Pbest_{i})=\left\{ \begin{array}{cc}F(P_{i}),&F(P_{i})<F(Pbest_{i})\\ F(Pbest_{i}),&others\end{array} \right\}\] (30) (3) Selection and crossover of GA We select a particle (Gbest) with the best fitness on a chromosome and a random particle in the existing population to perform a cross operation, generate a random intersection, generate two new offspring particles, calculate the fitness values of the two offspring particles and obtain two new paths. (4) Mutation of GA  
For particles in the offspring chromosome, to avoid high similarity with the parent particle, two solutions of an offspring particle are randomly selected for exchange to obtain a new mutated offspring. (5) Calculation of fitness value  
The optimal solution is found by calculating the fitness value of the particle. For the objective function, minimizing the cost of the cold chain logistics network is more in line with the expectations of the enterprise, so obtaining solutions with smaller objective function values will be prioritized.