Home \ Metaheuristics \ Firefly Algorithm (FA) in MATLAB

Firefly Algorithm (FA) in MATLAB

Firefly Algorithm (FA) is a metaheuristic algorithm for global optimization, which is inspired by flashing behavior of firefly insects. This algorithm is proposed by Xin-She Yang in 2008. Fireflies use the flashing behavior to attract other fireflies, usually for sending signals to opposite sex. However, in the mathematical model, used inside Firefly Algorithm, simply the fireflies are unisex, and any firefly can attract other fireflies.

Attractiveness of a firefly is proportional to its brightness and for any couple of fireflies, the brighter one will attract the other; so the less bright one is moved towards the brighter one. This is performed for any binary combination of fireflies in the population, on every iteration of algorithm. For more information, you can refer to the related article on Wikipedia, here.

In this post, we are going to share with you, the open-source MATLAB implementation of Firefly Algorithm (FA), which is easy to use within your research and projects, if you are familiar with MATLAB programming language.


The download link of this project follows.

Implementation of Firefly Algorithm (FA) in MATLAB


Citing This Work

If you wish, you can cite this content as follows.

Cite as:

Mostapha Kalami Heris, Firefly Algorithm (FA) in MATLAB (URL: https://yarpiz.com/259/ypea112-firefly-algorithm), Yarpiz, 2015.


  1. Thanks for your sharing of implementation, I’m going to look into these ml related works, I bet they are very helpful. However, if you could provide any explanations on this website about all these projects and topics, especially the intuition behind it, that would be very informative. Thanks.

    • Thanks for your comment and warm message. Brief explanation of the algorithms and codes is currently being completed. For some posts, just the source codes are provided; so the people can download and use them, in their projects and research.

  2. thank you for the material ,just downloaded it , will contact soon for doubts

  3. Thank you so much for the code

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.


Check Also

Particle Swarm Optimization (PSO) in MATLAB -- Video Tutorial

Particle Swarm Optimization (PSO) in MATLAB – Video Tutorial

Particle Swarm Optimization (PSO) is an intelligent algorithm leveraging principles from Swarm Intelligence, inspired by ...