math-test-functions 0.5.2

A collection of non linear functions for testing optimisation algorithms
Documentation
1
2
3
4
5
6
7
8
9
10
//! Step test function

use ndarray::Array1;

/// Step function - discontinuous, multimodal
/// Global minimum: f(x) = 0 for every coordinate in [-0.5, 0.5)
/// Bounds: x_i in [-100, 100]
pub fn step(x: &Array1<f64>) -> f64 {
    x.iter().map(|&xi| (xi + 0.5).floor().powi(2)).sum::<f64>()
}