It is convenient to explain the algorithm from the pseudo code. Considering the algorithm of Firely as given in Yang (2008).

Randomly generate n firefly populations

for k = 1: max_iterations

Initially, compute light intensity I (brightness) for each firefly

For i = 1: n

for j = 1:n (inner loop)

% update intensity for each firefly

if(Ii < Ij), then move firefly i towards j

end

end

rank the fireflies and find the best global g (store the best solution for each iteration)

end

The following diagram explains the algorithm:

__Citation:__

Adisorn Owatsiriwong (2024). Firefly Algorithm: Part II(https://www.mathworks.com/matlabcentral/fileexchange/160078-firefly-algorithm-part-ii), MATLAB Central File Exchange. Retrieved February 24, 2024.

__References:__
XS Yang (2010), Nature-Inspired Metaheuristic Algorithms, 2nd edition

OpenAI. (2024). *ChatGPT* [Large language model]. /g/g-5QhhdsfDj-diagrams-show-me