# An Investigation of Particle Swarm Optimization Topologies in Structural Damage Detection
## 3 Particle Swarm Optimization  
### Basic Model  
The PSO algorithm is inspired by the foraging behavior of birds and it is widely used to solve optimization problems. Each bird in the flock is called a particle, the PSO algorithm contains a population composed of a certain number of particles, and each particle represents a potential solution. All of the particles fly in a \(D\)-dimensional search space, each particle has its own position and velocity, and the fitness function is used to judge its quality. The whole population is randomly initialized, and then each particle evolves toward the best ones through iteration. Suppose that there is a swarm consisting of \(N\) particles in a \(D\)-dimensional search space, and the current position of the particle \(i\) can be expressed as a vector \(X_{i}=(x_{i1},x_{i2},\ldots,x_{iD})^{T}\), \(i=1,2,\ldots,N\); the velocity of the particle \(i\) is \(V_{i}=(v_{i1},v_{i2},\ldots,v_{iD})^{T}\). In the \(t\)th iteration, the particle updates its velocity and position by tracking the personal best position (\(pbest\)) and global best position (\(gbest\)), as follows [25]:  
\[v_{ij}(t+1)=\omega\,v_{ij}(t)\;+\;c_{1}\,r_{1 ij}(pbest_{ij}(t)-x_{ij}(t))\;+ \;c_{2}\,r_{2 ij}(gbest_{j}(t)-x_{ij}(t)) \tag{11}\]  
\[x_{ij}(t+1)=x_{ij}(t)\;+\;v_{ij}(t+1) \tag{12}\]  
where \(t\) is the number of iterations, \(j=1,2,\ldots,D\); \(v_{ij}(t)\) and \(x_{ij}(t)\) are the \(j\)th components of the position and the velocity of particle \(i\) at iteration \(t\), and \(gbest_{ij}(t)\) and \(gbest_{j}(t)\) represent the \(j\)th components of the personal best location and the global best location, respectively. \(\omega\) is the inertia weight, and it reflects the impact of the particle's current velocity on the next iteration. \(r_{1 ij}\), \(r_{2 ij}\) are random numbers that are uniformly distributed between \([0,1]\); \(c_{1}\) and \(c_{2}\) are the acceleration coefficients, \(c_{1}\) controls the tendency of the particle towards its personal best location, and \(c_{1}\) adjusts the trend of the particle approaching the global best location. The particle updates itself by tracking the \(pbest\) and \(gbest\) until the termination criteria are satisfied. During the search process, in order to avoid the invalid search, the position and velocity are limited to a certain interval \([X_{min}\;X_{max}]\) and \([-V_{max}\;V_{max}]\), which are generally set by the user.  
The main steps of the PSO algorithm are given, as follows:  
1. Initialize the position and velocity of the particles.
2. Calculate the fitness value \(S(X_{i})\) (\(i=1,2,\cdots,N\)) using Equation (7).
3. For each particle \(X_{i}\), compare its fitness value \(S(X_{i})\) with the local best location \(S(pbest_{i})\) that it has experienced. If \(S(X_{i})<S(pbest_{i})\), update it as the current personal best position.
4. For each particle \(X_{i}\), compare its personal best fitness value \(S(pbest_{i})\) with the global best fitness value \(S(gbest)\). If \(S(pbest_{i})<S(gbest)\), update it as the current global best position.
5. Adjust the velocity and position of the population according to Equations (11) and (12), also perform the boundary condition.
6. If the algorithm reaches the maximum number of iterations or the minimum value of the fitness function, stop the algorithm, and output the result; if not, go to step (2).