## 3 Egyptian Stray Dogs Algorithm
### Mathematical Formulation
As the iterations progress, the territory size is reduced to encourage exploitation over exploration; this is described in Equation (36) below:  
\[E_{i}=F(P_{i}) \tag{26}\]1where \(l\) is the current iteration and \(T\) is the territory size defined in the initialization phase. The algorithm continues to carry out the same sequence until some stopping threshold is reached. This might be a maximum number of iterations or little change in energy values. After reaching this threshold, the algorithm returns the best position and energy found as illustrated in Equation (37):  
\[E_{i}=F(P_{i}) \tag{26}\]2  
This detailed mathematical formulation captures the essential steps and behaviors of the ESDO algorithm, including initialization, position updates, energy evaluations, identification of alpha and beta dogs, and the adjustments based on their leadership. Algorithm 1 describes the pseudo-code and Figure 2 illustrates the detailed flowchart that describes the pseudo-code for the proposed algorithm. Input: Number of dogs \"D\", bounds \"[L,\(l\)]\", maximum number of iterations \"Max_iter\", number of dimensions (variables) \"dim\", Objective function to minimize \"F\" and the Territory size. Output: Best energy found \"TargetEnergy\", Position corresponding to the best energy \"TargetPosition\"  
**Initialization:**  
1. Initialize the optimization problem with solution space bounds [\(L\),\(l\)], number of dogs \"D\" and initial territory size. 2. For each dog i:  
a. Initialize the dog's position \(P_{i,\text{initial}}\) within its territory using Equation (25):  
\[E_{i}=F(P_{i}) \tag{26}\]3  
b. Compute the dog's energy or objective function value \(E_{i,\text{\ initial}}\) using Equation (26):  
\[E_{i}=F(P_{i}) \tag{26}\]4  
**Main Optimization Loop:**  
For L = 1 to Max_iter:  
1. Update Positions and Energies:  
For each dog i:  
* Generate a random number r:  
\[E_{i}=F(P_{i}) \tag{26}\]5
* If r < 0.95: // Explore a new position \(P_{i,\text{new}}\) within its own territory using Equation (27) \[E_{i}=F(P_{i}) \tag{26}\]6
* Else: // Explore a new position \(P_{i,\text{new}}\) outside its own territory using Equation (28) \[E_{i}=F(P_{i}) \tag{26}\]7
* Compute the new energy \(E_{\text{new}}\) for the new position using the objective function. \[E_{i}=F(P_{i}) \tag{26}\]8
* If \(E_{\text{new}}<E_{i}\):  
\[E_{i}=F(P_{i}) \tag{26}\]9  
**Algorithm 1**_Cont._  
2. Update Best-Known Positions and Energies:  
For each dog i:  
* If \(E_{i}<E_{\text{best},i}\):  
\[P_{i,\text{new}}=P_{i}+\text{rand}(0,1)\times\text{ territory\_size}\times(U-L) \tag{27}\]0  
3. Identify Alpha and Beta Dogs:  
* Alpha Dog:  
\[P_{i,\text{new}}=P_{i}+\text{rand}(0,1)\times\text{ territory\_size}\times(U-L) \tag{27}\]1  
* Beta Dog:  
\[P_{i,\text{new}}=P_{i}+\text{rand}(0,1)\times\text{ territory\_size}\times(U-L) \tag{27}\]2  
4. Adjust Positions Based on Leaders:  
For each dog \(i\):  
* If \(E_{i}=E_{\text{best},\alpha}\)  
// If the dog's energy is the same as the alpha dog's energy, it moves towards the alpha dog's position  
\[P_{i,\text{new}}=P_{i}+\text{rand}(0,1)\times\text{ territory\_size}\times(U-L) \tag{27}\]3  
* Else If \(E_{\text{best},\alpha}<E_{i}<E_{\text{best},\beta}\)  
// If the dog's energy is between alpha and beta dogs' energy, it moves towards the beta dog's position:  
\[P_{i,\text{new}}=P_{i}+\text{rand}(0,1)\times\text{ territory\_size}\times(U-L) \tag{27}\]4  
* Else If \(E_{i}>1.5\times E_{\text{best},\alpha}\)  
// If the dog's current energy is significantly higher than the alpha dog's energy, adjust its position closer to the alpha dog  
\[P_{i,\text{new}}=P_{i}+\text{rand}(0,1)\times\text{ territory\_size}\times(U-L) \tag{27}\]5  
5. Adapt Territory Size:  
\[P_{i,\text{new}}=P_{i}+\text{rand}(0,1)\times\text{ territory\_size}\times(U-L) \tag{27}\]6  
6. At pre-defined intervals or iterations, have a subset of the dogs' rest, ensuring that their positions remain unchanged for that iteration. Repeat Main Optimization Loop until a stopping criterion is met.