# A Study on the Vehicle Routing Planning Method for Fresh Food Distribution
## 3 Algorithm Design
### Generation of Candidate Points for Front Warehouse  
In the front warehouse mode, demand points are scattered everywhere, and the level of demand of the points is determined by forecasting based on the level of demand of the customer points over the years. Using the improved k-means algorithm, the traditional method of calculating the distance between the centroid and the sample is replaced by calculating the distance between the longitude and latitude of two points in the actual front warehouse problem, replacing the Euclidean distance in the traditional algorithm. Traditional site selection uses the maximum coverage model to establish a mathematical model. It is necessary to determine each location of alternative points in advance and then select a location from these alternative points. In this paper, the set coverage model is used to obtain the front warehouse reserve points through improved k-means clustering analysis. For this, a flowchart is shown in Figure 2. The selection of \(K\) values in cluster analysis is evaluated and analyzed based on the clustering effect. The process of k-means clustering analysis is as follows.  
Figure 2: Cluster analysis flowchart.  
Step 1: Import customer point information.  
Step 2: Calculate the distance between the customer point and the cluster center.  
Step 3: Assign customer points to the nearest cluster point.  
Step 4: Update the list of customer points.  
Step 5: If the list of customer points in the region has changed, return to step 3.  
Step 6: Output cluster point center position.  
Step 7: Update the center position of the clustering point until the customer point list remains unchanged.  
Step 8: Output optimal cluster point center position.  
The selection of \(K\) values in k-means clustering analysis is evaluated and analyzed based on the clustering effect. We try to make the distance within each cluster as close as possible and the distance between each cluster as far as possible. When the value of \(k\) is different, we set \(K\) to 5, 6, 7... 10 and calculate the inter-class distance, intra-class distance, number of samples in the maximum cluster and number of samples in the minimum cluster for different clustering results under each \(K\) value. The k-means clustering parameter analysis is shown in Table 2.  
\begin{table}
\begin{tabular}{c c c c c c c c c c c c} \hline \hline \(K\) & **5** & **6** & **7** & **8** & **9** & **10** & **11** & **12** & **13** & **14** & **15** & **16** \\ \hline Intra class distance & 2.37 & 1.93 & 1.73 & 1.62 & 1.42 & 1.36 & 1.31 & 1.26 & 1.21 & 1.19 & 1.08 & 1.12 \\ Inter class distance & 0.7 & 0.72 & 0.75 & 0.73 & 0.78 & & 0.7 & & & & \\ The number of samples in the minimum cluster & 11 & 11 & 11 & 4 & 7 & 5 & 5 & 11 & 1 & 1 & 3 & 1 \\ The number of samples in the maximum cluster & 24 & 25 & 18 & 25 & 17 & 17 & 17 & 25 & 13 & 12 & 11 & 13 \\ \hline \hline \end{tabular}
\end{table}
Table 2: K-means cluster parameter analysis.  
From Table 2, it can be seen that the \(K\) value with the smallest intra-class distance, the largest inter-class distance and the smallest difference in sample size between the maximum and minimum clusters is 15.