
Source-code of the KH algorithm in C++ 237
137 J=ns_tmp>Ub ;
138 A=rand ;
139 ns_tmp ( I )=A∗Lb( I )+(1−A) ∗ b es t ( I ) ;
140 B=rand ;
141 ns_tmp ( J )=B∗Ub( J )+(1−B) ∗ b e s t ( J ) ;
142 ns ( i , : )=ns_tmp ;
143 end
Listing 18.2
Source-code of KH algorithm in Matlab.
18.4 Source-code of the KH algorithm in C++
The C++ source code for the objective function and the KH algorithm are
presented in Listing 18.3 and Listing 18.4, respectively.
1 #i nclude <io st re am >
2 using namespace s td ;
3 /∗ Function D e f i n i t i o n s ∗/
4 double OF( double SA [ ] , i n t s i z e _ a r r a y )
5 {
6 double out put ;
7 i n t j ;
8 outp ut = 0 . 0 ;
9 f or ( j = 0 ;