
168 Firefly Algorithm
20 ns=f i n d l i m i t s ( n , ns , Lb , Ub) ;
21 %% Ranking f i r e f l i e s by t h e i r l i g h t i n t e n s i t y / o b j e c t i v e s
22 [ Lightn , In dex ]= s o r t ( Li ght n ) ;
23 ns_tmp=ns ;
24 f o r i =1:n ,
25 ns ( i , : )=ns_tmp( In dex ( i ) , : ) ;
26 end
27 %% Find th e cu r re nt b e s t and d i s p l a y ou t pu t s
28 f b e s t=Li ght n (1 ) , n be s t=ns ( 1 , : )
29 end % End o f t loo p ( up t o tMax )
Listing 13.2
The main part of the firefly algorithm.
The third part is the objective function and ways for implementing the
lower and upper bounds. This will ensure that all solution vectors should be
within the