## 2 K-means Clustering Based EVs Classification  
### Introduce of K-means Clustering Algorithm  
The K-means algorithm is an iterative clustering algorithm that uses distance as a similarity indicator to discover K classes in a given data set, and the center of each class is based on the mean of all values in the class, each of which is described by the clustering center. For a given data set \(x\) containing n D-dimensional data points and the category K to be divided, the Euclidean distance is selected as the similarity index, and the clustering target is to make all kinds of clustering squared and minimum, that is, to minimize:  
\[J=\sum_{k=1}^{k}\sum_{i=1}^{n}\|x_{i}-u_{k}\|^{2}. \tag{1}\]  
According to the least square method and Lagrange principle, the clustering center is the average of each data point in the corresponding category, and in order to make the algorithm converge, the final clustering center should be kept as constant as possible in the iterative process.  
In this paper, the traditional K-means algorithm is modified to suite the control strategy proposed in Section 3, the flow of the modified K-means algorithm is as Figure 1 shown, which can be divided into six stages:  
1. Create a D-dimensional data array and import the original data;
2. Adding K virtual standard points to a data space, Different standard points are spaced at a certain distance D. Select the K virtual standard points as the initial clustering center;
3. For other objects in the data space, calculate to their Euclidean distance by using Equation (1) from those clustering centers.
4. According to the Euclidean distance, the objects in the D-dimensional space are divided into several classes corresponding to their closest clustering center;
5. Update Clustering Center: The mean value of all objects in each category are defined as the new clustering center. The value of the objective function is calculated by using the clustering center of the class.
6. Go back to step 3, calculate the distance between all objects with new clustering center, calculate new clustering center again. If the values of the clustering center have changed, then go back to step 3 again. If not, output results.  
Because the EVs access to the power grid have a wide range of randomness and uncertainty in time and space, it is difficult to effectively manage such a huge number of random events at the same time period. Therefore, it is necessary to find a way to classify and manage these EVs according to their characteristic attributes. In this paper, a large number of EVs are classified by using the K-means classification method, the EVs are classified according to their battery SoC and average vehicle daily travel (AVDT) respectively at the first, then reorganize the EV groups by merging the EVs with the same SoC and AVDT miles into one single group. By doing so, A big electric vehicle group is divided into several sub EV groups, each sub EV group contains EVs with the same SOC and AVDT classes. The flow chart of the proposed EVs clustering strategy can be described as Figure 2 shown:  
Figure 1: The calculation principle of the K-means clustering algorithm.2.2 eclectic vehicles (EVs) clustering strategy.  
Figure 2: K-means based EVs clustering strategy.