Firefly algorithm
Metaheuristic proposed by Xin-She Yang
title: "Firefly algorithm" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["nature-inspired-metaheuristics"] description: "Metaheuristic proposed by Xin-She Yang" topic_path: "general/nature-inspired-metaheuristics" source: "https://en.wikipedia.org/wiki/Firefly_algorithm" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Metaheuristic proposed by Xin-She Yang ::
In mathematical optimization, the firefly algorithm is a metaheuristic proposed by Xin-She Yang and inspired by the flashing behavior of fireflies.
Algorithm
In pseudocode the algorithm can be stated as:
Begin
- Objective function:
- Generate an initial population of fireflies
- Formulate light intensity I so that it is associated with f(\mathbf{x}) (for example, for maximization problems,
- Define absorption coefficient γ
while (t for i = 1 : n (all n fireflies) for j = 1 : i (n fireflies) if (I_jI_i ), Vary attractiveness with distance r via \exp(-\gamma ; r) ; move firefly i towards j; Evaluate new solutions and update light intensity; end if end for j end for i Rank fireflies and find the current best; end while end
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.) Thus the total number of objective function evaluations is (number of generations) × (number of fireflies).
The main update formula for any pair of two fireflies \mathbf{x}_i and \mathbf{x}_j is \mathbf{x}_i^{t+1}=\mathbf{x}i^t + \beta \exp[-\gamma r{ij}^2] (\mathbf{x}_j^t - \mathbf{x}_i^t) +\alpha_t \boldsymbol{\epsilon}_t where \alpha_t is a parameter controlling the step size, while \boldsymbol{\epsilon}_t is a vector drawn from a Gaussian or other distribution.
It can be shown that the limiting case \gamma \rightarrow 0 corresponds to the standard particle swarm optimization (PSO). In fact, if the inner loop (for j) is removed and the brightness I_j is replaced by the current global best g^*, then FA essentially becomes the standard PSO.
Criticism
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.
References
References
- Yang, X. S.. (2008). "Nature-Inspired Metaheuristic Algorithms". [[Luniver Press]].
- (2016). "A new fuzzy membership assignment and model selection approach based on dynamic class centers for fuzzy SVM family using the firefly algorithm". Turkish Journal of Electrical Engineering & Computer Sciences.
- Lones, Michael A.. (2014). "Proceedings of the Companion Publication of the 2014 Annual Conference on Genetic and Evolutionary Computation".
- Weyland, Dennis. (2015). "A critical analysis of the harmony search algorithm—How not to solve sudoku". Operations Research Perspectives.
- Ariyaratne MKA, Pemarathne WPJ (2015) A review of recent advancements of firefly algorithm: a modern nature inspired algorithm. In: Proceedings of the 8th international research conference, 61–66, KDU, Published November 2015, http://ir.kdu.ac.lk/bitstream/handle/345/1038/com-047.pdf?sequence=1&isAllowed=y
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::