Firefly Algorithm (FA): A Novel method motivated from the behavior of Fireflies for Optimal Solution

1. Introduction

            Firefly algorithm (FA) was first developed by Yang in 2007 (Yang, 2008, 2009) which was based on the flashing patterns and behavior of fireflies. Firefly algorithm is classified as swarm intelligent, metaheuristic and nature-inspired, and it is developed by Yang in 2008 by animating the characteristic behaviors of fireflies [1]. In fact, the population of fireflies show characteristic luminary flashing activities to function as attracting the partners, communication, and risk warning for predators. As inspiring from those activities, Yang formulated this method under the assumptions of all fireflies are unisexual such that all fireflies has attracting potential for each other and the attractiveness is directly proportionate to the brightness level of individuals. Hence, the brighter fireflies attract to the less brighter ones to move toward to them, besides that in the case of no fireflies brighter than a certain firefly then it moves randomly [2]. In the formulation of firefly algorithm, the objective function is associated with flashing light characteristics of the firefly population. Considering the physical principle of the light intensity, it is inversely quadratic proportional to the square of the area, so that this principle enables to define fitting function for the distance between any two fireflies. For the optimization of fitting function, the individuals are forced to systematic or random moves in the population. In this way, it is ensured that all the fireflies move toward to more attractive ones which have brighter flashing until the population converge to brightest one. Within this procedure, firefly algorithm is executed by three parameters which are attractiveness, randomization, and absorption [3].

2. Life cycle of Firefly Algorithm

Fig1: Life circle of Firefly Algoritm

        Fig1 shows the Life cycle of Firefly Algorithm. The Adult Firefly is the one we know and love. They only in this for a few weeks. Their only mission now is to mate. Female Fireflies lay about 100 eggs in the grass or on the ground. Most of the Firefly is in this Larva stage [4]. They lives like this for 1-3 years spending winter underground or beneath the bark of a tree. Larva forms a peotective covering as it changes into an awasome firefly. This process takes about 2 and a half weeks either underground or on a tree branch [5].

3. Firefly Algorithm

        Fireflies are unisexual, so one firefly will be attracted to other fireflies regardless of their sex. Their attractiveness is proportional to their brightness, and both decrease as their distance increases. Thus, for any two flashing fireflies, the less brighter one will move toward the brighter one. If a particular firefly does not find a brighter one, it will move randomly. The brightness of a firefly is determined by the landscape of the objective function [6]. The “firefly algorithm” (FFA) is a modern metaheuristic algorithm, inspired by the behavior of fireflies. This algorithm and its variants have been successfully applied to many continuous optimization problems. This work analyzes the performance of the FFA when solving combinatorial optimization problems. In order to improve the results, the original FFA is extended and improved for self-adaptation of control parameters, and thus more directly balancing between exploration and exploitation in the search process of fireflies [7]. We use a new population model to increase the selection pressure, and the next generation selects only the fittest between a parent and an offspring population. The brightness of a firefly is affected or determinedby the landscape of the objective function. For a maximization problem, thebrightness can simply be proportional to the value of the objective function.Other forms of brightness can be defined in a similar way to the fitness functionin genetic algorithms [8].

Fig2: Firefly Algorithm

3.1. Attractiveness and distance

        The primary parameter which determines the efficiency of the FA is the variation of light intensity, i.e., attractiveness between neighboring fireflies. In FA, there are two important issues: formulation of attractiveness and variation of light intensity [9]. For simplicity, it is assumed that the attractiveness of a firefly is determined by its brightness which is always encoded with the objective function [10].

4. Steps for Firefly Algorithm

  • Initialization
  • Attaractiveness and Distance
  • Generate the next generation
  • Iterative computing
  • Termination

4.1. Initialization

         The main steps of the FA start from initializing a swarm of fireflies, each of which is determined the flashing light intensity. During the loop of pair wise comparison of light intensity, the firefly with lower light intensity will move toward the higher one [11]. The moving distance depends on the attractiveness. After moving, the new firefly is evaluated and updated for the light intensity.

4.2. Attractiveness and Distance

          Firefly algorithm is based on two important factors: variation of light intensity and formulation of the attractiveness. An assumption is made that attractiveness of a firefly is calculated according its brightness which is associated further with the encoded objective function [12].

