Animal and swarm-inspired algorithmsVerified

Snake Optimizer

Snake Optimizer (SO)

Year introduced
2022
Original authors
Fatma A. Hashim; Abdelazim G. Hussien
Source of inspiration
Snakes and mating behaviour
Search space
Continuous
Optimization types
Hyperparameter Optimization
Applied research in the repository
0

Overview

It imitates the mating behaviour of snakes, which is affected by temperature and food availability. The population is split into males and females; when food is scarce each snake searches randomly, when food is available and the weather is warm it feeds near the food, and in the cold it enters fighting or mating, which produces eggs that replace the worst.

Source of inspiration and mechanism

Image illustrating the source of inspiration of the SO algorithm: Snakes and mating behaviour
Snakes and mating behaviourImage: Rushenb · CC BY-SA 2.0 · Wikimedia Commons

Snakes usually mate in late spring and early summer, when the temperature is moderate and food is available; the males may fight over the females, and the female chooses her mate.

Initialization

Random, with two equal groups.

Update mechanism

According to Q and Temp.

Exploration

Q < 0.25.

Exploitation

Feeding near the food, fighting and mating.

Mathematical description

The food quantity is Q = c1·exp((t − T)/T) and the temperature Temp = exp(−t/T). If Q < 0.25 it is random exploration; otherwise, if Temp > 0.6, feeding near the food, otherwise fighting or mating according to a probability.

Temperature

Temp = \exp\!\left(\frac{-t}{T}\right)

Amount of food

Q = c_1 \exp\!\left(\frac{t-T}{T}\right),\quad c_1 = 0.5

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

Flowchart

StartInitialisationRandom, with two equal groupsEvaluationCompute the objective and find the bestsolutiont ≤ T ?ExplorationExploitationFeeding near the food, fighting and matingUpdate ruleAccording to Q and TempUpdate bestKeep the best solution and set t = t + 1EndReturn the best solutionYesNo

A simplified chart summarising the algorithm phases as described on its card in the lab; it is not the original figure published in the paper.

Pseudocode

Initialize; split males/females
for t = 1..T:
    Temp = exp(-t/T); Q = c1*exp((t - T)/T)
    if Q < 0.25: exploration (random)
    elif Temp > 0.6: exploitation toward food
    else: fight or mating; replace worst by eggs
return best

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
c1
c_1
0.5
c2
c_2
0.05
c3
c_3
2

Advantages

  • Splitting into two groups preserves diversity
  • An egg renewal mechanism.

Limitations

Several constants (c1, c2, c3, the thresholds).

Use in artificial intelligence

Domains documented in the card: Machine learning, hyperparameter tuning

Continuous and engineering optimization.

Hybridization potential

No hybridization partners recorded in the card.

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

Fatma A. Hashim; Abdelazim G. Hussien (2022). Snake Optimizer: A novel meta-heuristic optimization algorithm. Knowledge-Based Systems, Elsevier BV.

Verified DOI: 10.1016/j.knosys.2022.108320

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