# A Hybrid Bald Eagle Search Algorithm for Time Difference of Arrival Localization
## 3 Proposed Localization Algorithm
### TDOA Localization Implementation Process and Pseudo Code Based on HBES  
This section applies HBES to the WSN localization scenario, solving the nonlinear equations for TDOA localization to derive the estimated coordinates of the unknown nodes. The specific steps and pseudo-code for the implementation of TDOA localization based on HBES are shown below. Step 1: First, the modelling of TDOA localization is started by setting the number of anchor nodes and unknown nodes, randomly generating the coordinates of the anchor and unknown nodes. After that, start the localization and calculate the distance between each node based on the communication time between the nodes. Step 2: Initialize the population using Tent mapping and configure the basic parameters of HBES algorithm such as population dimension \(dim\), the maximum number of iterations \(T\), population size \(N\), population search boundary \(ub\), \(lb\), etc. Step 3: Calculate the search space of the current population and return the individuals that exceed the search space. Step 4: Calculate the fitness of each individual in the population and rank them; record the current best fitness value. Step 5: Introduce the Levy flight to promote the algorithm ability of global search and perform a global search of the initialized population of individuals according to Equation (20) with the HBES algorithm, after which the fitness values of the individuals in the population are ranked to complete a phase of position updating. Step 6: Then, the search mechanism of the positive cosine algorithm is added to perform the local search of the HBES algorithm, and the spatial prey phase of the HBES algorithm is entered according to Equation (27), followed by the spiral search phase according to Equation (13). Step 7: Finally, expand a set of reverse populations and calculate the fitness of the reverse populations, selecting the updated populations and the individuals with the highest fitness in the reverse populations. Step 8: Repeat steps 3-7 until the number of iterations reaches a maximum or the overall extreme accuracy value meets a predetermined minimum accuracy value to obtain the optimal coordinates for the TDOA localization model. Pseudo code of HBES-based TDOA positioning process is shown in Algorithm 1. ```
Input: Number of Population \(N\), Population dimension dim, Search the upper bound ub, Search the Lower lb, Maximum iteration, Number of anchor nodes \(n_{1}\) and unknown nodes \(n_{2}\); Initialization: Initial population by tent mapping, randomly generating the coordinates of the anchor nodes and unknown nodes;
1. Calculated the fitness of individuals in the initial population by Equation (7);
2. Select the individuals with the best fitness in the initial population \(P_{best}^{t}\);
3. While iterations < \(T\)
4. for\(i=1\):\(P\)
5. \(P_{i,new}=P_{best}+\alpha\times r(P_{mean}-P_{i})\times Levy\)
6. if fitness \(\left(P_{i,new}\right)<\) fitness \(\left(P_{best}^{t}\right)\)
7. \(P_{best}^{t}=P_{i,new}\)
8. end if
9. end for
10. for\(i=1\):\(P\)
11. if rand < 0.5
12. \(P_{i,new}=\omega P_{i}^{t}+r\times\sin(r_{2})\times\left|r_{3}P_{mean}^{t}-P_{ i}^{t}\right|\)
13. else if rand >= 0.5
14. \(P_{i,new}=\omega P_{i}^{t}+r\times\cos(r_{2})\times\left|r_{3}P_{mean}^{t}-P_{ i}^{t}\right|\)
15. end if
16. if fitness \(\left(P_{i,new}\right)<\) fitness \(\left(P_{best}^{t}\right)\)
17. \(P_{best}^{t}=P_{i,new}\)
18. end if
19. for\(i=1\):\(P\)
20. \(P_{i,new}=rand\times P_{best}+x1(i)\times\left(P_{i}-c1\times P_{mean}\right)+y1 \times\left(P_{i}-c2\times P_{best}\right)\)
21. if fitness \(\left(P_{i,new}\right)<\) fitness \(\left(P_{best}^{t}\right)\)
22. \(P_{best}^{t}=P_{i,new}\)
23. end if
24. end for
25. Generating reverse population \(P_{back}\) by Equation (28)
26. Calculated the fitness of individuals in the reverse population by Equation (7);
27. Select the individuals with the best fitness in the initial population \(P_{back}^{t}\);
28. if fitness \(\left(P_{best}^{t}\right)<\) fitness \(\left(P_{best}^{t}\right)\)
29.