# Microsseismic Source Location Method and Application Based on NM-PSO Algorithm
## 3 Particle Swarm Optimization (PSO) Algorithm  
The PSO algorithm is a swarm intelligence algorithm in intelligent computing; it finds the optimal solution together through sharing population information and the redistribution under the integration of resources.  
Assume that the search space is \(n\)-dimensional. A population \(x\) = (\(x_{1}\), \(x_{2}\), \(\cdots\), \(x_{m}\)) consisting of m particles, where the position of the \(i\)-th particle is:  
\[x_{i}=\left(x_{i1},x_{i2},\cdots,x_{in}\right) \tag{10}\]  
Its speed is:  
\[v_{i}=\left(v_{i1},v_{i2},\cdots,v_{in}\right) \tag{11}\]  
The optimal position of the \(i\)-th particle is:  
\[p_{i}=\left(p_{i1},p_{i2},\cdots,p_{in}\right). \tag{12}\]  
The optimal global solution is:  
\[p_{g}=\left(p_{g1},p_{g2},\cdots,p_{gn}\right). \tag{13}\]  
The quality of the particle position is measured according to the size of the fitness value. After that, the position and speed of the particle will change based on the optimal position of the individual and the optimal position of the group. Compared with the corresponding optimal position of the group, each iteration will generate a new optimal position to replace the original optimal position, and each particle moves according to the optimal group position obtained by iteration to change its position. At the same time, the movement speed will also change accordingly. After many iterations, the optimal solution to the problem is gradually found. Particles are updated and changed according to the following formula:  
\[v_{id}^{k+1}=v_{id}^{k}+c_{1}\cdot rand()\cdot\left(p_{id}^{k}-x_{id}^{k} \right)+c_{2}\cdot rand()\cdot\left(p_{gd}^{k}-x_{id}^{k}\right) \tag{14}\]  
\[x_{id}^{k+1}=x_{id}^{k}+v_{id}^{k+1} \tag{15}\]  
where \(c_{1}\) and \(c_{2}\) are called learning factors or acceleration factors; \(rand()\) is a random number between (0, 1); \(v_{id}^{k}\) and \(x_{id}^{k}\), respectively, represent particle \(i\) velocity and position in the \(k\)-th iteratiofo \(i\) the \(d\)-th dimension; \(p_{id}^{k}\) is the position of the individual extremum of particle \(i\) in the d-th dimension; \(p_{gd}^{k}\) is the position of the global extremum of the swarm in the \(d\)-th dimension.  
The speed update equation of the PSO algorithm can be regarded as the following three aspects, among which, \(v_{id}^{k}\) is called the previous speed of the particle; the second part is the cognitive part, the acceleration factor \(c_{1}\) can change the step size, and the main function in this part is to make The particle flies to the individual optimal solution; the third part is usually called the social part, the acceleration factor \(c_{2}\) in this part is different from the cognitive part in the step size adjustment, it is mainly for the adjustment of the optimal global solution.  
In order to improve the convergence ability of the PSO algorithm, the optimization of the solution space is more substantial, the inertia weight \(\omega\) is introduced into the PSO algorithm, and the above formula is modified as:  
\[v_{id}^{k+1}=\omega\cdot v_{id}^{k}+c_{1}\cdot rand()\cdot\left(p_{id}^{k}-x_{ id}^{k}\right)+c_{2}\cdot rand()\cdot\left(p_{gd}^{k}-x_{id}^{k}\right) \tag{16}\]  
\[x_{id}^{k+1}=x_{id}^{k}+v_{id}^{k+1} \tag{17}\]  
The process of the PSO algorithm is as follows:  
1. Initialize the particle swarm and set various parameters, including the randomly generated initial position and speed;
2. Select the appropriate fitness function according to the actual problem, and calculate the fitness value of each particle;
3. Compare the current fitness value of the particle with the optimal historical value. If it is better than the optimal historical value, replace its current position with the best position of the particle; If it is the optimal value of the group, its current position will replace the best position of the group;
4. Update the particles according to the formula;
5. If a good enough fitness value is not obtained or the maximum number of iterations is preset, go back to step (2).