# Research and Application of an Improved Sparrow Search Algorithm
## 3 Methods
### Adaptive Weibull Distributed Sparrow Search Algorithm
#### 3.2.3 Multidirectional Learning Strategy  
In Equation (3), when \(f_{i}=f_{g}\), the scout is aware of the danger. If the scout itself is in the current optimal position, it will choose to move to the neighborhood of itself, and if it is not optimal, it will move to the neighborhood of the current optimal position, which reduces the diversity of the population and increases the risk of local optimality in the previous period. In order to overcome this issue, we introduced a multi-directional learning strategy [32] to improve the scout's learning process, increase the algorithm's exploration ability in the search space. As shown in Equation (8) \(f_{a}\), \(f_{b}\), and \(f_{c}\) are the fitness of sparrows at three different points and different weights; \(\tau_{a}\), \(\tau_{b}\), \(\tau_{c}\) are calculated for this purpose. The sparrows with better adaptations occupy a larger proportion, and the comprehensive consideration of the position information of the three sparrows is more conducive for the follower to have a greater chance of exploring the unknown region. The new updated measurements are as in Equation (7):  
Figure 3: Enhanced Search Strategy.  
Figure 2: Original search strategy.  
\[X_{i,j}^{t+1}=\frac{\tau_{a}\cdot X_{a,j}^{t}+\tau_{b}\cdot X_{b,j}^{t}+\tau_{c} \cdot X_{c,j}^{t}}{\tau_{a}+\tau_{b}+\tau_{c}} \tag{7}\]  
\[\left\{\begin{array}{l}\tau_{a}=\frac{f_{a}+f_{b}+f_{c}}{f_{a}}\\ \tau_{b}=\frac{f_{a}+f_{b}+f_{c}}{f_{b}}\\ \tau_{c}=\frac{f_{a}+f_{b}+f_{c}}{f_{c}}\end{array}\right. \tag{8}\]  
After using the above three improvement strategies, the position-update strategy for individual sparrows is as follows (Algorithm 1):  
\[x_{i,j}^{t+1}=\begin{cases}x_{i,j}^{t}\cdot\left(\exp\left(\frac{-i\cdot y}{ \pi\cdot\text{iter max}}\right)\cdot\sin(i)\right)&\text{R}_{2}<ST\\ x_{i,j}^{t}+W\cdot\sigma\cdot L&\text{R}_{2}\geq ST\end{cases} \tag{9}\]  
\[x_{i,j}^{t+1}=\begin{cases}W\cdot\sigma\cdot\exp\left(\frac{x_{\text{worst}}^{ t}-X_{i,j}^{t}}{i^{2}}\right)&i>\frac{u}{2}\\ x_{P}^{t+1}+\left|x_{i,j}^{t}-x_{P}^{t+1}\right|A^{+}\cdot L&i\leq\frac{u}{2} \end{cases} \tag{10}\]  
\[x_{i,j}^{t+1}=\begin{cases}x_{\text{best}}^{t}+W\cdot\sigma\cdot\left|x_{i,j} ^{t}-x_{\text{best}}^{t}\right|&f_{i}>f_{g}\\ \frac{\tau_{a}\cdot X_{i,j}^{t}+\tau_{b}\cdot X_{b,j}^{t}+\tau_{c}\cdot X_{c,j }^{t}}{\tau_{a}+\tau_{b}+\tau_{c}}&f_{i}=f_{g}\end{cases} \tag{11}\]  
```
1:Input: N, PD, SD, ST
2:Output: Fitness, \(X_{\text{best}}\), \(X_{\text{worst}}\)
3:Initialize population
4:\(t=1\);
5:while\(t<iter_{max}\)do
6: Calculate the initial fitness values and sort them to find the current location of the sparrows with the best and worst fitness values.
7:for\(i=1:\) PD\(\cdot\)Ndo
8: Update the position of discoverer based on Equation (9)
9:endfor
10:for\(i=(\)PD\(\cdot\)N\():\)Ndo
11: Update the position of followers based on Equation (10)
12:endfor
13:for\(j=1:\) SD\(\cdot\)Ndo
14: Update the position of scout based on Equation (11)
15:endfor
16:\(t=t+1\);
17:endwhile
18:return Fitness, \(X_{\text{best}}\), \(X_{\text{worst}}\)
```  
**Algorithm 1** Adaptive Weibull Distributed Sparrow Search Algorithm.