In mathematical optimization, the firefly algorithm is a metaheuristic proposed by Xin-She Yang and inspired by the flashing behavior of fireflies.
[1] In pseudocode the algorithm can be stated as: Note that the number of objective function evaluations per loop is one evaluation per firefly, even though the above pseudocode suggests it is n×n.
(Based on Yang's MATLAB code.)
The main update formula for any pair of two fireflies
is a parameter controlling the step size, while
is a vector drawn from a Gaussian or other distribution.
It can be shown that the limiting case
corresponds to the standard particle swarm optimization (PSO).
In fact, if the inner loop (for j) is removed and the brightness
, then FA essentially becomes the standard PSO.
Nature-inspired metaheuristics in general have attracted criticism in the research community for hiding their lack of novelty behind metaphors.
The firefly algorithm has been criticized as differing from the well-established particle swarm optimization only in a negligible way.