| Crates.io | math-test-functions |
| lib.rs | math-test-functions |
| version | 0.3.0 |
| created_at | 2025-12-21 12:49:13.526876+00 |
| updated_at | 2026-01-02 08:42:47.822648+00 |
| description | A collection of non linear functions for testing optimisation algorithms |
| homepage | |
| repository | https://github.com/pierreaubert/math-audio |
| max_upload_size | |
| id | 1997922 |
| size | 19,346,686 |
A comprehensive collection of 56+ test functions for optimization algorithm benchmarking and validation, organized into logical modules for easy navigation and maintenance.
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, exponentialTest 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_trayFor constrained optimization algorithms:
keanes_bump_objective with constraintsrosenbrock_disk_constraintbinh_korn_* with multiple constraintsmishras_bird_* functionsHybrid and recent competition functions:
expanded_griewank_rosenbrockxin_she_yang_n1, xin_she_yang_n2, etc.happycat, katsuura, vincentgramacy_lee_2012, forrester_2008use 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)
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));
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
sphere, booth, matyas - Good for initial testingrosenbrock, ackley, griewank - Standard benchmarksschwefel, eggholder, katsuura - Challenging landscapesholder_table, cross_in_tray - Very difficult optimizationgramacy_lee_2012, forrester_2008branin, goldstein_price, six_hump_camelsphere, rosenbrock, ackley, rastriginelliptic, bent_cigar, katsuuraelliptic, cigar, tablet, discussphere, sum_squares, alpine_n1rosenbrock, ackley, griewankstep, de_jong_step2keanes_bump_*, binh_korn_*sphere and rosenbrockackley and rastriginschwefel, eggholder, katsuurakeanes_bump_* for constrained algorithms# 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
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