# Predicting the External Corrosion Rate of Buried Pipelines Using a Novel Soft Modeling Technique
## 2 Materials and Methods
### PSO Algorithm  
The particle swarm optimization (PSO) algorithm is an intelligent optimization algorithm inspired by the group predatory nature of organisms [43]. The technique considers the mismatch between particles in the swarm and their previous error paths. Through iterative minimization of the cost function, PSO can solve the optimization problem. PSO exhibits flexibility due to its parameterization, allowing for the customization of velocity and acceleration update rules [44]. Different variants of this algorithm can be obtained by modifying the way the particle velocities and accelerations are described. This approach provides optimal solutions based on threshold conditions [45; 46; 47]. The PSO algorithm flow chart is shown in Figure 2.  
Consider a swarm of particles (containing \(N\) particles) flying and searching simultaneously in a D-dimensional space. The attributes of each particle at different times are defined as follows, where \(1\leq d\leq D,1\leq i\leq N\):  
\[x_{id}^{t}=\left(x_{11}^{t},x_{i2}^{t},\cdots,x_{id}^{t}\right)^{T},x_{id}^{t} \in\left[L_{d},U_{d}\right] \tag{13}\]  
\[V_{id}^{t}=\left(V_{i1}^{t},V_{i2}^{t},\cdots,V_{id}^{t}\right)^{T},V_{id}^{t} \in\left[V_{dmin},V_{dmax}\right] \tag{14}\]  
\[P_{i}^{t}=\left(P_{i1}^{t},P_{i2}^{t},\cdots,P_{iD}^{t}\right)^{T} \tag{15}\]  
\[P_{g}^{t}=\left(P_{g1}^{t},P_{g2}^{t},\cdots,P_{gD}^{t}\right)^{T} \tag{16}\]  
In this context, Equation (13) represents the position of the \(i\) particle at the \(t\) iteration, where \(L_{d}\) and \(U_{d}\) are the lower and upper bounds of the D-dimensional space, respectively, and \(t\) denotes the current iteration number. The particle's velocity can be calculated using Equation (14), where \(V_{dmin}\) and \(V_{dmax}\) represent the lower and upper bounds of the velocity in the d dimension. Equation (15) represents the best position found by the \(i\) particle during its search process, while Equation (16) represents the global best position found by the entire swarm.  
Equations (17) and (18) represent the position and velocity of the particle at the \(t+1\) iteration, respectively.  
\[x_{id}^{t+1}=x_{id}^{1}+v_{id}^{t+1} \tag{17}\]  
\[v_{id}^{t+1}=v_{id}^{t}+c_{1}r_{1}\left(p_{id}^{t}-x_{id}^{t}\right)+c_{2}r_{2 }\left(p_{gd}^{t}-x_{id}^{t}\right) \tag{18}\]  
In these equations, \(v_{id}^{t}\) represents the velocity of the \(i\) particle in the \(d\) dimension at the \(t\) iteration; \(x_{id}^{t}\) represents the position of the \(i\) particle in the \(d\) dimension at the \(t\) iteration; \(r_{1}\) and \(r_{2}\) are random numbers uniformly distributed in the range \([0,\ 1]\); \(c_{1}\) and \(c_{2}\) are acceleration coefficients, which are typically set to \(c_{1}=c_{2}=2\) based on empirical experience; \(p_{id}^{t}\) represents the individual best position of the \(i\) particle in the \(d\) dimension at the \(t\) iteration; and \(p_{sd}^{t}\) represents the global best position in the \(d\) dimension.  
The implementation process of the PSO algorithm is as follows:  
Step 1: Set the parameters and population size and initialize the velocity and position of all particles in the population.  
Step 2: Calculate and evaluate the fitness of each particle in the population.  
Step 3: Update the current best position (\(p_{ib}\)). Compare the fitness value of the particle in Step 2 with the best historical position. Update to the current optimal position if it is better; otherwise, leave it unchanged.  
Step 4: Update the best global position (\(p_{g}\)). Compare the fitness value of the particle in Step 2 with the best historical global position. The global optimum is updated using the current value if it is better than the historical optimum; otherwise, it remains unchanged.  
Step 5: Update the velocity and position of individual particles.  
Step 6: Judge whether the algorithm is over or not. If the end condition is satisfied, the algorithm ends; in other cases, it returns to Step 2.