Keywords

1 Introduction

Firefly algorithm (FA) is a stochastic optimization algorithm inspired by the swarm intelligence introduced by XinShe Yang [1] at Cambridge University. The algorithm is of higher convergence rate especially in function optimization. A lot of numerical examples have illustrated the superiority of this method. FA has been applied to many different fields. Nggam J. Cheung et al. analyzed of the relevant parameters of the algorithm [2]. Xinshe Yang et al. also made a further research on the algorithm that some unique test functions were introduced [3]. And the advanced nature of the algorithm was described in the optimization problem [4]. Xinshe Yang believed that it was more effective in solving NP-hard problems [5]. A new method using FA for hybrid data clustering was explained by Maheshwar et al. [6]. Shaik Farook used hybrid genetic-firefly algorithm for regulating LFC regulations in a deregulated power system [7].

However, standard FA is easy to fall into the local optimal solution in the global search. In order to overcome this defect of the algorithm, Arora et al. proposed mutated firefly algorithm to improve the convergence rate and accurateness [8]. Shuhao Yu et al. used a variable strategy for step size α to modify firefly algorithm (VSSFA) [9]. A new disturbance model of the brightest firefly was improved in the paper of S.L. Tilahun et al. [10]. And a peculiar movement strategy was described by adding inertia weight in literature [11]. At the same time, Mahdi Bidar et al. described a new method called JFA which promoted the low brightness firefly [12]. The intelligent firefly algorithm (IFA) was introduced by Seif-Eddeen K. Fateen et al. in which a firefly acted intelligently by basing its move on top ranking fireflies [13]. Milan Tuba et al. also upgraded FA for portfolio optimization problem [14]. In addition, Le’vy Flights was combined with search strategy of FA in literature of XinShe Yang et al. [15]. Some scholars also introduced the chaos mechanism into the algorithm [16, 17]. As well, a kind of adaptive firefly optimization algorithm based on stochastic inertia weight was discussed by Changnian Liu [18].

In the above improved methods, the search path of the firefly was not mentioned. In standard FA, a firefly in the search process is not clear about the direction of movement, so that it is not conducive to find the global optimal solution. Therefore, we presented a kind of detecting firefly which surrounds a target point to do a spiral motion, and gradually converges to the target point. When the scope of the definition domain is larger, the more dispersed fireflies will lead to lower convergence rate. In order to solve this problem, we add the item of brightness to the definition of attractiveness. And the influence of the global optimum and the suboptimum also was considered to join in the process of the movement of the firefly.

The rest of the paper is structured as follows. The second section is a review of the standard FA. DFA is described in third section. In fourth section, the proposed algorithm is tested on 28 benchmark functions. Moreover, the simulation result is compared with the standard FA and several intelligent optimization algorithms and then the performance of DFA is verified. The last section summarizes the paper.

2 Standard Firefly Algorithm

For simplicity in describing FA which was developed by XinShe Yang, There are three idealized assumptions as following [1]:

  • Each firefly will be attracted to other fireflies only depend on their brightness regardless of their sex or other.

  • Any two flashing fireflies, the less bright one will be attracted and move towards the brighter one. The attractiveness of fireflies both decrease as their distance increases. If there is no brighter one than a particular firefly, it will move randomly.

  • The brightness of a firefly is affected or determined by the value of the objective function.

In standard FA, the brightness of a firefly is proportional to the value of objective function. The absolute brightness of a firefly at a particular location x is chosen as:

$$ I(x) \propto f(x) $$
(1)

where \( I(x) \) is absolute brightness when the attenuation of brightness in the medium is not considered. As attractiveness of a firefly is inverse proportional to the distance seen by adjacent fireflies, we define the attractiveness β of a firefly by:

$$ \beta = \beta_{0} e^{{ - \gamma r^{2} }} $$
(2)

where \( \beta_{0} \) is the attractiveness at r = 0, \( \gamma \) is a light absorption coefficient. The movement strategy of a firefly i is attracted to another more attractive (or brighter) firefly j is determined by:

$$ x_{i} = x_{i} + \beta \left( {x_{j} - x_{i} } \right) + \alpha \varepsilon_{i} $$
(3)

where the second term is due to the attraction. The third term is randomized with α being the randomization parameter, and \( \varepsilon_{i} \) is a vector of random numbers drawn form a Gaussian distribution or uniform distribution.

3 Detecting Firefly Algorithm

3.1 Detecting Firefly

