
Source-code of global version of CSO algorithm in C++ 63
71 fo r i =1:N
72 Eval ( i , 1 )=OF(P( i , : ) ) ;
73 i f Eval ( i , 1 )<Eval Pbes t ( i , 1 )
74 Pbest ( i , : ) =P( i , : ) ;
75 Ev alPb est ( i , 1 )=Eval ( i , 1 ) ;
76 end
77 i f Eval ( i , 1 )<Eval ( TheBest , 1 )
78 TheBest=i ;
79 end
80 end
81 i f Eval ( TheBest , 1 )<EvalGbest
82 Gbest ( 1 , : )=P( TheBest , : ) ;
83 EvalGbest=Eval ( TheBest , 1 ) ;
84 end
85 end
86 disp ( EvalGbest ) ;
Listing 5.3
Source-code of the global version of the CSO in Matlab.
5.4 Source-code of global version of CSO algorithm in
C++
1 #i nclude <io st re am >
2 #i nclude <c s t d l i b >
3 #i nclude <ctime>
4 #i nclude <