Adisorn Owatsiriwong

ALPS Consultants

__Introduction:__

Firefly algorithm is another metaheuristic approach for global optimization. The method was developed by Xin-She Yang (2008) based on the behavior of flashing fireflies to attract mates or prey. In this and the following articles, we will ground the basics of the Firefly algorithm; moreover, the pros and cons of the method compared to Particle Swarm Optimization (PSO) will be investigated by example of multi-modal objective functions. It can be later seen that FA and PSO share a similar concept of exploration and exploration in updating particle position. As seen in the figure below, this includes inertia, global best, and personal randomness.

__Concept:__

Like most population approaches, the Firefly algorithm starts by popularizing the agents (flyfires). Each firefly contains the element of design variables. Three main concepts are the backbone of the Flyfire algorithm:

Attraction: This is the key behavior of fireflies when interacting with others. In Yang's approach, fireflies will attract others regardless of gender.

__The less bright firefly will move towards the brighter one to achieve the exploration goal.__Brightness: The brightness is a source that attracts other fireflies regardless of the distance between them. The value of the objective function can represent brightness.

Absorptions: The brightness will decrease as the distance between two flies increases. This enforces the exploitation scheme as the fly would choose to move towards the closest brighter source (bringing the solution toward local minima).

The flowchart of Firefly algorithm can be shown in the figure below.

**Initialize Parameters:**Set the number of fireflies, light absorption coefficient, attractiveness, and other parameters.**Generate Initial Population:**Randomly initialize the positions of the fireflies.**Evaluate Fireflies:**Calculate the light intensity (objective function value) for each firefly.**Update Positions:**For each firefly, compare its light intensity with others and move it towards brighter fireflies.**Update Intensity:**Recalculate the light intensity after moving the fireflies.**Check Termination:**If the maximum number of generations is reached or another stopping criterion is met, terminate; otherwise, go back to step 4.**Output Best Solution:**Report the best solution found :

__References__

XS Yang, Nature-Inspired Metaheuristics Algorithms, 2nd Ed., Luniver Press

OpenAI. (2024). *ChatGPT* (4) [Large language model]. https://chat.openai.com

## Comments