Trait nlopt::ObjFn

source ·
pub trait ObjFn<U>: Fn(&[f64], Option<&mut [f64]>, &mut U) -> f64 { }
Expand description

A trait representing an objective function.

An objective function takes the form of a closure f(x: &[f64], gradient: Option<&mut [f64], user_data: &mut U) -> f64

  • x - n-dimensional array
  • gradient - n-dimensional array to store the gradient grad f(x). If gradient matches Some(x), the user is required to provide a gradient, otherwise the optimization will probabely fail.
  • user_data - user defined data

Implementors§

source§

impl<T, U> ObjFn<U> for T
where T: Fn(&[f64], Option<&mut [f64]>, &mut U) -> f64,