Before discussing the implementation details, recall from the previous lesson how these illuminating creature uses fluorescent to communicate. In this lesson, we will see the Implementation of Firefly Algorithm. We know that the light intensity at a particular distance r from the light source obeys the inverse-square law. That is to say, the light intensity decrease as the distance r increases. Mathematically it is represented as follows.
I \propto \frac{1}{r^2}\\ I: intensity ~of~light~source\\ r: distance ~from~the~light~source\\
Following the principle of proportionality, The flashing light exhibited by fireflies can be incorporated. And, the formulation of an objective function is done which needs to be optimized. This integration enables the development of Firefly optimization algorithms. By linking the characteristics of the flashing light to the parameters and variables of the optimization problem. New innovative approaches can be devised to solve complex optimization challenges.
Firefly Algorithm:
The Firefly algorithm comes under the class of Evolutionary Algorithms (EAs). And, Evolutionary algorithms are known for their simplicity and easy design philosophy. Following the same, the Firefly algorithm makes the following assumptions in its design principle.
- The very first assumption in designing the Firefly algorithm is that all fireflies in the search space are unisex. This means that all fireflies are attracted to the flies with better illumination, which corresponds to a better fitness value.
- The attractiveness of a flashing firefly is directly proportional to its brightness. Consequently, when two fireflies are flashing, the less bright firefly will be inclined to move towards the brighter one. This attraction is influenced by the relative brightness levels of the fireflies, with the brighter firefly exerting a stronger pull.
- Additionally, both the attractiveness and brightness decrease as the distance between the fireflies increases. In cases where a firefly does not encounter a firefly that is brighter than itself, it will move randomly. In such instances, the absence of a brighter firefly negates the directional pull. And the firefly’s movement becomes more stochastic or based on chance. This random movement allows the firefly to explore its surroundings efficiently. Other fireflies might exhibit greater brightness, thus altering their trajectory accordingly.
- The brightness of a firefly is influenced or determined by the landscape of the objective function. In other words, the intensity exhibited by a firefly is directly related to the values of the objective function. And, the specific landscape of the objective function, including its peaks, and valleys affects the brightness of individual fireflies. The objective function acts as a guiding force that shapes the brightness levels of the fireflies. This reflects the suitability or fitness of their current positions in the search space.
Firefly Algorithm Working Principle:
With these assumptions, fireflies explore the search space and gather information about the fitness landscape. In the firefly algorithm, two crucial aspects are considered: the variation of light intensity and the formulation of attractiveness. To simplify the approach, it is commonly assumed that the attractiveness of a firefly is directly determined by its brightness. This brightness, in turn, is associated with the encoded objective function. The firefly algorithm can leverage the brightness of individual fireflies as a proxy for their attractiveness. Where brightness represents the fitness or quality of their current solution in relation to the objective function being optimized.
For maximization problems, the brightness of fireflies is denoted by I. And, their specific location in the search space is denoted by x. Fireflies are chosen proportionally to the objective function value f(x) at that position x. This implies that the brighter the firefly, the higher the fitness or quality of its solution. However, attractiveness, represented by β, is a relative measure and is perceived by other fireflies within the population. Therefore, it varies with the distance. The distance between fireflies influences the perceived attractiveness, with closer fireflies generally being considered more attractive than those farther away. This variation in attractiveness ensures that fireflies can evaluate and respond to the presence and quality of nearby neighbors. Next, we will see the detailed steps for the Implementation of Firefly Algorithm.
Pseudo-code for Firefly Algorithm:
The major steps of the Firefly algorithm are mentioned below.
In the above pseudo-code, many doubts may occur to you, but these missing gaps are put here intentionally. You are required to fill out gaps like the position update equation for the Firefly algorithm. In this lesson, we studied the Implementation of Firefly Algorithm. If you want to read for research-specific purposes, check out the research articles here. But if you want to implement the code of Firefly Algorithm in your favorite computing environment. We got you covered with MATLAB and Python code of the Firefly algorithm. Enjoyed Reading! consider sharing as well to support us. leave your comments below for any related queries. Happy Learning!