Cuckoo Search
Cuckoo Search (CS)
- Year introduced
- 2009
- Original authors
- Xin-She Yang; Suash Deb
- Source of inspiration
- Cuckoo brood parasitism with Lévy flights
- Search space
- Continuous
- Optimization types
- Hyperparameter Optimization, Feature Selection
- Applied research in the repository
- 0
Overview
A new solution is generated by a Lévy flight and replaces a random nest if it is better, then a fraction pa of the nests is abandoned and replaced with new solutions.
Source of inspiration and mechanism

Some cuckoo species lay their eggs in the nests of other birds, and the host bird may discover the alien eggs and get rid of them. The algorithm combines this idea with Lévy flights, which have rare long steps.
Initialization
Random nests.
Update mechanism
Greedy replacement and probabilistic abandonment.
Exploration
Long Lévy steps and nest abandonment.
Exploitation
Frequent short steps around good solutions.
Mathematical description
Lévy flight
x_i^{t+1} = x_i^{t} + \alpha \oplus \text{L\'evy}(\lambda)⊕ is element-wise multiplication; the steps come from a heavy-tailed distribution.
Mantegna's algorithm
s = \frac{u}{|v|^{1/\beta}},\ u\sim N(0,\sigma_u^2),\ v\sim N(0,1),\ \sigma_u = \left[\frac{\Gamma(1+\beta)\sin(\pi\beta/2)}{\Gamma\!\left(\frac{1+\beta}{2}\right)\beta\,2^{(\beta-1)/2}}\right]^{1/\beta}β≈1.5 usually.
Computational complexity: O(T\cdot n\cdot (D + C_f))
Pseudocode
Initialize n nests
for t = 1..T:
get a cuckoo by Levy flight; evaluate
choose a random nest j; replace if better
abandon a fraction pa of worse nests and build new ones
keep best
return bestPython implementation
This code was actually run while building the lab (NumPy) on the sphere function to make sure it works; this is a run test, not a performance claim.
import numpy as np
from math import gamma as G, sin, pi
def levy(rng, dim, beta=1.5):
"""Mantegna's algorithm for Levy-stable steps."""
sigma = (G(1 + beta) * sin(pi * beta / 2) / (G((1 + beta) / 2) * beta * 2 ** ((beta - 1) / 2))) ** (1 / beta)
return rng.normal(0, sigma, dim) / np.abs(rng.normal(0, 1, dim)) ** (1 / beta)
def cuckoo(f, lb, ub, dim, n=25, iters=200, pa=0.25, alpha=0.01, seed=0):
"""Cuckoo Search via Levy flights (Yang & Deb, 2009)."""
rng = np.random.default_rng(seed)
nest = rng.uniform(lb, ub, (n, dim)); F = np.apply_along_axis(f, 1, nest)
curve = []
for _ in range(iters):
best = nest[F.argmin()]
for i in range(n): # new solutions by Levy flights
new = np.clip(nest[i] + alpha * levy(rng, dim) * (nest[i] - best) * (ub - lb) / 10, lb, ub)
j = rng.integers(n); fn = f(new)
if fn < F[j]:
nest[j], F[j] = new, fn
K = rng.random((n, dim)) > pa # abandon a fraction pa of nests
step = rng.random() * (nest[rng.permutation(n)] - nest[rng.permutation(n)])
new = np.clip(nest + step * K, lb, ub); Fn = np.apply_along_axis(f, 1, new)
imp = Fn < F; nest[imp], F[imp] = new[imp], Fn[imp]
curve.append(F.min())
b = F.argmin()
return nest[b], F[b], curve
if __name__ == "__main__":
sphere = lambda z: float(np.sum(z ** 2))
best, val, curve = cuckoo(sphere, -100, 100, dim=10)
print("best fitness:", val)
Coefficients
| Parameter | Symbol | Typical value | Range | Description |
|---|---|---|---|---|
| Discovery rate | pa | 0.25 | 0.1 – 0.5 | Fraction of abandoned nests |
| Step size | α | 0.01·L | Step scale | |
| Lévy exponent | β | 1.5 | 1 – 2 |
Advantages
- Few parameters
- Lévy flights help escape local optima.
Limitations
- Relatively slow final convergence
- The metaphor adds little over guided random search.
Use in artificial intelligence
Domains documented in the card: Machine learning, Feature Selection, hyperparameter tuning
Multimodal continuous optimization, engineering design, parameter tuning.
Hybridization potential
- DE — Differential Evolution Design this hybrid
- GA — Genetic Algorithm Design this hybrid
- PSO — Particle Swarm Optimization Design this hybrid
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.
Related lessons
Original reference
Xin-She Yang; Suash Deb (2009). Cuckoo Search via Lévy flights. 2009 World Congress on Nature & Biologically Inspired Computing (NaBIC), IEEE.
Verified DOI: 10.1109/NABIC.2009.5393690
Additional original reference: Cuckoo Search via Lévy flights
