Skip to main content
. 2020 Mar 3;20(5):1377. doi: 10.3390/s20051377
Algorithm 1 W-GUN: Whale-centric Optimization for Green Underwater Networks
  • 1.

    Initialize the population,Mx(x=1,2,…,y),

    // Mx 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(Pn)) of each search agent using Equation (1)

    // Fitness represents the maximum number of paths covered with minimal relay nodes

  • 4.

    Selection based on the adapted search algorithm

  • 5.

    For WOA-based search

  • 6.

    Find the best solution M*

  • 7.

    For GWO-based search

  • 8.

    Do

  • 9.

    Separate the solutions based on the fitness

  • 10.

    Mα = the first best search solution

  • 11.

    Mβ = the second-best search solution

  • 12.

    Mδ = the third best search solution

  • 13.

    Compare M* and Mα

    //Select the best solution among M* and Mα pass M(final_best) to WOA- and GWO-based updating procedures

  • 14.

    While (k < maximum number of iterations)

  • 15.

     Do update based on WOA and GWO

  • 16.

     // WOA-based update

  • 17.

     For each search agent

  • 18.

      Update x→,X→,G→, Q and s

  • 19.

      if1(Q<0.5)

  • 20.

       if2(|X→|<1)

  • 21.

        Update the position of the current search agent by,

  • 22.

        W→=|G→⋅M→*(k)−M→(k)|

  • 23.

        else if2(|X→|≥1)

  • 24.

        Select a random search agent (M→rand)

  • 25.

        Update the position of the current search agent by,

  • 26.

        M→(k+1)=M→rand−X→⋅W→

  • 27.

       end if2

  • 28.

      else if1(Q≥0.5)

  • 29.

      Update the position of the current search by,

  • 30.

      M→(k+1)=W→dist.explogspirals⋅cos(2∏s)+M→*(k)

  • 31.

      (where W→dist=|M→p*(k)−M→(k)| It means the distance between pth whale and prey (i.e., the best solution attained till now); s∈[−1,1] and logspiral is the constant for defining the shape of the logarithmic spiral)

  • 32.

      end if1

  • 33.

     end for

  • 34.

     Return M*

     //GWO-based update

  • 35.

     For each search solution

  • 36.

      Update the current search agent

  • 37.

      M(k+1)=(M1+M2+M3)3

  • 38.

      where M1=Mα(k)−C1⋅Pα;M2=Mβ(k)−C2⋅Pβ;M3=Mδ(k)−C3⋅Pδ;

               Pα=|V1⋅Mα−M|;Pβ=|V2⋅Mβ−M|;Pδ=|V3⋅Mδ−M|;

  • 39.

     End for

  • 40.

     Check if any search agent goes beyond the search space and adjust it

  • 41.

     Calculate the fitness of each search agent (i.e., relay set) obtained through both search algorithms

  • 42.

     Compare and update M(final_best) if there is a better solution

  • 43.

     Store the best solution attained so far

  • 44.

     k=k+1

  • 45.

    end while

  • 46.

    return M(final_best)

  • 47.

    Stop