# Research on the Causes and Transmission Mechanisms of Railway Engineering Safety Risks
## 2 Model Design
### Multi-Objective Particle Swarm Optimization Algorithm  
This study uses the multi-objective particle swarm optimization algorithm to optimize indicator selection, and the execution process of the algorithm is as follows [23; 24]. Step 1: Establish the initial population. The solution set used to store individual historical solutions within the population is denoted by \(TY_{i}\), and the solution set used to store the entire population is denoted by \(TY_{j}\). The algorithm iteration time step number is set to the total number of particles, which is denoted by \(N^{\prime}\). Binary encoding is performed on a particle \(i\) in the population, where \(x_{i}=[x_{i1},x_{i2},\ldots,x_{ik},\ldots,x_{im}]\), \(x_{i2}=0.1\), and the corresponding solution to \(x_{i}\) is \(F(x_{i})=[F_{1}(x_{i}),F_{2}(x_{i})]\);  
Step 2: Use the random forest algorithm to train the dataset composed of indicator combinations. The random forest algorithm is selected because it performs well in handling imbalanced classification datasets and has been widely used for state recognition;  
Step 3: Use the Euclidean distance to calculate the crowding distance in the entire population solution set \(TY_{j}\), and use the crowding distance to determine the uniformity of the distribution of feasible solutions on the Pareto front. Then, the operations are performed:  
1. Initialize the crowding distance of all individuals in set \(TY_{j}\);
2. For each objective function, sort the individuals in set \(TY_{j}\) according to the size of objective function \(m\), that is, \(Y=sort(F_{i},m)\);
3. For individuals in set \(TY_{j}\), which are at the boundary, set the crowding distance to infinity, that is, \(TY(d_{1})=\infty\), \(TY(d_{2})=\infty\);
4. For individuals outside the boundary, from \(k=2\) to \(k=n-1\), let \[TY(d_{k})=\sum_{m}\frac{TY(k+1)\cdot m-TY(k-1)\cdot m}{f_{m}^{max}-f_{m}^{min }},\] (4) where \(TY(k)\cdot m\) represents the value of the \(m\)th objective function of the \(k\)th individual in set \(Y\). Equation (4) indicates that after sorting according to the objective function value, the crowding distance of individuals in set \(TY_{j}\) represents the sum of differences between the objective function values of the previous and subsequent individuals. Step 4: Select a risk-critical causal combination. Based on the crowding distance, the solution in set \(TY_{i}\) represents the individual, historical, optimal combination of key causes of risks. In set \(TY_{j}\), the global, optimal combination of key causes of risks is selected, and the selection operator uses the widely used roulette wheel method in optimization algorithms. It should be noted that \(\sum_{s=1}^{K}d_{s}\) is the sum of the crowded distances in set \(TY_{j}\). According to the roulette wheel method, the probability of selecting the particles corresponding to group \(s\) of risk causation combinations is expressed by \(\frac{d_{s}}{\sum d_{s}}\). The individual corresponding to the key causal combination of the individual historical risk is denoted by \(i^{\prime}\), and the selected individual in set \(TY_{j}\) is denoted by \(i^{\prime\prime}\);  
Step 5: Cross-operation. Convert the binary code \(x_{i^{\prime}}\) corresponding to an individual \(i^{\prime}\) in set \(TY_{i}\), individual \(x_{i^{\prime\prime}}\) selected from \(TY_{j}\), and the current binary code \(x_{i}\) of particle \(i\) to real code and denote their real encodings by \(x_{i^{\prime}}^{R}\), \(x_{i^{\prime}}^{R}\), and \(x_{i}^{R}\), respectively; \(p_{c}\) is the probability of crossing. The cross-operation refers to the update of individuals in a population from their parents to their children, and the update process is expressed as follows:  
\[\mu_{i}^{R}=(1-p_{c})\cdot x_{i^{\prime}}^{R}+p_{c}\cdot x_{i^{\prime\prime}} ^{R} \tag{5}\]  
\[x_{i^{\prime}}^{R*}=(1-p_{c})\cdot x_{i}^{R}+p_{c}\cdot\mu_{i}^{R} \tag{6}\]Step 6: Mutation operation. Assume that \(p_{m}\) represents the probability of variation and select particles in a particle swarm with a probability \(p_{m}\).