Skip to main content
. 2019 Sep 20;16(19):3505. doi: 10.3390/ijerph16193505
Algorithm 1 WOA
Input: Maximum number of iterations IterMax, Fitness function Fi, Current iteration number t,
   A random number l between −1 and 1, A constant number b.
1: Initialize the whales population Xi(i=1,2,3,,n)
2: for each search agent do
3:  Calculate the fitness function Fi
4: end for
5: X*= the best search agent
6: while t<IterMax do
7:   for each search agent do
8:   Update a,A,C,l and p
9:   if p<0.5 then
10:     if |A|<1 then
11:      Update the position of search agent using Eq(2);
12:     elseIf |A|1
13:      Select a random search agent Xrand;
14:      Update position of search agent using Eq(8);
15:     end if
16:    elseIf p>0.5
17:     Update the position with spiral Eq(5);
18:    end if
19:  end for
20:  Check if any search agent goes beyond the search space and amend it;
21:  for each search agent do
22:    Calculate the fitness function Fi
23:  end for
24:  Update X* if there is a better solution;
25:  t=t+1
26: end while
27: return X*