Expand description
§Optimization Test Functions Library
A comprehensive collection of 56+ test functions for optimization algorithm benchmarking and validation, organized into logical modules for easy navigation and maintenance.
§Function Categories
§Unimodal Functions (Single Global Optimum)
Perfect for testing convergence speed and precision:
sphere,rosenbrock,powell,dixons_pricezakharov,booth,matyas,sum_squareselliptic,cigar,tablet,discus(ill-conditioned)ridge,sharp_ridge,brown,exponential
§Multimodal Functions (Multiple Local Minima)
Test global search and exploration capabilities:
ackley,rastrigin,griewank,schwefelhartman_3d,hartman_4d,hartman_6dmichalewicz,alpine_n1,alpine_n2branin,goldstein_price,six_hump_cameleggholder,holder_table,cross_in_tray
§Constrained Functions
For constrained optimization algorithms:
keanes_bump_objectivewith constraintsrosenbrock_disk_constraintbinh_korn_*with multiple constraintsmishras_bird_*functions
§Composite & Modern Functions
Hybrid and recent competition functions:
expanded_griewank_rosenbrockxin_she_yang_n1,xin_she_yang_n2, etc.happycat,katsuura,vincentgramacy_lee_2012,forrester_2008
§Usage Examples
§Basic Function Evaluation
use ndarray::Array1;
use math_audio_test_functions::*;
// Evaluate sphere function
let x = Array1::from_vec(vec![1.0, 2.0]);
let result = sphere(&x); // Returns 5.0 (1² + 2²)
// Evaluate Rosenbrock function
let x = Array1::from_vec(vec![1.0, 1.0]);
let result = rosenbrock(&x); // Returns 0.0 (global minimum)§Function Metadata and Bounds
use math_audio_test_functions::{get_function_metadata, get_function_bounds, get_function_bounds_2d};
// Get all function metadata
let metadata = get_function_metadata();
println!("Available functions: {}", metadata.len());
// Get bounds for a specific function
let bounds = get_function_bounds("ackley").unwrap();
println!("Ackley bounds: {:?}", bounds);
// Get 2D bounds array (for compatibility)
let bounds_2d = get_function_bounds_2d("sphere", (-5.0, 5.0));§Working with Different Categories
use ndarray::Array1;
use math_audio_test_functions::*;
let x = Array1::from_vec(vec![1.0, 1.0]);
// Unimodal functions (good for convergence testing)
let result1 = elliptic(&x); // Ill-conditioned
let result2 = rosenbrock(&x); // Valley-shaped
// Multimodal functions (good for global search testing)
let result3 = ackley(&x); // Highly multimodal
let result4 = rastrigin(&x); // Many local minima
// Modern benchmarks
let result5 = happycat(&x); // Recent CEC function
let result6 = katsuura(&x); // Fractal-like landscape§Function Properties
§Difficulty Levels
- Easy:
sphere,booth,matyas- Good for initial testing - Medium:
rosenbrock,ackley,griewank- Standard benchmarks - Hard:
schwefel,eggholder,katsuura- Challenging landscapes - Extreme:
holder_table,cross_in_tray- Very difficult optimization
§Dimensionality Support
- 1D:
gramacy_lee_2012,forrester_2008 - 2D Fixed:
branin,goldstein_price,six_hump_camel - N-Dimensional:
sphere,rosenbrock,ackley,rastrigin - High-D Specific:
elliptic,bent_cigar,katsuura
§Special Properties
- Ill-conditioned:
elliptic,cigar,tablet,discus - Separable:
sphere,sum_squares,alpine_n1 - Non-separable:
rosenbrock,ackley,griewank - Discontinuous:
step,de_jong_step2 - Constrained:
keanes_bump_*,binh_korn_*
§Benchmarking Guide
§Algorithm Testing Workflow
- Start Simple: Test on
sphereandrosenbrock - Add Multimodality: Try
ackleyandrastrigin - Test Scalability: Use N-dimensional functions
- Challenge Mode:
schwefel,eggholder,katsuura - Constraints:
keanes_bump_*for constrained algorithms
§Performance Metrics
- Convergence Speed: Unimodal functions
- Global Search: Multimodal functions
- Precision: Functions with known exact minima
- Robustness: Ill-conditioned and noisy functions
- Scalability: High-dimensional variants
§Build & Test
# Build the library
cargo build --release
# Run all tests
cargo test --release
# Test specific examples
cargo run --example test_new_sfu_functions
cargo run --example test_additional_functions
# Check code quality
cargo check
cargo clippy
cargo fmt§🏗️ Architecture
The library is organized into modular components:
src/
├── lib.rs # Main library with utilities and metadata
└── functions/
├── mod.rs # Module exports and organization
└── *.rs # 1 file per function§References
Re-exports§
pub use functions::*;
Modules§
- functions
- Test function implementations organized by category
Structs§
- Function
Metadata - Metadata for a test function including bounds, constraints, and other properties
Functions§
- create_
bounds - Create bounds matrix for optimization (2 x n matrix) bounds[[0, i]] = lower bound, bounds[[1, i]] = upper bound
- get_
function_ bounds - Helper function to get bounds for a specific function from metadata Returns None if function is not found in metadata
- get_
function_ bounds_ 2d - Helper function to get bounds as a 2D array for optimization (compatible with existing tests) Returns default bounds if function is not found
- get_
function_ bounds_ vec - Helper function to get bounds as a Vec for optimization (compatible with recorded tests) Returns default bounds if function is not found
- get_
function_ metadata - Get metadata for all available test functions (explicit definitions)