Location and Layout of Electric Vehicle Charging Stations Based on K-Means Algorithm

The development of the electric vehicle industry can be promoted by the reasonable layout of electric vehicle charging stations. In this study, the construction of charging piles for new energy vehicles in Guangzhou was discussed. Specifically, the location of the charging pile clustering center was selected using the K-Means clustering algorithm. The K-Means clustering results were analyzed through the elbow method to solve the optimal construction partition of charging piles. Simulation modeling revealed that when k=6, charging piles could be used more conveniently when being about 4.8665 km from the dense flow of new energy vehicles under the clustering center mode compared with the situation at the original distance.


Introduction
China's new energy automobile industry is booming.According to statistics, by the end of 2022, the number of new energy vehicles in China reached 13.1 million, accounting for 4.10% of the total number of vehicles, with an increase of 67.13% [1].With an increasing number of new energy vehicles, the location of charging piles has become an important factor influencing consumers to buy new energy vehicles.Therefore, the optimal layout planning of charging stations is also a current hot issue [2].In this study, taking Guangzhou as an example, the location of the charging pile clustering center was selected using the K-Means clustering algorithm.The K-Means clustering results were analyzed through the elbow method to solve the optimal construction partition of charging piles.

Algorithm Overview
Based on the statistical analysis of the traffic density of new energy vehicles, the charging of new energy vehicles near charging piles was simulated using the K-Means algorithm, followed by the calculation of the spatial-temporal distribution of charging demands.The study area was partitioned using kilometer grids to facilitate the subsequent analysis and calculation.

K-Means algorithm
K-Means is an iterative clustering analysis algorithm [3].The basic idea of this algorithm: (1) K concentrated pieces of data are randomly selected as the initial center; (2) The distance from non-center points to the clustering center is calculated using the Euclidean distance, and the nearest centers form one group; (3) The average distance from non-clustering centers to the clustering center in each group is calculated as a new clustering center; (4) Steps ( 2) and (3) are repeated until the clustering center no longer changes or the maximum number of iterations is reached.
Euclidean distance: The Euclidean distance is mainly used to measure the distance between two points in space.For a given dataset, X = X n = 1, 2, ⋯ , each object in X has m features.
The formula of Euclidean distance:

Elbow method
The elbow method is a way of confirming the optimal K value by using the relational graph between the square sum of errors (SSE) and K values.SSE can also be replaced by the average Euclidean distance between the sample point and the clustering center, so SSE was selected in this study.
where SSE is the square sum of errors,  is the i-th cluster, Q represents the sample point of  , and  stands for the centroid of  .

Modeling
In fact, there is a great demand for urban charging piles.The K-Means clustering analysis has the advantages of fast operation speed and a small amount of calculation, making it suitable for analyzing and processing large sample data and effectively shortening the operation time and improving the operation efficiency.In this study, the data mining clustering algorithm was innovatively combined with the location selection of charging stations.The latitude and longitude coordinates were selected as the calculation data of distance, and the K-Means clustering model and elbow model were established.The solving process was as follows: (1) The data of urban new energy vehicles were organized, and the maximum number M of the charging piles was preliminarily determined on this basis.(2) The distance from the clustering center under K=1 to that under K=M was calculated, and the SSE value corresponding to the K value was solved.(3) The SSE line chart from K=1 to K-M was drawn.If the "elbow" appeared, the corresponding K value was namely the clustering center of charging piles (i.e., the optimal number of charging pile clustering centers), and the charging pile clustering center corresponding to the K value was the optimal charging pile clustering center.Without the appearance of the "elbow", 1 was added to the M value, the central position under K=M and the corresponding SSE value were calculated, and (3) was repeated until the appearance of the "elbow".

