# A Particle Swarm and Smell Agent-Based Hybrid Algorithm for Enhanced Optimization
## 2 Hybridization of PSO and SAO Algorithms
For the trailing mode to function, the odor must first evaporate in the agent's direction, followed by the sniffing procedure to determine olfaction capacity, \(O_{f}\), which is calculated as follows [27]:  
\[O_{f}=\frac{f(x_{\text{Agent}})}{\left(\sum_{i=1}^{N}f(x_{i})\right)/N} \tag{5}\]  
where \(f(x_{\text{Agent}})\) is the agent's fitness, \(f(x_{i})\) denotes the fitness of an individual molecule, and \(N\) is the number of molecules. Equation (6) further defines the agent's trailing behavior as follows:  
\[x_{i}^{(t+1)}=x_{i}^{(t)}+r1\cdot O_{f}\cdot(x_{\text{Agent}}^{(t)}-x_{i}^{( t)})-r2\cdot O_{f}\cdot(x_{\text{Wost}}^{(t)}-x_{i}^{(t)}) \tag{6}\]  
where \(r1\) and \(r2\) are random numbers generated at distinct intervals. This trailing mechanism is proposed in our hybrid as an alternative position update strategy instead of the PSO update mechanism defined as follows:  
\[x_{i}^{(t+1)}= \begin{cases}x_{i}^{(t)}+v_{i}^{(t+1)}&\text{if }hf<J_{r}\\ y_{i}^{(t+1)}&\text{if }hf\geq J_{r}\end{cases}  \tag{7}\]  
where  
\[v_{i}^{(t+1)}=v_{i}^{(t)}+c_{1}r_{1}\cdot(\textit{pbest}_{i}^{(t)}-x_{i}^{(t )})+c_{2}r_{2}\cdot(\textit{gbest}_{i}^{(t)}-x_{i}^{(t)}) \tag{8}\]  
and \(y_{i}^{(t+1)}\) is calculated using Equation (6). The value of \(hf\) (termed the hopping frequency) determines whether our hybrid algorithm uses the trailing mode (Equation (6)) or the PSO velocity update equation (Equation (7)). Its value is determined experimentally, and \(J_{r}\) is calculated using the normal distribution in the range (0, 1). Figure 2 presents a flowchart describing the complete working mechanism of the PSO-SAO algorithm. The control parameters, including the swarm size \(n_{pop}\) (i.e., population size), olfaction capacity (\(O_{f}\)), hopping frequency (\(hf\)), coefficient vector, termination criteria \(Iter_{max}\), and initial velocity \(c_{1},c_{2}\), are summarized in Table 2. The pseudocode for the hopping frequency trail update mechanism proposed for use in PSO-SAO is provided in Algorithm 1. The PSO-SAO algorithm is then evaluated to assess its effectiveness using 37 benchmark test functions listed in Table 1.  
```
1:Input:\(n_{pop},nVar,c_{1},c_{2},w,Iter_{max},hf,g_{k},P_{k}\)
2:Initial particles' agent \((P_{agent})\) and particles' worst \((P_{worst})\). 3:for\(k=1\) to \(n_{pop}\)do
4:if\(rand()>hf\)then
5:\(v_{k,m}^{(t+1)}=w\times v_{k,m}^{(t)}+c_{1}\times r_{1}\times(p_{k}-x_{k,m}^{ (t)})+c_{2}\times r_{2}\times(g_{k}-x_{k,m}^{(t)})\)
6:\(x_{j,m}^{(t+1)}=x_{j,m}^{(t)}+v_{j,m}^{(t+1)}\)
7:elseif\(rand()<hf\)then
8: Update \(P_{agent}\) and \(P_{worst}\) from the fitness of initial particles. 9:if\(f(x_{k}^{(t)})<f(P_{agent})\)then
10:\(P_{agent}=x_{i,k}^{(t)}\)
11:elseif\(f(x_{i,k}^{(t)})>f(P_{worst})\)then
12:\(P_{worst}=x_{i,k}^{(t)}\)
13:endif
14:endif
15:\(x_{k,m}^{(t+1)}=x_{k,m}^{(t)}+O_{f}\times r_{4}\times(P_{agent}-x_{k,m}^{(t)})+O_ {f}\times r_{5}\times(P_{worst}-x_{k,m}^{(t)})\)
16:endfor
```  
**Algorithm 1** Hopping frequency mechanism deployed in the PSO-SAO for position update \begin{table}
\begin{tabular}{c c c} \hline \hline
**S/N** & **Initialization Parameters** & **Values** \\ \hline
1 & W\({}_{\max}\) & 0.9 \\
2 & W\({}_{\min}\) & 0.2 \\
3 & C1 & 2 \\
4 & C2 & 2 \\
5 & Olf & 0.75 \\
6 & hf & 0.3 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Proposed algorithm control parameters. Figure 2: Operation of the PSO-SAO algorithm.