Why can't I reproduce the experiments in the original paper that introduced the Firefly Algorithm?
I wrote some python code to reproduce this paper's purported results. My code very efficiently optimizes simple smooth functions like bowls, but does not come close to reproducing the paper's claimed results on more complex functions, including with the parameters the authors report. I think that, since both @Jairo and I were unable to reproduce the results from the information in the paper, independently, it is likely that something is wrong with the paper.

It may be possible to reproduce the paper's claimed behaviors using a library like py_swarm, however the paper is using a Firefly Algorithm (already a rarer form of a PSO), and is using a home-brew variant of that algorithm, so my guess is that rolling your own is required, as we both did.

Additionally, I find the paper's claims fairly unlikely. For example, in section 4.1, they claim to converge on the global minimum of a function with many local minima in just 10 iterations. It seems to me like most of the time the fireflies will quickly converge on the bottom of one of the gullies in this function, and get stuck there. This is also what I observe in my replications. I suspect the authors may have cherry-picked their results from the best runs without reporting this, or have omitted some key detail from the paper.

Here is my replication code, in case someone else wants to try to reproduce this:

from math import sin, pi, exp, sqrt
from random import random
from copy import deepcopy

def michalewiz_objective(x):
    result = 0
    for i, x_i in enumerate(x):
        result -= sin(x_i)*(sin(i*(x_i**2)/pi))**20
    return -result

def bowl_objective(x):
    return -sum([x_i**2 for x_i in x])

pop_size = 40
max_generations = 10
alpha = 0.2
gamma = 1
beta_0 = 1
d = 2
I = michalewiz_objective
#I = bowl_objective

def move(firefly, other_firefly):
    radius = sqrt(sum([(firefly[i] - other_firefly[i])**2 for i in range(0, len(firefly))]))
    for i, value in enumerate(firefly):
        firefly[i] += beta_0*exp(-gamma*radius**2)*(other_firefly[i] - firefly[i])
        firefly[i] += alpha * (random() - 0.5)

# Using 4*random() to match Figure 3's apparent spread.
fireflies = [[4*random() for i in range(0, d)] for j in range(0, pop_size)]

for generation in range(0, max_generations):
    new_fireflies = [deepcopy(firefly) for firefly in fireflies]
    for index, firefly in enumerate(fireflies):
        for other_firefly in fireflies:
            if I(other_firefly) &gt; I(firefly):
                move(new_fireflies[index], other_firefly)
    fireflies = new_fireflies
    best = max([I(f) for f in fireflies])
    mean = [sum([f[0] for f in fireflies]), sum([f[1] for f in fireflies])]
    print(best)
    print(mean)