Skip to main content
. 2022 Oct 27;22(21):8240. doi: 10.3390/s22218240
Algorithm 1 Cuckoo search algorithm
Input: (n, p, kmax)
Output: x 0
 1: Randomly initialize n candidates x¯i=(i=1,2,...,n1)
 2: Calculate the error fi of each candidate xi
 3: Sort the population in ascending order of error fi
 4: for (k=0:k<kmax) do
 5:    for (i=0:i<p*n) do
 6:      Randomly pick a candidate xi with error fi
 7:      Generate xj by mutating xi using Equation (6)
 8:      Calculate error ej of xj
 9:      if (ej<fi) then
10:         Replace xi with xj
11:      end if
12:    end for
13:    Sort the population in ascending order of error fi
14:    Randomly initialize (p*n) worst candidates
15: end for