Animal and swarm-inspired algorithmsVerified

Mayfly Algorithm

Mayfly Algorithm (MA)

Year introduced
2020
Original authors
Konstantinos Zervoudakis; Stelios Tsafarakis
Source of inspiration
Mayfly (Ephemeroptera)
Search space
Continuous
Optimization types
Hyperparameter Optimization, Feature Selection, Weight Optimization
Applied research in the repository
0

Overview

It combines the strengths of particle swarm optimization and the genetic algorithm, inspired by the mating behaviour of the mayfly: the males gather in swarms and dance above the water, the females fly towards them, then mating (crossover) takes place and offspring are produced with mutation.

Source of inspiration and mechanism

Image illustrating the source of inspiration of the MA algorithm: the mayfly (Ephemeroptera)
Mayfly (Ephemeroptera)Image: Richard Bartz, Munich aka Makro Freak Image:MFB.jpg · CC BY-SA 2.5 · Wikimedia Commons

The adult mayfly lives for a day or less; the males form dancing swarms above the water to attract the females, and mating happens quickly in the air.

Initialization

Random male and female populations.

Update mechanism

A PSO-like update, then crossover and mutation.

Exploration

The random dance, the random flight of the females, and mutation.

Exploitation

Attraction to pbest and gbest.

Mathematical description

The male velocity is v = g·v + a1·e^{−βr_p²}(pbest − x) + a2·e^{−βr_g²}(gbest − x), where r_p and r_g are the two distances. The best males perform a random "dance", v = g·v + d·r. The females are attracted to the matching male if it is better, otherwise they fly randomly. Mating is a linear crossover between a male and a female.

Male velocity

v_{ij}^{t+1} = g\,v_{ij}^{t} + a_1 e^{-\beta r_p^2}\left(pbest_{ij} - x_{ij}^{t}\right) + a_2 e^{-\beta r_g^2}\left(gbest_j - x_{ij}^{t}\right)

g is the gravity weight, β a constant visibility factor.

Mating

off_1 = L\cdot male + (1-L)\cdot female,\qquad off_2 = L\cdot female + (1-L)\cdot male

L random.

Computational complexity: O(T\cdot N\cdot (D + C_f))

Pseudocode

Initialize males and females
for t = 1..T:
    update male velocities (pbest, gbest) and positions
    update female velocities (attraction to paired male) and positions
    mate males and females (crossover), mutate offspring
    replace worst with best offspring
return gbest

Python implementation

There is currently no tested python implementation of this algorithm in the lab. We did not include untested code so that it is not used as a reference implementation.

Coefficients

ParameterSymbolTypical valueRangeDescription
a1
a_1
1
a2, a3
a_2, a_3
1.5
β
\beta
2
Dance
d
5

Advantages

Combines the memory of PSO with the diversity of GA.

Limitations

A large number of parameters (a1, a2, a3, β, d, fl, g).

Use in artificial intelligence

Domains documented in the card: Machine learning, deep learning, Feature Selection, hyperparameter tuning

Continuous and multimodal optimization.

Hybridization potential

These are partnerships suggested theoretically in the card; any resulting design is presented as a "proposed hybrid method" until its results are compared with the literature.

Applied research from the repository

An aspect that did not appear in the current search results within the repository. This does not mean there is no published research outside it.

Original reference

Konstantinos Zervoudakis; Stelios Tsafarakis (2020). A mayfly optimization algorithm. Computers & Industrial Engineering, Elsevier BV.

Verified DOI: 10.1016/j.cie.2020.106559

The bibliographic data match the Crossref record (checked 2026-11-20). There is no tested Python code for this algorithm in this version.