Establishment of K-Means clustering model
Users tend to choose the nearest charging station among nearby ones at great probability.The K-Means algorithm measures the similarity between samples based on the Euclidean distance.One piece of data in its cluster category is relatively closer to the clustering center of the current category, so the clustering center can be used as one of the candidate points for charging station construction.Using the distance as a similarity index, the K-Means algorithm finds K categories in the dataset.The center of each category is obtained according to the average value of all the values in the category, and the clustering center is used to represent the center of each category.K-Means clustering aims to minimize the SSE of the implemented clusters, that is, to minimize the loss function whose function is displayed in Formula (3): 3.2 Establishment of the elbow model After cluster analysis, the best cluster number (Kbest) should be determined by the elbow method.The core index of the elbow method is the SSE (as shown in Formula ( 4)), which is used to represent the clustering error.The larger the value is, the higher the clustering fineness and the higher the degree of aggregation of each cluster will be.When the number of simulated clusters satisfies K <Kbest, the SSE will decrease greatly because the increase of each K will increase the aggregation degree of each cluster.When K >Kbest, the aggregation degree of each cluster will tend to be stable with the increase of K, so the SSE will decline stably and then tend to change gently with the continuous increase of K, while the clustering center will tend to remain unchanged.At this time, the position corresponding to the "elbow" is the optimal cluster number (K=K best).
4 Case Analysis In this study, taking Guangzhou as an example, the charging pile clustering center was located using the K-Means clustering algorithm.The K-Means clustering results were analyzed through the elbow method to solve the optimal construction partition of charging piles.The existing dense areas of new energy vehicle traffic in Guangzhou are distributed in a total of 1532 (the specific locations are shown in Figure 1, and the latitude and longitude are shown in Table 1).The location of each demand point is indicated by the latitude and longitude measured and obtained by Baidu Map.(1) Only one-time one-way charging of vehicles is considered, the demand at each demand point is the same, and the K value of the selected charging pile clustering center is 2-10.
(2) The latitude and longitude coordinates are calculated with three digits after the decimal point, the linear distance between two points is calculated by using the latitude and longitude coordinates instead of the actual distance.The latitude and longitude coordinates are converted into the actual distance, with the approximate value of 111 km/arc length per degree selected.
In this paper, programming was performed via Matlab for model solving and clustering.The clustering results of different K values were iteratively obtained.The SEE value under different K values was solved, and a line chart (Figure 2) was drawn.The cost problem should be taken into account in addition to the shortest distance.In the case of a too large number of clustering centers, the initial construction cost of distribution centers was excessively high, thus increasing the later operation cost.Hence, a greater number of centering centers would lead to an increase in costs on the contrary, and more energy from new energy vehicles would be consumed at an ultra-long distance, which went against the concept of green logistics development.Combining the elbow method and the SSE line chart, it could be seen that the broken line continuously declined, and the declining trend was very gentle after K>6, so the optimal number of clustering centers was 6 (partition diagram is seen in Figure 3).Through the new map, the points of clustering analysis were visually analyzed and compared with the location result of the existing charging piles (Figure 4) on the Baidu Map.The clustering centers are displayed in Table 2.The distances from such points to the clustering centers (Figure 5) were randomly extracted, and it could be seen that the optimal number of clustering centers obtained by elbow methodbased location was relatively optimal.Within the coverage of charging piles under K=6, the distance of new energy vehicles from clustering centers shrunk more evidently considering the influencing factors for the dense flow of new energy vehicles.In this study, K=6 was selected as the optimal number of clustering centers through the K-Means clustering algorithm and the elbow method.When K=6, the dense flow of new energy vehicles was about 4.8665 km away from the charging piles under the clustering center mode.

Conclusion
In this study, the current situation, prospects, and shortcomings of electric vehicles as well as factors limiting electric vehicle charging piles were analyzed.An optimal location model for charging piles was designed.This model, which consisted of travel time and waiting time in line, was solved via the K-Means algorithm and MATLAB software.Finally, Guangzhou City was taken as an example for case analysis, and the optimal location of charging piles was acquired.This study on the location selection

Figure 1 .
Figure 1.Some Dense Flow Distribution Points of New Energy Vehicles

Figure 2 .
Figure 2. SSE Line Chart Figure 3. Partition of Charging Pile Construction Points under K=6

Figure 4 .
Figure 4. Cluster Analysis of Charging Pile Distribution Map and Existing Charging Pile Distribution Map

Table 1 .
Latitude and Longitude of Some Dense Flow Areas of New Energy Vehicles

Table 2 .
Clustering Center Points