# Efficient Feature Selection Using Weighted Superposition Attraction Optimization Algorithm
## 2 Methodology
### Metaheuristics
#### 2.3.3 Particle Swarm Optimization  
The PSO is a metaheuristic optimization algorithm which is inspired by the swarm behavior observed in birds or schools of fish [13]. Any of the observable vicinities of a bird in nature are limited to a given range. But having many birds enables all birds in a swarm to be cognizant of the larger area of a fitness objective/function. Every particle in the swarm optimization has a fitness value, velocity and an associated position. Every particle also keeps track of the particle's best fitness value, and a set of global best fitness values is maintained [42; 43]. The mathematical model for PSO is represented using Equation (3).  
\[P_{i}^{t}=\left[x_{0,i}^{t},x_{1,i^{\prime}}^{t},x_{2,i^{\prime}}^{t},x_{3,i^{ \prime}}^{t},\ldots,x_{n,i}^{t}\right] \tag{3}\]where \(P_{i}^{t}\) is the position of \(i\)th particle in \(t\)th iteration.  
```
Objective function \(f(x)\), \(x=(x_{1},\ x_{2},\ldots,x_{d})\) Initialize population \(G=0\); Initialize all \(NP\) individuals WHILE Iterations \(<\) Maximum Iterations FOR \(i\gets\ 1\) to \(NP\) WHILE need to generate more offspring IF population size \(<k\) then Refill: move all individuals from the temporary population \(T\) to population \(S\) END IF sampling \(k\) individuals without replacement from population \(S\) select the winner from the tournament move the \(k\) sampled individuals into temporary population \(T\) return the winner END \(Iterations=Iterations+NP\) END \(G=G+1\) END
```  
**Algorithm 3**Genetic algorithm (tournament selection)  
When a particle is involved in a population like its topological neighbors, it results in a value referred to as local best. Once the best two values are obtained, the particle updates its velocity and location using the following equations [44]:  
\[P_{i}^{t+1}=P_{i}^{t}+V_{i}^{t+1} \tag{4}\]  
\[V_{i}^{t+1}=wV_{i}^{t}+c_{1}r_{1}\left(P_{\text{best}(i)}^{t}-P_{i}^{t}\right) +c_{2}r_{2}\left(P_{\text{bestglobal}}^{t}-P_{i}^{t}\right) \tag{5}\]  
where \(V_{i}^{t}\) is the velocity of \(i\)th particle in \(t\)th iteration, \(P_{\text{best}(i)}^{t}\) is the best position of \(i\)th particle in \(t\)th iteration, \(P_{\text{bestglobal}}^{t}\) is the best position obtained so far among all particles until \(t\)th iteration, \(r_{1}\) and \(r_{2}\) are random numbers in the range [0, 1], and \(c_{1}\) and \(c_{2}\) are the user-defined parameters.  
The pseudocode for PSO can be represented as shown in Algorithm 4.  
```
Objective function \(f(x)\), \(x=(x_{1},\ x_{2},\ldots,x_{d})\) Initialize population FOR \(t=1:\ max\ generation\) FOR \(i=1:\ N\) If \(f(x_{i,d}(t))<f(p_{i}(t))\) then \(p_{i}(t)=x_{i,d}(t)\), \(f(p_{g}(t))=min_{t}\,f(p_{i}(t))\) END FOR \(d=1:\ d\) \(v_{i,d}(t+1)=wv_{i,d}(t)+c_{1}r_{1}\left(p_{i}-x_{i,d}(t)\right)+c_{2}r_{2} \left(p_{g}-x_{i,d}(t)\right)\) \(x_{i,d}(t+1)=x_{i,d}(t)+v_{i,d}(t+1)\) IF \(v_{i,d}(t+1)>v_{max}\) THEN \(v_{i,d}(t+1)=v_{max}\) ELSE IF \(v_{i,d}(t+1)<v_{min}\) THEN \(v_{i,d}(t+1)>v_{min}\) THEN \(x_{i,d}(t+1)>v_{max}\) THEN \(x_{i,d}(t+1)=x_{max}\) IF \(x_{i,d}(t+1)<x_{min}\) THEN \(x_{i,d}(t+1)=x_{min}\) END END
```  
**Algorithm 4**Particle swarm optimization