Struct optimization::NumericalDifferentiation
[−]
[src]
pub struct NumericalDifferentiation<F: Function> { /* fields omitted */ }
Wraps a function for which to provide numeric differentiation.
Uses simple one step forward finite difference with step width h = √εx.
Examples
let square = NumericalDifferentiation::new(Func(|x: &[f64]| { x[0] * x[0] })); assert!(square.gradient(&[0.0])[0] < 1.0e-3); assert!(square.gradient(&[1.0])[0] > 1.0); assert!(square.gradient(&[-1.0])[0] < 1.0);
Methods
impl<F: Function> NumericalDifferentiation<F>[src]
fn new(function: F) -> Self
Creates a new differentiable function by using the supplied function in
combination with numeric differentiation to find the derivatives.
Trait Implementations
impl<F: Function> Function for NumericalDifferentiation<F>[src]
fn value(&self, position: &[f64]) -> f64
Computes the objective function at a given position x, i.e., f(x) = y.
impl<F: Function> Function1 for NumericalDifferentiation<F>[src]
fn gradient(&self, position: &[f64]) -> Vec<f64>
Computes the gradient of the objective function at a given position x, i.e., ∀ᵢ ∂/∂xᵢ f(x) = ∇f(x). Read more
impl<F: Function + Default> Default for NumericalDifferentiation<F>[src]
impl<F: Problem> Problem for NumericalDifferentiation<F>[src]
fn dimensions(&self) -> usize
Returns the dimensionality of the input domain.
fn domain(&self) -> Vec<(f64, f64)>
Returns the input domain of the function in terms of upper and lower, respectively, for each input dimension. Read more
fn minimum(&self) -> (Vec<f64>, f64)
Returns the position as well as the value of the global minimum.
fn random_start(&self) -> Vec<f64>
Generates a random and feasible position to start a minimization.
fn is_legal_position(&self, position: &[f64]) -> bool
Tests whether the supplied position is legal for this function.