# Analyzing Physics-Inspired Metaheuristic Algorithms in Feature Selection with K-Nearest-Neighbor
## 2 Methodology
### Physics-Inspired Metaphor Algorithms
#### 2.3.6 Equilibrium Optimizer (EO)  
Control volume mass balance models, which are used to estimate both dynamic and equilibrium states, serve as an inspiration for the Equilibrium Optimizer (EO), a recently proposed physics-inspired algorithm [34]. The particles are considered to be the solutions, and their positions map the concentration of the particles. This algorithm constructs an equilibrium pool of five reference solutions (four best so-far particles and one arithmetic mean of them) called equilibrium candidates. Each particle updates its position with reference to a randomly selected candidate from the pool. The algorithm is aided by two carefully designed parameters called the exponential term (\(F\)) and the generation rate (\(G\)). Moreover, a concept of memory saving is used, which allows a solution to update its concentration only if it improves as compared to its previous concentration. The exploration, exploitation, and the balance between them are controlled through these parameters: the equilibrium pool and the generation probability. EO uses a mass-balance equation to describe the conservation of mass within a system. The generic mass-balance equation is given as:  
\[V\frac{dC}{dt}=QC_{\{eq\}}-QC+G \tag{30}\]  
where \(V\frac{dC}{dt}\) represents the rate of change of mass in a control volume, \(Q\) is the flow rate, the concentration at an equilibrium state is denoted by \(QC_{\{eq\}}\), and \(G\) mimics the mass generation rate. Here, \(\frac{dC}{dt}\) can also be solved in terms of \(\mathcal{\tilde{P}}\) and \(\mathcal{\tilde{P}}\) denoted by \(\lambda\) or the turnover rate (i.e., \(\lambda=\mathcal{\tilde{P}}\)). Therefore, the above equation can be reconstructed as:  
\[\frac{dC}{\lambda C_{\{eq\}}-\lambda C+\mathcal{\tilde{P}}}=dt \tag{31}\]  
By taking the integration of the above equation, we obtain:  
\[C=C_{\{eq\}}+\Big{(}C_{0}-C_{\{eq\}}\Big{)}F+\frac{G}{\lambda V}(1-F) \tag{32}\]  
which is used as an updating rule for each particle, where \(F\) is calculated as follows:  
\[F=\exp[-\lambda(t-t_{0})] \tag{33}\]  
where \(t_{0}\) and \(C_{0}\) represent the initial start time and concentration. In this algorithm, each particle is a solution, and its position represents its concentration. The mathematical formulation of EO is discussed in the following steps. Initialization and function evaluation: The first step is to initialize the particles' concentration according to the following equation:  
\[X_{\{m\}}^{\{init\}}=X_{\{min\}}+rand_{m(X_{\{max\}}-X_{\{min\}})} \tag{34}\]  
where \(X_{\{m\}}^{\{init\}}\) represents the initial concentration of the \(m^{\text{th}}\) particle, \(X_{\{max\}}\) shows the maximum, and \(X_{\{min\}}\) shows the minimum values. Equilibrium pool and candidates \(X_{\text{e}}\): In this algorithm, four equilibrium candidates (good solutions) are determined to guide other particles and promote exploration. Moreover, a particle constructed by taking the arithmetic mean of all these candidates is also used, which promotes exploitation. These candidates are then assembled to form an equilibrium pool. Each particle updates its position with respect to a randomly selected candidate from the pool. Exponential term (E): This term is used in position updating to balance exploration and exploitation. The exponential term is computed as follows:  
\[E=e^{\{-\{\lambda\}(t-t_{0})\}} \tag{35}\]  
where \(t\) and \(t_{0}\) are computed by following equations, respectively:  
\[t=\Big{(}1-\frac{Iter}{Max\_iter}\Big{)}^{\{(\frac{\epsilon_{2}Iter}{Max\_iter })\}} \tag{36}\]  
\[t_{0}=\frac{1}{\lambda}\ln\Big{(}-a_{1}sign(\{r\}-0.5)\Big{[}1-e^{\{-\{\lambda \}t\}}\Big{]}\Big{)}+t \tag{37}\]  
In the above equation, a large value of \(a_{1}\) promotes exploration, and a large value of \(a_{2}\) promotes exploitation. The \(sign(\{r\}-0.5)\) controls the direction of exploration and exploitation.