## 2 Methods
### K-PSO Method  
The particle swarm optimization K-means algorithm (KPSO) improves the global search ability of the K-means algorithm and can effectively solve the problem whereby the local convergence of the algorithm and the classification results are affected by the initial clustering center [23]. In the K-PSO algorithm, the particles need to be encoded. In this paper, the coding method based on clustering center is adopted: the position of each particle is composed of the centers of \(K\) rock mass quality classification groups; each particle has a certain velocity \(V\) to adjust its position; in addition, each particle also has a fitness to evaluate the adaptability of the current position of the particle (i.e., the validity of the clustering results). In the process of rock mass quality classification, the fitness of particles is calculated by Equation (4). In this way, each particle represents a possible classification result, and the fitness of the particle is used to evaluate the classification result. Since the rock mass of different sections is divided into \(K\) groups, the position and velocity of the particles are 3 \(\times\)\(K\) dimensional variables. Each particle is encoded using the structure shown in the following Figure 1.  
Figure 1: Particle coding. where \(cj=(cj_{1},\,cj_{2},\,cj_{3})\) represents the center of the \(j\)th cluster (\(1\leq j\leq K\)) and D = \(3\,\times\,K\). The flow chart of the K-PSO algorithm is shown in Figure 2. The specific operation process is described as follows [24; 25; 26]. Step 1: The number of groups \(K\) is determined, which is the initial value of the parameter setting, including learning factor (\(\mu_{1},\,\mu_{2}\)), inertia weight (\(w_{\text{min}},\,w_{\text{max}}\)), and the total number of particles \(N\) in the particle swarm. Step 2: Population initialization. For example, the initialization of particle \(i\) (\(i=1,\,2,\,\ldots\), \(N\)) in the population can be achieved by the following steps: (a) The rock mass of different sections is divided into \(K\) groups, and the clustering center of each group is calculated by eigenvalue analysis method; (b) according to the calculated clustering center of \(K\) group rock mass, the particle position is coded as \(X_{i}=(x_{i1},\,x_{i2},\,\ldots,\,x_{iD})\), and the velocity of randomly initialized particles is \(V_{i}=(v_{i1},\,v_{i2},\,\ldots,\,v_{iD})\); (c) according to the classification results, the fitness \(f(X_{i})\) of the particles is calculated according  
Figure 2: Flow chart of K-PSO method (adapted with permission from Ref. [23] Li, Y.Y. 2015). to Equation (4). Repeating the above steps \(N\) times, a particle swarm containing \(N\) particles can be generated:  
\[POP=\left[ \begin{array}{c}x_{11},x_{12},\cdots,x_{1D},v_{11},v_{12},\cdots,v_{1 D},f(X_{1})\\ x_{21},x_{22},\cdots,x_{2D},v_{21},v_{22},\cdots,v_{2D},f(X_{2})\\ \cdots\\ x_{N1},x_{N2},\cdots,x_{ND},v_{N1},v_{N2},\cdots,v_{ND},f(X_{N})\end{array} \right] \tag{7}\]  
where \((x_{11},x_{12},\ldots,x_{1D})=(c_{11},c_{12},c_{13},c_{21},c_{22},c_{23},\ldots,c_{\text{K1}},c_{\text{K2}},c_{\text{K3}})\) and \(D=3\times\text{K}\). Initialize the individual optimal position \(P_{i}\) of each particle and the optimal position \(P_{g}\) of the population. For each particle \(i\), let \(P_{i}=X_{i}\); comparing the fitness of each particle, the position of the particle with the smallest fitness value is assigned to \(P_{g}\). The position and velocity of particles are updated by Equations (5) and (6). For each particle \(i\), conduct the following operation:  
1. Calculate the distance from the rock mass of different tunnel sections to the K latest clustering centers, and divide the rock mass of the tunnel section into the nearest group;
2. Update the clustering center according to the grouping results;
3. Calculate the fitness value. According to the classification results in Step (5), the position and fitness value of the particles are updated.