# W-GUN: Whale Optimization for Energy and Delay-Centric Green Underwater Networks
## 3 Green Underwater Sensor Network Framework using Adapted Whale and Wolf Optimization
### The Pseudo-Code for the Proposed W-GUN Framework  
In Algorithm 1, a few of the major operations of the optimization model are detailed. In steps one and two, initialization of the optimization model is performed, which is basically a constant time operation depending on the population size \(M_{x}\). In step two, the fitness function for the optimization model is calculated using Equation (1). In step five, whale optimization is considered for better underwater relay node selection. The exploration and exploitation of whale optimization is enhanced in step six via the wolf optimization method. In steps 10-13, we prioritize the three best solutions as the most recent solutions at each optimization iteration. In steps 17-31, the whale optimization-based iterative search is performed for selecting underwater relay nodes. In steps 35-38, the wolf optimization-based search is performed for enhancing the exploitation and exploration of the whale approach. In steps 40-44, the three optimal relay node solutions are prioritized for each particular iteration. ```
1. Initialize the population, \(M_{\alpha}(x=1,2,\ldots,y)\), //\(M_{x}\) represents the set of random solutions based on the size and position of relay nodes
2. Initialize WOA parameters(\(x\), \(X\), \(G\), \(Q\) and \(s\)) and GWO parameters(\(C\), \(V\) and \(c\))
3. Calculate the fitness(\(FF=max(\mathcal{P}_{n})\)) of each search agent using Equation (1)
4. // Fitness represents the maximum number of paths covered with minimal relay nodes
5. Selection based on the adapted search algorithm
6. For WOA-based search
7. Find the best solution \(M^{*}\)
8. For GWO-based search
9. Do
10. Separate the solutions based on the fitness
11. \(M_{\alpha}=\) the first best search solution
12. \(M_{\beta}=\) the second-best search solution
13. \(M_{\delta}=\) the third best search solution
14. Compare \(M^{*}\) and \(M_{\alpha}\) //Select the best solution among \(M^{*}\) and \(M_{\alpha}\) pass \(M(final\_best)\) to WOA- and GWO-based updating procedures
15. While (\(k<\) maximum number of iterations)
16. Do update based on WOA and GWO
17. // WOA-based update
18. For each search agent
19. Update \(\overset{\rightarrow}{\rightarrow},\overset{\rightarrow}{X},\overset{ \rightarrow}{G},\) \(Q\) and \(s\)
20. if\(\Omega(Q<0.5)\)
21. if\(\Omega(|\overset{\rightarrow}{X}|<1)\)
22. Update the position of the current search agent by,
23. else if\(\Omega(|\overset{\rightarrow}{X}|\geq 1)\)
24. Select a random search agent (\(\overset{\rightarrow}{M}\))
25. Update the position of the current search agent by,
26. \(\overset{\rightarrow}{M}(k+1)=\overset{\rightarrow}{M}^{\mathit{m}}- \overset{\rightarrow}{X}\cdot\overset{\rightarrow}{W}\)
27. end if
28. else if\(\Omega(Q\geq 0.5)\)
29. Update the position of the current search by,
30. \(\overset{\rightarrow}{M}(k+1)=\overset{\rightarrow}{W}_{\mathit{dist}} \cdot\exp^{\mathit{log}_{\mathit{spind}}s}\cdot\cos(2\prod s)+\overset{ \rightarrow}{M}^{*}(k)\)
31. (where \(\overset{\rightarrow}{W}_{\mathit{dist}}=\overset{\rightarrow}{W}_{p}(k)- \overset{\rightarrow}{M}(k)\)) It means the distance between \(p^{\mathit{th}}\) whale and prey (i.e., the best solution attained till now); \(s\in[-1,1]\) and \(\mathit{log}_{\mathit{spind}}\) is the constant for defining the shape of the logarithmic spiral)
32. end if
33. end for
34. Return \(M^{*}\) //GWO-based update
35. For each search solution
36. Update the current search agent
37. //\(M(k+1)=\frac{(M_{1}+M_{2}+M_{3})}{3}\)
38. where \(M_{1}=M_{\alpha}(k)-C_{1}\cdot P_{\alpha}M_{2}=M_{\beta}(k)-C_{2}\cdot P_{ \beta};M_{3}=M_{\delta}(k)-C_{3}\cdot P_{\beta};\)
39. \(P_{\alpha}=|V_{1}\cdot M_{\alpha}-M|_{\alpha}P_{\beta}=|V_{2}\cdot M_{\beta}-M| _{\alpha}P_{\beta}=|V_{3}\cdot M_{\delta}-M|_{\alpha};\)
40. End for
41. Check if any search agent goes beyond the search space and adjust it
42. Calculate the fitness of each search agent (i.e., relay set) obtained through both search algorithms
43. Compare and update \(M(final\_best)\) if there is a better solution
44.