4.3. Generate the next generation

          The  firefly  is re-initialized with a new random position in the search space, if its status is inactive. In the FA, as per our objective, we recast the  algorithm and employed it to reposition the random  firefly. In this, we reduce the TEST phase as per the requirement for the random  firefly and assume the random  firely as an inactive agent [13]. Now, for the randomly selected  firefly, another  firefly is selected from the swarm. If the   firefly has more brightness than the random selected  firefly then the random  firefly initializes itself to a new position in the neighboring region of the firefly, otherwise the selected  firefly re-initialize itself randomly in the search space [14].

4.4. Iterative computing

         In computational mathematics, an iterative method is a mathematical procedure that uses an initial guess to generate a sequence of improving approximate solutions for a class of problems, in which the n-th approximation is derived from the previous ones [15].

 4.5. Termination

         The Firefly Algorithm (FA) is a nature – inspired algorithm which is based on the social flashing behavior of fireflies. Attractiveness is proportional to their flashing brightness which decreases as the distance from the other firefly increases due to the fact that the air absorbs light [16]. 

4.6. Flow Chart

Fig3: Flowchart of FA

5. Numerical Expression for FA      

      The main steps of the FA start from initializing a swarm of fireflies, each of which is determined the flashing light intensity. During the loop of pair wise comparison of light intensity, the firefly with lower light intensity will move toward the higher one [17]. The moving distance depends on the attractiveness. After moving, the new firefly is evaluated and updated for the light intensity [18].

          In this work, the evaluation on the goodness of schedules is measured by the makespan, which can be calculated using  this equation , where Ck is completed time of job k.


  Speed sequence      Distance        (rij) Attractiveness         ( βr)   Movement        (Xi) Sequence for      Next generation   Makespan
   2 3 5 1 4       0.6       0.55     0.9986     2 3 5 1 4      48
   3 2 5 1 4       0.7      0.497     1.6388     3 2 5 1 4      48
   2 4 3 5 1       0.4     0.6703     0.6703     2 4 3 5 1      45
   1 5 2 3 4       1.2     0.3012     2.2943     1 2 5 3 4      45

6. Applications of Firefly Algorithm

  • For solving Travelling Salesman problem[19]
  • Digital image compression and image processing
  • Feature selection and fault processing
  • Antenna design
  • Structural design[20]
  • Scheduling
  • Chemical phase equlibrium[21]
  • Dynamic problems

Fig4: Applications of FA

7. Advantages of Firefly Algorithm

  • Firefly can be accessed anywhere with a web browser and an internet connection. This makes it a potentially more convenient and portable tool than Kurzweil [22].
  • The reading voices in Firefly are, as a whole, superior to those in the Mac version of Kurzweil.
  • Firefly is comparable to Kurzweil (both Windows and Mac versions) in its ability to translate text. Unlike Mac Kurzweil, Firefly can also intelligibly read text in Spanish [23].
  • FA can deal with highly non- linear, multimodel optimization problems naturally and effictively.
  • FA does not use velocities, and there is no problem as that associated with velocity in PSO [24].
  • The speed of convergence of FA is very high in probability of finding the global optimized answer.
  • It has the flexibility of integration with other optimization techniques to form hybrid tools.
  • It does not require a good initial solution to start its iteration process.


[1] Li, J. (2014). The Shortest Path Optimization Based on Mutation Firefly Optimization Algorithm. Advanced Materials Research, 1049-1050, pp.1690-1693. 

[2] Arora, S. and Kaur, R. (2018). An escalated convergent firefly algorithm. Journal of King Saud University – Computer and Information Sciences.

[3] Weber, P. and Pepłowski, P. (2014). Gaussian Motion Competing with L\’evy Flights. Acta Physica Polonica B, 45(11), p.2067.

[4] Fister, I., Perc, M., Kamal, S. and Fister, I. (2015). A review of chaos-based firefly algorithms: Perspectives and research challenges. Applied Mathematics and Computation, 252, pp.155-165.

[5] Johari, N., Zain, A., Noorfa, M. and Udin, A. (2013). Firefly Algorithm for Optimization Problem. Applied Mechanics and Materials, 421, pp.512-517.

