A comprehensive collection of mathematical benchmark functions for testing optimization algorithms
Project description
optimization-benchmarks
A comprehensive Python package providing 50+ classical mathematical benchmark functions for testing and evaluating optimization algorithms.
🎯 Features
- 50+ Standard Benchmark Functions: Including Ackley, Rastrigin, Rosenbrock, Griewank, and many more
- Vectorized NumPy Implementation: Fast and efficient computation
- Well-Documented: Each function includes domain constraints and global minima
- Type Hints: Full type annotation support
- Command-Line Interface: Evaluate functions directly from the terminal
- Zero Dependencies: Only requires NumPy
- Academic Citations: Properly cited mathematical formulations
📦 Installation
From PyPI
pip install optimization-benchmarks
From Source
git clone https://github.com/ak-rahul/optimization-benchmarks.git
cd optimization-benchmarks
pip install -e .
🚀 Quick Start
import numpy as np
from optimization_benchmarks import ackley, rastrigin, rosenbrock
x = np.zeros(5)
result = ackley(x)
print(f"Ackley(0) = {result}") # Should be close to 0
x = np.ones(10)
result = rosenbrock(x)
print(f"Rosenbrock(1) = {result}") # Should be 0
x = np.random.randn(5)
result = rastrigin(x)
print(f"Rastrigin(x) = {result}")
📊 Usage Examples
Benchmarking an Optimization Algorithm
import numpy as np
from optimization_benchmarks import ackley, rastrigin, sphere
def my_optimizer(func, bounds, max_iter=1000):
"""Your optimization algorithm here."""
# ... implementation ...
pass
test_functions = {
'Sphere': (sphere, [(-5.12, 5.12)] * 10),
'Ackley': (ackley, [(-32, 32)] * 10),
'Rastrigin': (rastrigin, [(-5.12, 5.12)] * 10),
}
for name, (func, bounds) in test_functions.items():
best_x, best_f = my_optimizer(func, bounds)
print(f"{name}: f(x*) = {best_f}")
🎮 Command-Line Interface
The package includes a CLI for quick function evaluation:
List all available functions
optbench --list
Get function information
optbench --info ackley
Evaluate a function
optbench --function rastrigin --values 0 0 0 0 0
Batch evaluation from CSV
optbench --function sphere --input points.csv --output results.json
📚 Available Functions
Multimodal Functions
ackley- Multiple local minima with deep global minimumrastrigin- Highly multimodal with regular structuregriewank- Multimodal with product termschwefel2_26- Deceptive with distant global minimumlevy- Multimodal with sharp global minimummichalewicz- Steep ridges and valleys
Unimodal Functions
sphere- Simple convex quadraticrosenbrock- Narrow curved valleysum_squares- Weighted sphere functionhyperellipsoid- Axis-parallel ellipsoid
2D Test Functions
beale- Narrow valleybooth- Simple quadraticmatyas- Plate-like surfacehimmelblau- Four identical local minimagoldstein_price- Multiple local minimaeasom- Flat surface with narrow peak
Special Functions
branin- Three global minimacamel3- Three-hump camel functioncamel6- Six-hump camel functionkowalik- Parameter estimation problemlangerman- Multimodal test function
And 30+ more functions!
🔬 Function Properties
Each function includes:
- Domain: Valid input ranges
- Dimension: Number of variables (n for arbitrary dimensions)
- Global Minimum: Known optimal value and location
- Mathematical Formula: Documented in docstrings
🎓 Academic Use
This package is perfect for:
- Algorithm Development: Test new optimization algorithms
- Comparative Studies: Benchmark against existing methods
- Academic Research: Reproduce published results
- Teaching: Demonstrate optimization concepts
- Thesis Projects: Comprehensive evaluation suite
Citing This Package
If you use this package in academic work, please cite:
@software{optimization_benchmarks,
author = {AK Rahul},
title = {optimization-benchmarks: Benchmark Functions for Optimization Algorithms},
year = {2025},
publisher = {PyPI},
url = {https://github.com/ak-rahul/optimization-benchmarks}
}
Mathematical Formulations Based On
[1] Adorio, E. P. (2005). MVF - Multivariate Test Functions Library in C.
[2] Surjanovic, S. & Bingham, D. (2013). Virtual Library of Simulation Experiments.
[3] Jamil, M., & Yang, X. S. (2013). A literature survey of benchmark functions for global optimization problems.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Quick Contribution Guide
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/new-function`)
3. Add your function to `functions.py`
4. Add tests to `tests/test_functions.py`
5. Run tests: `pytest`
6. Submit a pull request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Mathematical formulations based on the MVF C library by E.P. Adorio
- Function definitions from Virtual Library of Simulation Experiments
- Inspired by the optimization research community
📞 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
🔗 Related Projects
- SciPy Optimize - Optimization algorithms
- PyGMO - Massively parallel optimization
- DEAP - Evolutionary algorithms
Made with ❤️ for the optimization community
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optimization_benchmarks-0.1.0.tar.gz.
File metadata
- Download URL: optimization_benchmarks-0.1.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
566ebdf847c3fb429a5e5d2bc3e14d3307eca755ac593485ce5ff85e3ae17125
|
|
| MD5 |
2510bec303f44e8816be4752b4969582
|
|
| BLAKE2b-256 |
962a74fd0ca0d0378214c264e0fa4f979d0aa1a0e58dc91fa24eda33ef2f03a7
|
File details
Details for the file optimization_benchmarks-0.1.0-py3-none-any.whl.
File metadata
- Download URL: optimization_benchmarks-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4da543f5e2020903aac4ee67720f752fd2071d2852220a28d8d58d0aa61c5bf1
|
|
| MD5 |
0e26ed44934ea63610ea8f1ee6bb1d76
|
|
| BLAKE2b-256 |
3556a75d30ed0e535586d59bc8df310dd01c616fcf4eaa0e17c57dbb4e66d407
|