(1): set Popsize = Number of EMPs |
(2): set N_var = Number of variables in the problem //number of electromagnets |
(3): set Termination condition |
(4): set R_rate_max = Maximum probability of random search |
(5): set R_rate_min = Minimum probability of random search |
(6): set Ps_rate_max = Maximum probability of selecting the electromagnet from positive field |
(7): set Ps_rate_min = Minimum probability of selecting the electromagnet from positive field |
(8): set R_rate = R_rate_max //R_rate will decrease from R_rate_max to R_rate_min |
(9): set Ps_rate = Ps_rate_min //Ps_rate will increase from Ps_rate_min to Ps_rate_max |
(10): set UB and LB = Upper and lower bounds of electromagnets |
(11): set phi = Golden ratio |
(12): set P_field = ratio of the positive field |
(13): set N_field = ratio of the negative field |
(14): Generate initial population as pop. //use Eqn (11) |
(15): Evaluate initial population //calculate fitness of the initial population |
(16): Sort population according to the fitness values |
(17): do while Termination condition is not satisfied //Main loop |
// Candidate EMP generation // |
//v will be the candidate EMP, the size of v is N_var |
(18): for i = 1 to N_var do //for each electromagnets of the generated particle |
(19): Determine positive_index, negative_index and neutral_index randomly |
(20): if rand(0,1) ≤ Ps_rate then |
(21): v(i) = pop(positive_index,i) //generated EMPs electromagnet will be equal to positive field EMP |
(22): else |
(23): Determine v(i) using Eqn (12) |
(24): end if |
(25): end for |
(26): Check the boundary limits. //if v is outside of the boundary values, set the corresponding electromagnets to the boundary values |
// Random search // |
(27): if rand(0,1) ≤ R_rate then |
(28): Update randomly selected electromagnet of v within limits randomly |
(29): end if |
(30): set fitv = fitness value of the generated EMP |
(31): if fitv is better than the worst EMP in pop then |
(32): Delete the worst EMP and insert v to the pop |
(33): Re-sort the pop according to the fitness values |
(34): end if |
(35): Update Ps_rate and R_rate using the Eqn (13) and Eqn (14) |
(36): Save necessary information // Memorize global best |
(37): end while |