
Source-code of GWO algorithm in C++ 213
39 r2=rand ( ) ;
40 A2=2∗a∗ r1−a ;
41 C2=2∗ r2 ;
42 D_beta=abs ( C2∗Beta_pos ( j )−P o s i t i o n s ( i , j ) ) ;
43 X2=Beta_pos ( j )−A2∗D_beta ;
44 r1=rand ( ) ;
45 r2=rand ( ) ;
46 A3=2∗a∗ r1−a ;
47 C3=2∗ r2 ;
48 D_delta=abs (C3∗ Delta_pos ( j )−P o s i t i o n s ( i , j ) ) ;
49 X3=Delta_pos ( j )−A3∗ D_delta ;
50 P o s i t i o n s ( i , j )=(X1+X2+X3) /3 ;
51 en d % Return back t h e sea rc h a g e n ts th a t go beyond t he b oun da ri e s
o f the s ea r ch space
52 Flag4ub=P o s i t i o n s ( i , : ) >ub ;
53 Fl a g 4l b=P o s i t i o n s ( i , : )<l b ;
54 P o s i t i o n s ( i , : ) =( P o s i t i o n s ( i