Inspired by detecting particle swarm optimization that was proposed by Y Zhang [19], we introduced the detecting firefly to FA. In standard FA, the search path of single firefly is disorganized. It is easy to make the algorithm fall into local optimal solution. The aim of this research is to help the firefly escape from local optimal trap. We selected a small portion of the n fireflies whose number was marked as \( n_{s} \). These fireflies which are known as detecting firefly try to find a better potential optimal value along the spiral convergence line path (a spiral center is required in the domain of definition). Using the detecting firefly can expand the search scope of the algorithm. In the meantime, the rest of fireflies search the optimal value in accordance with the standard FA. That natural firefly and detecting firefly complement each other effectively to maintain population diversity and avoid premature phenomenon in the evolution.

In order to make the detecting firefly move around the target point (such as current global optimal value) along the path of the spiral line, we used an offset \( \Delta X \) which is equal to the speed of particle in PSO. When detecting firefly i is going to move, its location update formula is defined as follows:

$$ \Delta X_{i}^{k + 1} = C_{s1} \Delta X_{i}^{k} + C_{s2} \left( {X_{gbest} - X_{i}^{k} } \right) $$
(4)
$$ X_{i}^{k + 1} = X_{i}^{k} + \Delta X_{i}^{k + 1} $$
(5)

where \( X_{gbest} \) is the position of the brightest firefly, coefficient k represents the \( k_{th} \) iteration, \( C_{s1} \) and \( C_{s2} \) respectively represent the proportion of \( \Delta X_{i}^{k} \) and \( \left( {X_{gbest} - X_{i}^{k} } \right) \) in movement direction of the detecting firefly and the initial position \( X_{i}^{0} \) and initial offset \( \Delta X_{i}^{0} \) are random. We selected the position of current optimal firefly as the target. \( n_{s} \)(\( n_{s} \) = 5) detecting fireflies travel in the spiral track which were given in Fig. 1 around the position of current optimal firefly. This process will be iterated for T (T = 10) times. For example, we selected firefly i as a detecting firefly. The original brightness \( I_{i} \) of firefly i and the brightness \( I_{i}^{*} \) of detecting firefly \( i^{*} \) which is the brightest in T iterations are compared. If the brightness \( I_{i}^{*} \) is greater than the original brightness \( I_{i} \), the algorithm will use the position of detecting firefly \( i^{*} \) to update the original position of firefly i.

Fig. 1.
figure 1

The search path of the detecting firefly

3.2 Randomization Parameter (Step Length) and Attractiveness

In fact, the randomization parameter \( \alpha \) of the standard FA is fixed in the formula of movement of a firefly. It cannot be perfectly suited to the search process of firefly. When \( \alpha \) is large, the algorithm has a satisfied convergence rate. But it is easy to ignore the potential of the optimal value, so that it reduces the accuracy in late search. On the other hand, when \( \alpha \) is smaller, the algorithm has the high precision in local. However, reduced search space can result in that the algorithm cannot find the global optimal value. In order to balance the search range and precision, we used an adaptive strategy to generate \( \alpha \) [1] as follow:

$$ \alpha = \alpha_{e} + (\alpha_{s} - \alpha_{e} )e^{ - t} $$
(6)

where \( \alpha_{s} \) is initial value, \( \alpha_{e} \) is the final value specified, coefficient t represents the \( t_{th} \) iteration. The formula shows that \( \alpha \) decreases exponentially with the increase of the iteration.

In standard FA, the movement direction of the firefly is determined by the brightness of each firefly. But the degree of the attractiveness between the fireflies is only related to the distance. It does not reflect the impact of the brightness in the movement of the firefly [9]. If the function optimization problem has a larger scope of definition, a brighter firefly which is far from the others will not have enough attractiveness to the others. So in DFA, a new method of calculating attractiveness was designed depending on both brightness and direction. If firefly j is brighter than firefly i, the attractiveness \( \beta_{ij} \) of firefly j to firefly i is given by:

$$ \beta_{ij} = \left\{ \begin{aligned} & \frac{{I_{j} }}{{I_{i} }}e^{{ - \gamma r^{2 } }} & I_{i} > 0 \\ & \beta_{o} \, & I_{i} = 0 \\ \end{aligned} \right. $$
(7)

where \( I_{i} \) and \( I_{j} \) are absolute brightness of firefly i and firefly j respectively. In this paper, it is important to note that the brightness of all fireflies is greater than zero which depends on the objective function. Therefore, the minimum brightness is zero.

3.3 Firefly Movement

In the position update process of original firefly, the current brightest firefly has not been concerned in the algorithm. XinShe Yang introduced to add an extra item about the brightest firefly into Eq. 3 [1]. But this strategy is likely to cause that the movement direction of the firefly becomes single.

DFA was continued to add another item about second brightest in our improvement. When the firefly is moving, the space between the optimum and the suboptimum will be searched. It avoids the premature convergence that is caused by adding the optimal location only. Suppose that the brightness of firefly i is not as good as firefly j, firefly i is attracted by firefly j. The updated location of firefly i is defined by:

$$ x_{i} = x_{i} + \beta_{ij} \left( {x_{j} - x_{i} } \right) + \alpha \varepsilon_{i1} + \lambda_{1} \varepsilon_{i2} \left( {x_{gbest} - x_{i} } \right) + \lambda_{2} \varepsilon_{i3} (x_{gbest}^{ '} - x_{i} ) $$
(8)

where \( x_{gbest} \) is the location of the brightest firefly and \( x_{gbest}^{'} \) is the location of the second brightest firefly. \( \varepsilon_{i1} \), \( \varepsilon_{i2} \) are vectors of random numbers in [-0.5,-0.5]. \( \lambda_{1} ,\lambda_{2} \) are inertia weight. If a firefly is the brightest firefly, it will move randomly. We used the best firefly after disturbing to replace the original firefly. According to Eqs. 48, the pseudo code of DFA is given by Table 1.

Table 1. The pseudo code of DFA

4 Simulation and Experiments

The algorithm was compared with other intelligent optimization algorithms, such as standard particle swarm algorithm, genetic algorithm, SFA, and VSSFA [9]. The parameters of these algorithm were listed by Table 2. The proposed DFA was tested by 28 benchmark functions in CEC 2013 which be summarized in paper [20]. There are five unimodal functions (from \( f_{1} \) to \( f_{5} \)), 20 basic multimodal functions (from \( f_{6} \) to \( f_{20} \)) and 8 composition functions (from \( f_{21} \) to \( f_{28} \)). All problems are the minimum optimization. And the dimensions of all test functions were 30. The scope of each dimension was in [−100, 100]. We adopted 50 independent runs for each of test function and then calculated the average of 50 results.

Table 2. The parameters’ setting

The average values on the optimization were presented in Table 3, where the top of the ranked value was highlighted in boldface. From the results, the average ranking of DFA is 1.46 that is far higher than other algorithms in ranking.

Table 3. Simulation result of the 28 benchmark functions

Though the performance of DFA is not as good as SPSO on function \( f_{2} \), \( f_{4} \), \( f_{6} \), \( f_{10} \), and is worse than GA and VSSFA respectively on function \( f_{8} \) and \( f_{15} \), \( f_{23} \), the algorithm has an absolute advantage on the rest of test functions. The simulation and experiments show that the performance of the algorithm is significant which beyond other in finding the global optimal value.

To amplify the convergence property of DFA, the convergence curves were displayed at Figs. 2, 3, 4 and 5. Due to space limitations, our paper only described four convergence curves on functions \( f_{1} \), \( f_{11} \), \( f_{13} \), \( f_{28} \). Figures 3 and 4 show that convergence rate of DFA was greater than other algorithms on Sphere function and Rastrigin’s function. On Sphere function, DFA began to converge at the \( 400_{th} \) iteration. But SFA and VSSFA still fluctuated at the \( 800_{th} \) iteration. DFA began to converge at the \( 300_{th} \) iteration on Rastrigin’s function. However, SFA and VSSFA were not convergent in \( 1000_{th} \) iterations. On non-continuous rotated Rastrigin’s function, DFA is better than FA, not as good as VSSFA. And on the composition function 8(n = 5, rotated), the convergence rate of DFA is as high as that of SFA, which is higher than VSSFA.

Fig. 2.
figure 2

Convergence curve of \( f_{1} \)

Fig. 3.
figure 3

Convergence curve of \( f_{11} \)

Fig. 4.
figure 4

Convergence curve of \( f_{13} \)

Fig. 5.
figure 5

Convergence curve of \( f_{28} \)

The experiments displayed that DFA has well accuracy and convergence rate on different function optimization problems. Adding the detecting firefly made the algorithm escape from the local optimal trap and premature convergence. The decline of convergence rate that detecting firefly caused was blocked by adding optimum and suboptimum.

5 Conclusion

In the paper, to address the problem that SFA easy to fall into local optimum, an improved firefly algorithm, named as DFA, was proposed. The proposed algorithm based on detecting firefly expanded the searching range of the firefly swarm, so that it is easier to find the global optimal value. Further, that the optimal location was added to the movement strategy highlighted the role of optimal location in the algorithm. Finally, the experiments on 28 benchmark functions show that DFA has a significant improvement on standard FA.