Ackley Function
Introduction
The Ackley function is a widely used multimodal benchmark function for testing optimization algorithms. It features many local minima and a single global minimum, making it an excellent test for an algorithm's ability to avoid getting trapped in local optima.
Mathematical Definition
The Ackley function is defined as:
Where:
- \(a = 20\) (amplitude of exponential term)
- \(b = 0.2\) (exponential decay factor)
- \(c = 2\pi\) (frequency of cosine term)
- \(d\) = dimensionality
- \(e\) = Euler's number
Properties
- Global minimum: \(f(0, 0, ..., 0) = 0\)
- Search domain: Typically \([-32.768, 32.768]^d\) or \([-5, 5]^d\)
- Multimodal: Many local minima
- Non-separable: Variables are coupled
- Differentiable: Smooth function
- Scalable: Can be used in any dimension
Usage Example
from hyperactive.experiment.bench import Ackley
from hyperactive.opt.gfo import RandomSearch
exp = Ackley(d=2)
opt = RandomSearch(experiment=exp)
best = opt.solve()
Characteristics for Algorithm Testing
What the Ackley Function Tests
- Global vs Local Search: Can the algorithm escape local minima?
- Exploitation: Can it fine-tune around the global optimum?
- Scalability: How does performance change with dimensionality?
- Robustness: Consistent performance across runs?
Expected Behavior
- Random Search: Explores broadly but may miss global optimum
- Hill Climbing: Often gets trapped in local minima
- Simulated Annealing: Can escape local minima with proper cooling
- Bayesian Optimization: Usually finds global optimum efficiently
- Population Methods: Good at avoiding local minima
Multi-Dimensional Usage
Visualization
The Ackley function in 2D shows: - A central valley leading to the global minimum at (0,0) - Many small local minima scattered across the surface - Exponential decay from the center - High-frequency oscillations creating the local minima
Algorithm Comparison Example
Parameter Sensitivity
The Ackley function parameters affect difficulty:
References
- Ackley, D. H. (1987). A connectionist machine for genetic hillclimbing.
- Jamil, M., & Yang, X. S. (2013). A literature survey of benchmark functions for global optimization problems.