# A Dynamic Edge Server Placement Scheme Using the Improved Snake Optimization Algorithm
## 4 Dynamic Edge-Server Placement
### ISO Algorithm
#### 4.2.3 Elite Leadership Strategy  
The SO algorithm incorporates a certain probability that the snakes will produce eggs after mating, i.e., that the worst solution will be replaced by a randomly generated solution. However, the blindness of the randomized solution reduces the ability of the algorithm to find the optimal solution quickly. Therefore, the elite leadership strategy is adopted in this study. This strategy replaces the 10% of the individuals with the lowest fitness in the algorithm to increase the probability of finding the optimal solution. The equations are  
\[X_{i,m}(t+1) =X_{i,m}(t)+r_{1}\times(X_{m,gbest}-X_{i,m}(t)) \tag{44}\] \[X_{i,f}(t+1) =X_{i,f}(t)+r_{1}\times(X_{f,gbest}-X_{i,f}(t)), \tag{45}\]  
where \(X_{m,gbest}\) and \(X_{f,gbest}\) denote the optimal individuals among all males and females, respectively. This improvement can avoid the blindness of the random solution, improve the algorithm convergence speed and quality, and increase the probability of finding the optimal solution.  
Figures 5 and 6 visualize this strategy. The position distributions of 11 individuals at a given moment are shown. The blue snake represents the best-adapted individual, the brown snakes represent the individuals with fitness values in the bottom 10%, and the remaining individuals are represented by green snakes. When the elite leading strategy is used, the brown-snake position changes as shown in Figures 5 and 6. The blue line in Figure 5 indicates that the individual is moving closer to the best-performing individual; the orange line indicates the movement direction and distance of the individual. Figure 6 shows the position distribution of the individuals following the movement of those with fitness values in the bottom 10%. The original best-performing individual is now classed among the remaining individuals, and some of the original remaining individuals are now among the individuals with fitness values in the bottom 10%.  
The time complexity of the SO algorithm is O(TNd). The time complexity of combining with the PSO algorithm is O(N). The bidirectional search strategy does not increase the time complexity. The time complexity of the elite leading strategy is O(Nd). In conclusion, the final time complexity of the ISO algorithm is O((T + 1)Nd + N). Algorithm 1 describes the optimization process of the ISO algorithm.  
```
0: Maximum number of iterations, population size, etc.
0: Optimal value
1: Initialize the edge server location
2:while\((t<T)\)do
3: Calculate temp, Q, Xworst_m, Xworst_f, pBestm, gBestm, pBestf, gBestf
4:if\((Q<Threshold1)\)then
5: Find food, update position according to Equations (38) and (39)
6:else
7:if\((Q>Threshold2)\)then
8: Move towards food and update position according to Equations (42) and (43)
9:else
10:if\((rand>0.6)\)then
11: Enter combat mode and update position according to Equations (28) and (29)
12:else
13: Enter mating mode and update position according to Equations (32) and (33)
14: Select whether to hatch or not; if hatching, update the position according to Equations (44) and (45)
15:endif
16:endif
17:endif
18:endwhile
```  
**Algorithm 1** Improved Snake Optimization Algorithm