Firefly algorithm

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In mathematical optimization, the firefly algorithm is a metaheuristic proposed by Xin-She Yang and inspired by the flashing behaviour of fireflies.[1]

Nature-inspired metaheuristics in general have started to attract criticism in the research community for hiding their lack of novelty behind an elaborate metaphor.[2][3][4][5][6] In response, Springer's Journal of Heuristics has updated their editorial policy to state that:[7]

Implementations should be explained by employing standard optimization terminology, where a solution is called a "solution" and not something else related to some obscure metaphor (e.g., harmony, flies, bats, countries, etc.).

The firefly algorithm specifically has been criticized as differing from the well-established particle swarm optimization only in a negligible way.[8]


The primary purpose for a firefly's flash is to act as a signal system to attract other fireflies. Xin-She Yang formulated this firefly algorithm by assuming:

  1. All fireflies are unisexual, so that any individual firefly will be attracted to all other fireflies;
  2. Attractiveness is proportional to their brightness, and for any two fireflies, the less bright one will be attracted by (and thus move towards) the brighter one; however, the intensity (apparent brightness) decrease as their mutual distance increases;
  3. If there are no fireflies brighter than a given firefly, it will move randomly.

The brightness should be associated with the objective function.


In pseudocode the algorithm can be stated as:

   1) Objective function: ;
   2) Generate an initial population of fireflies ;.
   3) Formulate light intensity I so that it is associated with 
      (for example, for maximization problems,  or simply ;)
   4) Define absorption coefficient γ
   While (t < MaxGeneration)
      for i = 1 : n (all n fireflies)
         for j = 1 : n (n fireflies)
            if (),
               move firefly i towards j;
               Vary attractiveness with distance r via ;
               Evaluate new solutions and update light intensity;
            end if 
         end for j
      end for i
      Rank fireflies and find the current best;
   end while

   Post-processing the results and visualization;


The main update formula for any pair of two fireflies and is

where 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 is replaced by the current global best , then FA essentially becomes the standard PSO.

See also[edit]


  1. ^ Yang, X. S. (2008). Nature-Inspired Metaheuristic Algorithms. Luniver Press. ISBN 1-905986-10-6. 
  2. ^ Weyland, Dennis (2010). "A Rigorous Analysis of the Harmony Search Algorithm: How the Research Community can be Misled by a "Novel" Methodology". International Journal of Applied Metaheuristic Computing 1 (2): 50–60. doi:10.4018/jamc.2010040104. 
  3. ^ Sörensen, Kenneth (2013). "Metaheuristics—the metaphor exposed". International Transactions in Operational Research 22: 3–18. doi:10.1111/itor.12001. In recent years, the field of combinatorial optimization has witnessed a true tsunami of "novel" metaheuristic methods, most of them based on a metaphor of some natural or man-made process. The behavior of virtually any species of insects, the flow of water, musicians playing together – it seems that no idea is too far-fetched to serve as inspiration to launch yet another metaheuristic. In this paper, we will argue that this line of research is threatening to lead the area of metaheuristics away from scientific rigor. 
  4. ^ Metaheuristics at Scholarpedia, curated by Fred Glover and Kenneth Sörensen. "A large (and increasing) number of publications focuses on the development of (supposedly) new metaheuristic frameworks based on metaphors. The list of natural or man-made processes that has been used as the basis for a metaheuristic framework now includes such diverse processes as bacterial foraging, river formation, biogeography, musicians playing together, electromagnetism, gravity, colonization by an empire, mine blasts, league championships, clouds, and so forth. An important subcategory is found in metaheuristics based on animal behavior. Ants, bees, bats, wolves, cats, fireflies, eagles, vultures, dolphins, frogs, salmon, vultures, termites, flies, and many others, have all been used to inspire a "novel" metaheuristic. [...] As a general rule, publication of papers on metaphor-based metaheuristics has been limited to second-tier journals and conferences, but some recent exceptions to this rule can be found. Sörensen (2013) states that research in this direction is fundamentally flawed. Most importantly, the author contends that the novelty of the underlying metaphor does not automatically render the resulting framework "novel". On the contrary, there is increasing evidence that very few of the metaphor-based methods are new in any interesting sense."
  5. ^ Jerry Swan, Steven Adriaensen, Mohamed Bishr, Edmund K. Burke, John A. Clark, Patrick De Causmaecker, Juanjo Durillo, Kevin Hammond, Emma Hart, Colin G. Johnson, Zoltan A. Kocsis, Ben Kovitz, Krzysztof Krawiec, Simon Martin, J. J. Merelo, Leandro L. Minku, Ender Özcan, Gisele L. Pappa, Erwin Pesch, Pablo Garcáa-Sánchez, Andrea Schaerf, Kevin Sim, Jim E. Smith, Thomas Stützle, Stefan Voß, Stefan Wagner, Xin Yao. "A Research Agenda for Metaheuristic Standardization". "Metaphors often inspire new metaheuristics, but without mathematical rigor, it can be hard to tell if a new metaheuristic is really distinct from a familiar one. For example, mathematically, 'Harmony search' turned out to be a simple variant of 'Evolution Strategies' even though the metaphors that inspired them were quite different. Formally describing state, representation, and operators allows genuine novelty to be distinguished from minor variation."
  6. ^ Alexander Brownlee and John R. Woodward (2015). "Why we fell out of love with algorithms inspired by nature". The Conversation.
  7. ^ Journal of Heuristic Policies on Heuristic Search Research. Springer. "Proposing new paradigms is only acceptable if they contain innovative basic ideas, such as those that are embedded in classical frameworks like genetic algorithms, tabu search, and simulated annealing. The Journal of Heuristics avoids the publication of articles that repackage and embed old ideas in methods that are claimed to be based on metaphors of natural or manmade systems and processes. These so-called "novel" methods employ analogies that range from intelligent water drops, musicians playing jazz, imperialist societies, leapfrogs, kangaroos, all types of swarms and insects and even mine blast processes (Sörensen, 2013). If a researcher uses a metaphor to stimulate his or her own ideas about a new method, the method must nevertheless be translated into metaphor-free language, so that the strategies employed can be clearly understood, and their novelty is made clearly visible. (See items 2 and 3 below.) Metaphors are cheap and easy to come by. Their use to "window dress" a method is not acceptable."
  8. ^ Weyland, Dennis (2015). "A critical analysis of the harmony search algorithm—How not to solve sudoku". Operations Research Perspectives 2: 97–105. doi:10.1016/j.orp.2015.04.001. For example, the differences between the particle swarm optimization metaheuristic and "novel" metaheuristics like the firefly algorithm, the fruit fly optimization algorithm, the fish swarm optimization algorithm or the cat swarm optimization algorithm seem negligible.