## 2 Materials and Methods
### Unsupervised Clustering Algorithm Based on Adjacent Grid Search  
During the milling of large aviation structural parts, due to the lack of off-line testing to provide necessary prior knowledge, unsupervised pattern recognition has become a priority, and clustering is a commonly used unsupervised pattern recognition algorithm. In this paper, a clustering algorithm based on adjacent grid search (CAGS) is established. This algorithm can automatically identify the number of clusters, find clusters of arbitrary shape, process noise data, process high-dimensional data, process large-scale data and minimize a priori knowledge. The algorithm flow is shown in Figure 4.  
A multidimensional space \(S^{d}\) is composed of multiple orthogonal continuous dimensions. A sample point set \(D^{d}\) is distributed in \(S^{d}\):  
\[D^{d}=\left\{D_{1}^{d},D_{2}^{d},\cdots,D_{d}^{d}\right\} \tag{8}\]  
where \(D_{i}^{d}\subset S_{i}^{d}\) is the x-dimensional distribution state of \(D^{d}\) in \(S^{d}\). Usually, multidimensional sample sets are discrete, finite and uneven. The multidimensional sample set also has another representation:  
\[D^{d}=\left\{X_{1}^{d},X_{2}^{d},\cdots,X_{N}^{d}\right\} \tag{9}\]  
where \(N\) is the sample set size, the total number of samples in the sample set, and \(X_{i}^{d}\) is the \(i\)th sample in \(D^{d}\). The distribution of the sample set in \(S^{d}\) identifies a finite d-dimensional space, which is gridded using a monotonic scale sequence, the expression is as follows:  
\[SC_{i}^{D}=\left\{SC_{i}^{D}(0),SC_{i}^{D}(1),\cdots,SC_{i}^{D}(k)\right\} \tag{10}\]where \(SC_{i}^{D}(k)\) represents the \(k+1\)st hyperplane in the \(i\)th dimension in a finite d-dimensional space. The multidimensional grid space generated after the multidimensional space segmentation is expressed as:  
\[G^{D}=\left\{C_{1}^{D},C_{2}^{D},\cdots,C_{i}^{D}\right\} \tag{11}\]  
where \(C_{i}^{D}\) is the \(i\)th cell in grid space \(G^{D}\) and each cell is a super rectangle in \(G^{D}\). At the same time, cell \(C_{i}^{D}\) also has the following attribute values:  
\[C_{i}^{D}=\left\{location,member,density\right\} \tag{12}\]  
where location is the coordinate of the cell in the grid space; member is a member of a cell, that is, a set of sample points within the cell; and density is the density value of the cell, that is, the number of sample points within the cell range. After the above steps, we will treat the grid as follows:  
1. Kill (delete) all empty cells with density of 0;
2. Realign all the remaining non-empty cells from large to small by density;
3. Set glow threshold \(threeH\) and define the cells with a density less than that threshold as the halo cells; define the density Cells greater than or equal to this threshold as core cells. The halo threshold is calculated by the following equation:  
\[threeH=\frac{\sum_{i=1}^{M}density\big{(}C_{i}^{D}\big{)}}{M}f_{H} \tag{13}\]  
Figure 4: Flow chart of the CAGS algorithm. where \(f_{H}\) is the halo coefficient and \(M\) is the total number of cells. In this paper, an adjacent grid search method is used to realize grid clustering. In a multidimensional grid space \(G^{D}\) constructed for a multidimensional sample set \(D^{d}\), the cell coordinates adjacent to a cell \(C_{i}^{D}\) can be obtained by the following equation:  
\[location\left(AC_{i}^{D}\right)=location\left(C_{i}^{D}\right)+Aopt^{d} \tag{14}\]  
where \(AC_{i}^{D}\) is the adjacent cell of \(C_{i}^{D}\), also known as adjacent grid. \(Aopt^{d}\) is a d-dimensional adjacent operator:  
\[Aopt^{d}=\left\{L_{1}^{d},L_{2}^{d},\cdots,L_{T}^{d}\right\}-0 \tag{15}\]  
where \(L_{T}\) is the d-dimensional coordinate vector arranged in a symmetric triad in ascending order. \(T=3^{d}\), the symbol \"\(-\)\" represents the set seeking the difference, and 0 represents a d-dimensional null vector. The formal clustering process falls into two stages: traversal of core cells and processing of halo cells. In the first stage, the cells sorted by density are traversed successively to find the core of each cluster.