Skip to main content
. 2019 Apr 15;21(4):398. doi: 10.3390/e21040398
Algorithm 1. Pseudo-code of CEFO algorithm
/* Part 1: Algorithm parameters initialization */
N_var: The number of electromagnets in each electromagnetic particle.
N_emp: The number of electromagnetic particles in population.
Ps_rate: The probability of changing one electromagnet with a random electromagnet.
R_rate: The probability of selecting electromagnets from the positive field.
P_field: The portion of particles belonging to positive.
N_field: The portion of particles belonging to negative.
 min = lower boundary; max = upper boundary
/* Part 2: Main loop of the algorithm */
for i = 1 to N_emp do
   for j = 1 to N_var do
    position [i, j] = min + rand ( )(max − min)
   end for
end for
Update position by using the chaotic map of Equation (5)
 fitness = function (position)
while t (current iteration) < max iterations
   Divide the electromagnetic field into three regions
   for i = 1 to N_var do
     if rand (0,1) > Ps_rate
      Generate the EMPNew by Equation (4)
     else
      Generate the EMPNew from positive particles
     end if
     Check if any particle beyond the search space
   end for
   if rand (0,1) < R_rate
     Change one electromagnet of EMPNew randomly
   end if
   Compare the fitness of EMPNew with worst particle
   t = t + 1
end while
 Output the best particle