
128 Dynamic Virtual Bats Algorithm
80 i f f ( x ( i , : ) ) <= f g b e s t
81 f g b e s t = f ( x ( i , : ) ) ; xg b es t = x ( i , : ) ;
82 end
83 end
84 end
85 % t h e r e s u l t of DVBA i s re t u r ne d
86 disp ( f g b e s t )
Listing 10.2
Source-code of DVBA in Matlab.
10.4 Source-code of DVBA in C++
1 #i nclude <io st re am >
2 #i nclude <c s t d l i b >
3 #i nclude <ctime>
4 using namespace s td ;
5 // d e f i n i t i o n o f t he o b j e c t i v e f u n c t i o n f ( x )
6 f l o a t ub = 5 . 1 2; f l o a t l b = −5.12; //ub , l b : upper and lo wer bounds .
7 f l o a t f ( f l o a t x [ ] , i n t s i z e _ a r r a y ) {
8 f l o a t t = 0 ;
9 fo r (