[6] Mishra, A., Agarwal, C., Sharma, A. and Bedi, P. (2014). Optimized gray-scale image watermarking using DWT–SVD and Firefly Algorithm. Expert Systems with Applications, 41(17), pp.7858-7867.

[7] Tighzert, L., Fonlupt, C. and Mendil, B. (2018). A set of new compact firefly algorithms. Swarm and Evolutionary Computation, 40, pp.92-115.

[8] Kopciewicz, P. and Łukasik, S. (2019). Exploiting flower constancy in flower pollination algorithm: improved biotic flower pollination algorithm and its experimental evaluation. Neural Computing and Applications.

[9] Liu, F., Li, F. and Jing, X. (2019). Navigability Analysis of Local Gravity Map With Projection Pursuit-Based Selection Method by Using Gravitation Field Algorithm. IEEE Access, 7, pp.75873-75889.

[10] Teng, L. and Li, H. (2018). Modified Discrete Firefly Algorithm Combining Genetic Algorithm for Traveling Salesman Problem. TELKOMNIKA (Telecommunication Computing Electronics and Control), 16(1), p.424.

[11] Rajinikanth, V. and Couceiro, M. (2015). RGB Histogram Based Color Image Segmentation Using Firefly Algorithm. Procedia Computer Science, 46, pp.1449-1457.

[12] Wang, J. (2017). Firefly algorithm with dynamic attractiveness model and its application on wireless sensor networks. International Journal of Wireless and Mobile Computing, 13(3), p.223.

[13] Jagatheesan, K., Anand, B., Samanta, S., Dey, N., Ashour, A. and Balas, V. (2019). Design of a proportional-integral-derivative controller for an automatic generation control of multi-area power thermal systems using firefly algorithm. IEEE/CAA Journal of Automatica Sinica, 6(2), pp.503-515.

[14] Bojic, I., Podobnik, V., Ljubi, I., Jezic, G. and Kusek, M. (2012). A self-optimizing mobile network: Auto-tuning the network with firefly-synchronized agents. Information Sciences, 182(1), pp.77-92.

[15] Brajević, I. and Stanimirović, P. (2018). An improved chaotic firefly algorithm for global numerical optimization. International Journal of Computational Intelligence Systems, 12(1), p.131.

[16] Miguel, L., Lopez, R. and Miguel, L. (2013). Multimodal size, shape, and topology optimisation of truss structures using the Firefly algorithm. Advances in Engineering Software, 56, pp.23-37.

[17] Baykasoğlu, A. and Ozsoydan, F. (2014). An improved firefly algorithm for solving dynamic multidimensional knapsack problems. Expert Systems with Applications, 41(8), pp.3712-3725.

[18] Baykasoğlu, A. and Ozsoydan, F. (2014). An improved firefly algorithm for solving dynamic multidimensional knapsack problems. Expert Systems with Applications, 41(8), pp.3712-3725.

[19] Coelho, L. and Mariani, V. (2013). Improved firefly algorithm approach applied to chiller loading for energy conservation. Energy and Buildings, 59, pp.273-278.

[20] ZHENG, H., LIU, H. and ZHENG, X. (2013). Group path planning method based on improved group search optimization algorithm. Journal of Computer Applications, 32(8), pp.2223-2226.

[21] Wang, D., Luo, H., Grunder, O., Lin, Y. and Guo, H. (2017). Multi-step ahead electricity price forecasting using a hybrid model based on two-layer decomposition technique and BP neural network optimized by firefly algorithm. Applied Energy, 190, pp.390-407.

[22] Singh, D., Singh, D. and Verma, K. (2008). GA based energy loss minimization approach for optimal sizing & placement of distributed generation. International Journal of Knowledge-based and Intelligent Engineering Systems, 12(2), pp.147-156.

[23] Gholizadeh, S. (2015). Performance-based optimum seismic design of steel structures by a modified firefly algorithm and a new neural network. Advances in Engineering Software, 81, pp.50-65. [24] Tawhid, M. and Ali, A. (2016). Direct Search Firefly Algorithm for Solving Global Optimization Problems. Applied Mathematics & Information Sciences, 10(3), pp.841-860.

Leave a Reply

%d bloggers like this: