Experiments with Firefly Algorithm
Experiments with Firefly Algorithm
Abstract. Firefly Algorithm (FA) is one of the recent swarm intelligence methods
developed by Xin-She Yang in 2008 [12]. FA is a stochastic, nature-inspired, meta-
heuristic algorithm that can be applied for solving the hardest optimization problems.
The main goal of this paper is to analyze the influence of changing some parameters
of the FA when solving bound constrained optimization problems. One of the most
important aspects of this algorithm is how far is the distance between the points and
the way they are drawn to the optimal solution. In this work, we aim to analyze other
ways of calculating the distance between the points and also other functions to com-
pute the attractiveness of fireflies.
To show the performance of the proposed modified FAs a set of 30 benchmark
global optimization test problems are used. Preliminary experiments reveal that the
obtained results are competitive when comparing with the original FA version.
1 Introduction
In this study we are interested in solving the bound constrained global optimization
problem by FA. The mathematical formulation of the optimization problem to be
addressed in this paper is stated as follows:
( )
(1)
where ( ) is a continuous nonlinear objective function, and are the lower and
upper bounds of the variables.
Following the firefly algorithm and the proposal changes to the attractiveness func-
tion are presented.
2.1 Original FA
The firefly algorithm is based on three main principles:
1. All fireflies are unisex, implying that all the elements of a population can attract
each other.
2. The attractiveness between fireflies is proportional to their brightness. The firefly
with less bright will move towards the brighter one. If no one is brighter than a par-
ticular firefly, it moves randomly. Attractiveness is proportional to the brightness
which decreases with increasing distance between fireflies.
3. The brightness or light intensity of a firefly is related with the type of function to
be optimized. In practice, the brightness of each firefly can be directly proportional
to the value of the objective function.
This algorithm is based on two key ideas: the light intensity emitted and the de-
gree of attractiveness that is generated between two fireflies.
The light intensity of firefly , , depends on the intensity of light emitted by firefly
and the distance between firefly and . In [13], the light intensity varies with
the distance monotonically and exponentially. That is
(2)
‖ ‖ . (3)
( ) (4)
‖ ‖ (∑| | )
‖ ‖ {| |} .
{ (5)
Here, for a given value of , if the distance between two fireflies is lesser or equal
than d, then exponentially decreases with the distance. Whenever the distance
between two fireflies is greater than d, the attractiveness takes a constant value. The
motivation for this approach is due to the fact that in (2) the value of attractiveness
can be considered negligible for certain values of distance.
Finally, another attractiveness function that takes into account the average rate of
change of the firefly brightness is considered. This function, denoted by , is defined
by:
( ) ( )
( ) ( )
{ (6)
3 Numerical Experiments
The FA algorithm was coded in Matlab and the computational tests were per-
formed on a PC with a 2.53 GHz Intel(R) Core (Tm) i5 Processor M460 and 4 Gb of
RAM. We used a collection of 30 benchmark bound constrained global optimization
test problems of dimension 2-30, described in full detail in the Appendix B of [1].
Each problem is solved 30 times.
The population of fireflies is used and the algorithm stops when a maxi-
mum of 20000 function evaluations is reached. The parameters used are: ,
, and 1.
In the first set of experiments, different norms in (2) are used for the calculation of
the distance . In the second set of experiments, a comparison with three attractive-
ness functions is made. For comparison purposes, performance profiles are used. Fi-
nally, a table with the results obtained with the best strategy is presented.
To compare the results obtained by different algorithms (or solvers), we used a sta-
tistical tool called performance profiles, created by Dolan and Moré [2]. Performance
profiles are depicted by a plot of a cumulative distribution ( ) representing a per-
formance ratio for the different solvers, based on a chosen metric. Generally, perfor-
mance profiles can be defined representing a statistic computed for a given quality
indicator value obtained in several runs. Performance profiles provide a good visuali-
zation and easiness of making inferences about the performance of the algorithms.
The concept of performance profiles requires minimization of a performance metric
and can be described as follows.
Let and be the set of problems and the set of solvers in comparison, respec-
tively. Let be the performance metric found by solver on problem
after a fixed number of function evaluations. Here, a metric that measures the relative
improvement of the function values, a scaled distance to the optimal function value, is
defined by:
(7)
where denotes the known optimal function value for a problem , denotes
the worst function value found among all solvers on the problem and denotes
the average of the best function values found by a solver on problem , after a cer-
tain number of runs.
As { } can be zero for a particular problem, the comparison used in
our study is based on the performance ratios defined by:
{ } { }
{ { }
for , and .
The overall assessment of the performance of a particular solver is given by
{ }
( )
The value of ( ) gives the probability that the solver will win over the others
in comparison. Thus, to see which solver has the least value of the performance met-
ric mostly, then ( ) should be compared for all the solvers. The higher the the
better the solver is. On the other hand, for large values of , the solver robustness is
measured by ( ).
Figure 1 plots the performance profile for the average value of obtained best func-
tion values concerning FA with different norms in the attractiveness function (2).
From Fig. 1 we may conclude that the average best solutions found for computing
attractiveness based on 1-norm, over the 30 runs, outperforms the other versions in
comparison. In particular, this one gives the best average solution in about 50% of the
tested problems and dominates the other four solvers for all values.
Figure 2 shows the plots of the solvers in comparison that are related with the im-
plementation of the two attractiveness functions ((5) and (6)) and the original attrac-
tiveness function (2). In all attractiveness functions the 1-norm is considered to com-
pute the distance between fireflies. The attractiveness function defined by reveals
as efficient as the original beta function. Their efficiency is shown in Fig. 2 at .
However, for τ greater than approximately 2, the solver with as the attractiveness
function wins against the others and dominates with respect to robustness.
0.9 1 1
0.98
0.8
0.96
0.7
0.94
0.6
0.92
()
0.9 1 1
0.8 0.95
0.98
0.7
0.9
0.96
0.6
()
0.85
0.5 0.94
1 0.8
0.4
2
0.75
0.92
0.3
original
0.2 0.7 0.9
1 1.2 1.4 1.6 1.8 10 30 1100 1150
4 Conclusions
In this paper the Firefly Algorithm, a stochastic global optimization algorithm, in-
spired by the social behavior of fireflies and based on their flashing and attraction, is
presented for solving the bound constrained optimization problems.
In order to improve the efficiency of FA, other ways of calculating the distance be-
tween the points and other functions to compute the attractiveness of fireflies were
tested and analyzed.
A set of benchmark global optimization test problems were used to show the per-
formance of the proposed modified FAs and preliminary results revealed competitive
when comparing with the original FA version.
In the future, an extension of FA algorithm, to solve constrained problems, based
on penalty techniques will be addressed.
Acknowledgements. This work has been supported by FCT (Fundação para a Ciência
e Tecnologia, Portugal) in the scope of the projects: PEst-OE/MAT/UI0013/2014 and
PEst-OE/EEI/UI0319/2014.
References
1. Ali, M.M., Khompatraporn, C., Zabinsky, Z.B.: A numerical evaluation of several stochas-
tic algorithms on selected continuous global optimization test problems. J. Global Optim.
31, 635–672 (2005)
2. Dolan, E. D., Doré, J.J.: Benchmarking Optimization Software with Performance Profiles.
Preprint ANL/MCS-P861-1200 (2001)
3. Dorigo, M., Stützle, T.: Ant Colony Optimization, MIT Press (2004)
4. Dorigo, M., Caro, G. D., Gambardella L. M.: Ant algorithms for discrete optimization,.
Université Libre de Bruxelles, Belgium (1999)
5. Eberhart, R.C., Kennedy, J., Shi, Y.: Swarm optimization. Academic Press (2001)
6. Eberhart, R.C., Kennedy, J.: Particle Swarm optimization. Proc. of IEEE International
Conference on Neural Networks, Piscataway, NJ, pp.1942-1948 (1995)
7. Goldber, D.E.: Genetic Algorithms in Search, Optimization and Machine Learning. Read-
ing, Mass., Addison Wesley (1989)
8. Heppner, F., Grenander, U.: A stochastic nonlinear model for coordinated bird flocks. The
Ubiquity of Chaos. AAAS Publications, Washington DC (1990)
9. Lukasik, S., Zak, S.: Firefly algorithm for continuous constrained optimization tasks. In:
Chen, S.M., Ngugen, N.T., Kowalczyk, R. (eds.), ICCC 2009, Lecture notes in Artificial
Intelligence, vol. 5796, pp. 97-100. Springer (2009)
10. Reynolds, C. W.: Flocks, herds and schools: a distributed behavioral model. Comp. Graph.
25-34 (1987)
11. Rocha, A.M.C., Fernandes, E.M.G.P., Martins, T.F.M.C.: Novel Fish swarm heuristics for
bound constrained global optimization problems. J. Comput. Appl. Math. 235(16), 4611-
4620 (2011)
12. Yang, X-S.: Firefly Algorithm, Stochastic Test Functions and Design Optimization. Int. J.
Bio-Inspired Computation, Vol. 2, No. 2, pp.78-84 (2010)
13. Yang, X-S.: Nature-Inspired Metaheuristic Algorithms. Luniver Press, Beckington, UK,
2nd edition, 2010
14. Yang, X-S.: Firefly algorithms for multimodal optimization. In: Watanabe O, Zeugmann
T, (eds.) Stochastic algorithms: foundations and applications, SAGA 2009, LNCS, vol.
5792, pp. 169–78. Springer-Verlag (2009)