## 4 Proposed Method
### CH Selection Stage  
#### 4.1.1 CH Selection Using SO  
In this section, we describe how to use the SO [32] optimization algorithm for optimal cluster head set selection for wireless sensor networks. The suggested algorithm's main goal is to carefully choose CHs from the pool of regular sensor nodes, strategically integrating considerations for energy conservation. This overarching aim is geared towards proactively elongating the network's operational lifetime. An individual in SO symbolizes a whole solution. It represents the ideal locations of the CHs for the proposed algorithm's CH selection. Let \(X=[X_{i,1}(t),X_{i,2}(t),X_{i,3}(t),\ldots,X_{i,D}(t)]\) represent the \(i\)th member of the population, and let \(X_{(i,D)}(t)=(x_{i}d(t),y_{i}d(t)),1\leq i\leq N\), \(1\leq d\leq D\) represent each component's coordinates for the sensor nodes chosen to serve as CH. Every single person has the same number of dimensions represented by the letter \(D\); this corresponds to the quantity of CH. The snakes choose a random position during the exploration phase and adjust their position in relation to it if \(Q<0.25\). The following steps are followed to mimic the exploration phase:  
\[X_{i,m}(t+1)=X_{rand,m}(t)\pm c_{2}\times A_{m}\times((X_{max}-X_{min})\times rand +X_{min}) \tag{6}\]  
Figure 2: ESO-GJO flowchart. The \(i\)th male position is shown by \(X_{i,m}\), the random male position is indicated by \(X_{rand,m}\), and the male's ability to find food is indicated by \(A_{m}\). The calculation for this is as follows:  
\[A_{m}=exp\left(\frac{-f_{rand,m}}{f_{i,m}}\right) \tag{7}\]  
where \(c_{2}=0.05\) is defined, the fitness of \(X_{rand,m}\) is denoted by \(f_{rand,m}\), and the \(i\)th member of the male group's fitness is denoted by \(f_{i,m}\). \[X_{i,f}=X_{rand,f}(t+1)\pm c_{2}\times A_{f}\times((X_{max}-X_{min})\times rand +X_{min}) \tag{8}\]  
where \(A_{f}\) is the female's capacity to locate food and may be computed as follows; a random female's position is indicated by \(X_{rand,f}\); and position of the \(i\)th female is indicated by \(X_{i,f}\). \[A_{f}=exp\left(\left(-f_{(rand,f)}\right)/f_{(i,f)}\right) \tag{9}\]  
In this case, the fitness of \(X_{rand,f}\) is represented by \(f_{(rand,f)}\), and the \(i\)th member of the female group's fitness is denoted by \(f_{i,f}\). The constant coefficient \(c_{3}\) is utilized to update the snake's position throughout the exploiting phase. In this study, instead of using the constant coefficient \(c_{3}\), we use the Brownian motion function to keep the algorithm from reaching a local optimum. One of many physical processes in which a quantity continuously fluctuates between tiny, random fluctuations is called Brownian motion. It is believed that Brownian motion is a Markov process coupled with a Gaussian process. The normal (Gaussian) equation was altered by the algorithm's changes to the size and number of agents, which are used to determine the Brownian motion steps, and the Brownian motion was finalized (Equation (10))  
\[f(\delta)=\frac{1}{\sqrt{2\pi\sigma}}exp\left(-\frac{(\delta-\mu)^{2}}{2\sigma ^{2}}\right) \tag{10}\]  
The following formula can be used to define the temperature Temp. \[Temp=exp\left(\frac{-t}{T}\right) \tag{11}\]  
Here, \(t\) represents the current iteration, and \(T\) signifies the maximum number of iterations. The definition of the quantity of food is \(Q\). The following formula can be used to determine how much food is consumed. \[Q=c_{1}*exp\left(\frac{t-T}{T}\right) \tag{12}\]  
where \(c_{1}=0.5\). If the \(temperature>0.6\), snakes only travel in the direction of food. \[X_{(i,j)}(t+1)=X_{food}\pm f(\delta)\times Temp\times rand\times\left(X_{ food}-X_{(i,j)}(t)\right) \tag{13}\]  
where \(X_{food}\) represents the best individual's position and \(X_{i,j}\) represents the individual's position. The snake will go into either the fighting or mating mode if the temperature is less than 0.6.