Firefly Algorithm: Concept and Applications
The Firefly Algorithm (FA) is a swarm-based optimization algorithm inspired by the flashing behavior of fireflies. It was developed by Xin-She Yang in 2008. In essence, a brighter firefly attracts less bright fireflies to move closer, so the population gathers around the best solutions.
Basic rules
Xin-She Yang simplified firefly behavior into three rules:
All fireflies are unisex, so one firefly is attracted to any other firefly.
Attractiveness is proportional to brightness. Between two fireflies, the less bright one moves toward the brighter one. Attractiveness decreases as distance increases. If no firefly is brighter, it moves randomly.
Brightness is determined by the objective function value. In maximization problems, brightness is proportional to the function value.
Formulas
Distance
The distance between fireflies i and j is usually Euclidean:
rij = ||xi - xj||
Attractiveness
Attractiveness decreases exponentially with distance:
β(r) = β0 · exp(-γ r2)
where β0 is the attractiveness at zero distance (often 1) and γ is the light absorption coefficient.
Movement
If firefly j is brighter than i, then i moves according to:
xi = xi + β0 exp(-γ rij2) (xj - xi) + α (rand - 0.5)
The first term is the current position, the second is the attraction toward the brighter firefly, and the third is a random move with parameter α to maintain exploration.
Role of the parameters
Small γ (near 0): attractiveness is nearly constant, all fireflies see each other, and behavior resembles PSO.
Large γ: attractiveness drops quickly, fireflies are attracted only to close neighbors, forming several groups, which suits multimodal problems.
α: the size of the random move, often reduced over the iterations.
Algorithm steps
Initialize the firefly population randomly and set β0, γ, α, and the maximum iterations.
Compute the brightness (fitness) of each firefly.
For each pair i and j, if j is brighter, move i toward j with the movement formula.
Update brightness, sort, and record the best solution.
Repeat until the maximum iterations are reached.
A simple calculation
Suppose β0 = 1, γ = 1, firefly i at xi = 2 and a brighter j at xj = 3 (distance r = 1). Ignore the random term.
Attractiveness = 1 × exp(-1) ≈ 0.368.
New position of i = 2 + 0.368 × (3 - 2) = 2.368.
Firefly i moves toward j by about 37% of the distance.
Strengths and weaknesses
Strengths: can form subgroups, making it good for multimodal problems, a clear concept, and competitive results on many problems.
Weaknesses: O(n2) complexity per iteration because every pair is compared, sensitive to the parameters γ and α, and it can oscillate or converge slowly if the parameters are poorly chosen.
Applications
FA is used in engineering design optimization, scheduling, feature selection, tuning machine learning model parameters, and data clustering.
Conclusion
The Firefly Algorithm is an intuitive and effective metaheuristic, especially for problems with many local optima. Report the parameter values and population size you used in your thesis, and compare with similar algorithms.