A robust implementation of the Simulated Annealing algorithm benchmarked against 55+ optimization test functions using the optimization-benchmarks package.
This repository contains a production-ready implementation of the Simulated Annealing metaheuristic algorithm with comprehensive benchmarking capabilities. The implementation features adaptive cooling, multiple restart strategies, and robust boundary handling.
- Robust Implementation: Handles multiple bound formats and edge cases
- Adaptive Cooling: Dynamic cooling rate adjustment based on acceptance ratio
- Multiple Restarts: 5 restart strategies for improved global search
- Comprehensive Benchmarking: Tested against 55 optimization functions
- Single Function Analysis: Detailed statistical analysis with 30 independent trials
- Production Ready: Error handling, type conversion, and boundary management
- Initial Temperature: 100.0
- Cooling Rate: 0.99 (adaptive: 0.98-0.995)
- Max Iterations: 20,000 per restart
- Restart Strategies: 5 (center, near-center, random, lower-biased, upper-biased)
- Temperature-dependent step size adaptation
- Metropolis acceptance criterion
- Adaptive cooling based on acceptance ratio
- Boundary clipping for constraint handling
- Scalar conversion for NumPy compatibility
| Metric | Value |
|---|---|
| Total Functions | 55 |
| Successfully Converged | 41/55 (74.5%) |
| Perfect Solutions | 27 functions (error = 0) |
| Median Error | 0.000279 |
| Average Time | 0.82s per function |
| Metric | Value |
|---|---|
| Success Rate | 100% (30/30 trials) |
| Mean Error | 0.0 |
| Std Dev Error | 0.0 |
| Average Time | 0.66s per trial |
- Clone repository locally:
git clone https://github.com/ak-rahul/Simulated-Annealing.git
cd Simulated-Annealing
- Upload to Google Colab:
- Go to Google Colab
- Click
File→Upload notebook - Select either:
Simulated-Annealing.ipynb(single function)Simulated-Annealing-with-Complete-Benchmarks.ipynb(all functions)
- Run in Colab:
- The notebook will automatically install
optimization-benchmarks - Click
Runtime→Run all - Results will be saved to Colab's
/content/directory
Single function benchmark with detailed analysis:
- 30 independent trials
- Statistical summary (mean, median, std dev)
- Individual trial results
- CSV export with metadata
Complete suite benchmark across all 55 functions:
- Per-function results with timing
- Success rate analysis
- Top 5 best/worst performers
- Comprehensive CSV export
The implementation is tested against diverse optimization landscapes:
Multimodal: Ackley, Rastrigin, Griewank, Schwefel, Levy, Michalewicz
Unimodal: Sphere, Rosenbrock, Sum Squares, Hyperellipsoid
2D Specialized: Beale, Booth, Himmelblau, Goldstein-Price, Branin, Camel
Special Cases: Eggholder, Kowalik, Langermann, Box-Betts
- Exploration: Multiple restart strategies prevent local optima
- Exploitation: Adaptive cooling balances search intensity
- Robustness: Handles diverse function landscapes effectively
- Efficiency: Fast convergence on smooth landscapes
- Python 3.7+
- NumPy >= 1.20.0
- optimization-benchmarks == 0.1.1
MIT License - see LICENSE.md for details.
- Built using the
optimization-benchmarkspackage - Inspired by classical SA implementations and modern optimization research