Skip to main content
. 2016 Aug 31;16(9):1390. doi: 10.3390/s16091390
Algorithm 1. Modified CS algorithm
1. Begin
2. Generate initial population of n nests (solutions) xi, i = 1, 2, …, n
3. Define objective function f(x); x = (x1, x2, …, xd);
4. Set the range of α and Pa: αmin, αmax, Pamin, Pamax
5. Set the range of the nest(solution): Xmin, Xmax
6. Set the maximum number of iterations: N_itertotal
7. For all xi do
8. Calculate the fitness Fi=f(xi)
9. End For
10. N_iter = 1
11. While (N_iter < N_itertotal) do
12. For all xi do
13. Compute the step size for Levy flight using Equation (6)
14. Generate a new cuckoo (xj) from the nest xi randomly by taking Lévy flight
15. If (xj>Xmax) then
16. xjXmax
17. End If
18. If (xj<Xmin) then
19. xjXmin
20. End If
21. Calculate the fitness Fj=f(xj)
22. Choose a random nest (xk) among n nest randomly
23. If (Fj>Fk) then
24. xjxk
25. FjFk
26. End If
27. End For
28. Keep the current global optimal fitness: fmin
29. Compute the probability Pa using Equation (7)
30. A fraction (Pa) of worse nests abandoned and new ones/solutions are built/generated correspondingly
31. For all the nests (say, xi) to be built/generated do
32. If (xi>Xmax) then
33. xiXmax
34. End If
35. If (xi<Xmin) then
36. xiXmin
37. End If
38. Calculate the fitness Fi=f(xi) and evaluate its quality/fitness Fi
39. Keep best solutions (or nests with quality solutions)
40. End For
41. Rank all the solutions and find the current best
42. End While
43. End