Skip to content

Nelder-Mead

Classical

Nelder-Mead Simplex Method optimization algorithm.

Algorithm Overview

This module implements the Nelder-Mead optimization algorithm. Nelder-Mead is a derivative-free optimization method that uses only function evaluations (no gradients). It works by maintaining a simplex of n+1 points in n-dimensional space and iteratively replacing the worst point with a better one through reflection, expansion, contraction, and shrinkage operations.

The Nelder-Mead method is particularly useful for:

  • Functions where gradients are not available or difficult to compute
  • Noisy functions
  • Functions with discontinuities
  • Black-box optimization problems

This implementation uses scipy's Nelder-Mead optimizer with multiple random restarts to improve global optimization performance.

Usage

python
from opt.classical.nelder_mead import NelderMead
from opt.benchmark.functions import sphere

optimizer = NelderMead(
    func=sphere,
    lower_bound=-5.12,
    upper_bound=5.12,
    dim=10,
    max_iter=500,
)

best_solution, best_fitness = optimizer.search()
print(f"Best solution: {best_solution}")
print(f"Best fitness: {best_fitness:.6e}")

Parameters

ParameterTypeDefaultDescription
funcCallableRequiredObjective function to minimize.
lower_boundfloatRequiredLower bound of search space.
upper_boundfloatRequiredUpper bound of search space.
dimintRequiredProblem dimensionality.
max_iterint1000Maximum iterations per restart.
num_restartsint25Number of random restarts for multistart strategy.
seedint | NoneNoneRandom seed for reproducibility.
target_precisionfloat1e-08Algorithm-specific parameter
f_optfloat | NoneNoneAlgorithm-specific parameter

Algorithm Metadata

PropertyValue
Algorithm NameNelder-Mead Simplex Method
AcronymNM
Year Introduced1965
AuthorsNelder, John; Mead, Roger
Algorithm ClassClassical
ComplexityO((n+1)×evals) per iteration
PropertiesDerivative-free, Deterministic
ImplementationPython 3.10+
COCO CompatibleYes

Mathematical Formulation

Simplex operations on (n+1) vertices {x0,...,xn}:

Reflection:

xr=x¯+α(x¯xn+1)

Expansion:

xe=x¯+γ(xrx¯)

Contraction:

xc=x¯+ρ(xn+1x¯)

Shrinkage:

xi=x0+σ(xix0)

where:

  • x¯ is the centroid of best n points
  • xn+1 is the worst vertex
  • α=1,γ=2,ρ=0.5,σ=0.5 are standard coefficients

Constraint handling:

  • Boundary conditions: Penalty-based (large value for out-of-bounds)
  • Feasibility enforcement: Post-optimization clamping to bounds

Hyperparameters

ParameterDefaultBBOB RecommendedDescription
max_iter100010000Maximum iterations
num_restarts2510-50Number of random restarts

Sensitivity Analysis:

  • num_restarts: High impact on finding global optimum
  • Recommended tuning ranges: num_restarts[10,50]

COCO/BBOB Benchmark Settings

Search Space:

  • Dimensions tested: 2, 3, 5, 10, 20, 40
  • Bounds: Function-specific (typically [-5, 5] or [-100, 100])
  • Instances: 15 per function (BBOB standard)

Evaluation Budget:

  • Budget: dim×10000 function evaluations
  • Independent runs: 15 (for statistical significance)
  • Seeds: 0-14 (reproducibility requirement)

Performance Metrics:

  • Target precision: 1e-8 (BBOB default)
  • Success rate at precision thresholds: [1e-8, 1e-6, 1e-4, 1e-2]
  • Expected Running Time (ERT) tracking

Raises

ValueError: If search space is invalid or function evaluation fails.

Notes

  • Modifies self.history if track_history=True
  • Uses self.seed for all random number generation
  • BBOB: Returns final best solution after max_iter or convergence

Computational Complexity:

  • Time per iteration: O((n+1)×fevals) for simplex operations
  • Space complexity: O(n2) for storing simplex vertices
  • BBOB budget usage: Typically uses 30-60% of dim×10000 budget

BBOB Performance Characteristics:

  • Best function classes: Non-smooth, Low-dimensional, Noisy functions
  • Weak function classes: High-dimensional, Ill-conditioned
  • Typical success rate at 1e-8 precision: 40-70% (dim=2-5)
  • Expected Running Time (ERT): Good on low-dim, degrades rapidly with dimension

Convergence Properties:

  • Convergence rate: Sub-linear in general (no quadratic convergence guarantee)
  • Local vs Global: Tends to find local optima, multistart essential for global search
  • Premature convergence risk: High without restarts (simplex can degenerate)

Reproducibility:

  • Deterministic: Yes (given same seed) - Same seed guarantees same restart points
  • BBOB compliance: seed parameter required for 15 independent runs
  • Initialization: Uniform random sampling in [lower_bound, upper_bound]
  • RNG usage: numpy.random.default_rng(self.seed) for restart initialization

Implementation Details:

  • Parallelization: Not supported (sequential restarts)
  • Constraint handling: Penalty-based during optimization, clamping post-optimization
  • Numerical stability: Sensitive to simplex degeneracy, SciPy includes safeguards

Known Limitations:

  • No gradient information used (slower than gradient methods on smooth functions)
  • Performance degrades rapidly with dimension (curse of dimensionality)
  • Simplex can collapse to subspace (degenerate simplex)
  • Lacks convergence guarantees for non-convex functions

Version History:

  • v0.1.0: Initial implementation with multistart strategy
  • v0.1.2: Added COCO/BBOB compliance documentation

References

[1] Nelder, J. A., & Mead, R. (1965). "A simplex method for function minimization." The Computer Journal, 7(4), 308-313. https://doi.org/10.1093/comjnl/7.4.308

[2] Wright, M. H. (1996). "Direct search methods: Once scorned, now respectable." Pitman Research Notes in Mathematics Series, 191-208.

[3] Hansen, N., Auger, A., Ros, R., Mersmann, O., Tušar, T., Brockhoff, D. (2021). "COCO: A platform for comparing continuous optimizers in a black-box setting." Optimization Methods and Software, 36(1), 114-144. https://doi.org/10.1080/10556788.2020.1808977

COCO Data Archive:

Implementation:

  • Original paper code: FORTRAN implementations available
  • This implementation: Based on SciPy's Nelder-Mead with multistart for BBOB compliance

See Also

Powell: Another derivative-free method using conjugate directions BBOB Comparison: Similar performance, Powell may converge faster on smooth functions

BFGS: Gradient-based alternative with faster convergence when gradients available BBOB Comparison: BFGS faster on smooth functions, Nelder-Mead better for non-smooth

AbstractOptimizer: Base class for all optimizers opt.benchmark.functions: BBOB-compatible test functions

Related BBOB Algorithm Classes:

  • Classical: Powell, HillClimbing, TabuSearch
  • Gradient: BFGS, LBFGS, ConjugateGradient

Benchmark Performance

Interactive fitness landscape of a representative multimodal benchmark function (drag to rotate, scroll to zoom):

Convergence, final-fitness distribution and performance profile on rastrigin (5D), averaged over independent runs (compared against representative baselines):


Source Code

View the implementation: nelder_mead.py

Released under the MIT License.