## 4 Stepwise Process Enclosed in Proposed Research
### First Stage: Design of Optimal Routing Protocol
#### 4.2.3 Election of Grid Organizer Based on Salifish Optimization
* Step 3: Attack-alteration approach The sailfish can attack in every direction as a shrinking circle, and they keep updating their position according to the position of the prey. The new position of the sailfish can be represented as follows:  
\[Z^{i}_{\text{new\,SF}}\,=\,Z^{i}_{\text{elite\,SF}}\,-\,\delta_{i}\,(\text{rand} (0,1)\,(\frac{Z^{i}_{\text{elite\,SF}}+Z^{i}_{\text{injure\,S}}}{2})\,-Z^{i}_{ \text{old\,SF}}) \tag{7}\]  
Equation (7), \(Z^{i}_{\text{elite\,SF}}\) represents the position of elite sailfish at the \(i_{\text{th}}\) iteration, rand(0,1) is the random number, \(Z^{i}_{\text{injure\,S}}\) represents the position of the injured sardine at the \(i\)th iteration, \(Z^{i}_{\text{old\,SF}}\) denotes the current position of the sailfish, and \(\delta_{i}\) represents the coefficient, which can be calculated as follows:  
\[\delta_{i}=2\,\text{rand}\,(0,1)\,\text{PD}\,-\,\text{PD} \tag{8}\]  
PD is the density of the prey, which means the number of prey present at every iteration, and the PD can be calculated as follows:  
\[\text{PD}=1+(\frac{N_{\text{SF}}}{N_{\text{SF}}+N_{\text{S}}}) \tag{9}\]  
In Equation (9), \(N_{\text{SF}}\) is the number of sailfish and \(N_{\text{S}}\) represents the number of sardines in each iteration. * Step 4: Attacking Prey  
Subsequently, in this step, the current position of the sardine gets updated. The new position of the sardine can be obtained using (10). \[Z^{i}_{\text{new\,S}}=\tau\,(Z^{i}_{\text{elite\,SF}}-Z^{i}_{\text{old\,S}}+ \text{AP}) \tag{10}\]  
where \(Z^{i}_{\text{elite\,SF}}\) denotes the best position of elite sailfish, \(Z^{i}_{\text{old\,S}}\) denotes the current position of sardine, r is a random number in the range 0 and 1, and AP denotes the attack power of the sailfish. The updating process continues until convergence is achieved. A flow chart explaining the sequences of the sailfish optimization algorithm is shown in Figure 3.  
Figure 3: Flow chart of sailfish optimization. Salifish Optimizer for Choosing Grid Organizers  
The grid organizer among the grid members was selected using the sailfish optimization algorithm. As explained previously, the elected grid organizer is the head of the grid cluster for a particular period. After a certain period, the election process of the grid organizer commences once again. The steps followed in the sailfish optimization for the election of the grid organizer are described below. * Step 1: Initialization  
The population considered for the analysis was initialized at this stage. Generally, the variables related to the problem are termed population or candidate solutions. The variables considered for our research problem are the residual energy of the sensors and the distance between the nodes and sink. The mathematical expression used to represent the population initialization is given by Equation (11). \[ \begin{array}{l}\mathrm{D}=\left\{\mathrm{d}_{1},\mathrm{d}_{2},\mathrm{d }_{3}\ldots\mathrm{d}_{n}\right\}\\ \mathrm{RS}=\left\{\mathrm{rs}_{1},\mathrm{rs}_{2},\mathrm{rs}_{3}\ldots\mathrm{ rs}_{n}\right\}\end{array}  \tag{11}\]  
Equation (9), \(\mathrm{d}_{n}\) represents the population of the distance between nodes and \(\mathrm{rs}_{n}\) represents the population of residual energy in nodes. * Step 2: Fitness Function  
Based on the initialized population, the fitness function can be represented as follows:  
\[\mathrm{fitness}=\left\{ \begin{array}{c}\mathrm{maximize}(\mathrm{RS})\\ \mathrm{minimize}(\mathrm{D})\end{array} \right\} \tag{12}\]  
According to this equation, the fitness function for this optimization problem is to maximize the residual energy in the sensors and minimize the distance between the sensor nodes. * Step 3: Updating  
The values of distance and residual energy related to nodes get updated in each iteration to find the best solution within the search space. * Step 4: Termination  
The search process was terminated once the required criteria were satisfied. A grid organizer is selected for each grid by performing the optimization protocol.