Objective

Trait Objective 

Source
pub trait Objective:
    Debug
    + Send
    + Sync {
    // Required methods
    fn value(
        &self,
        coefficients: &Array1<Float>,
        data: &ObjectiveData,
    ) -> Result<Float>;
    fn gradient(
        &self,
        coefficients: &Array1<Float>,
        data: &ObjectiveData,
    ) -> Result<Array1<Float>>;

    // Provided methods
    fn value_and_gradient(
        &self,
        coefficients: &Array1<Float>,
        data: &ObjectiveData,
    ) -> Result<(Float, Array1<Float>)> { ... }
    fn supports_hessian(&self) -> bool { ... }
    fn hessian(
        &self,
        _coefficients: &Array1<Float>,
        _data: &ObjectiveData,
    ) -> Result<Array2<Float>> { ... }
}
Expand description

Trait for optimization objectives that can be minimized

Required Methods§

Source

fn value( &self, coefficients: &Array1<Float>, data: &ObjectiveData, ) -> Result<Float>

Compute the objective value

Source

fn gradient( &self, coefficients: &Array1<Float>, data: &ObjectiveData, ) -> Result<Array1<Float>>

Compute the gradient of the objective

Provided Methods§

Source

fn value_and_gradient( &self, coefficients: &Array1<Float>, data: &ObjectiveData, ) -> Result<(Float, Array1<Float>)>

Compute both value and gradient (often more efficient than separate calls)

Source

fn supports_hessian(&self) -> bool

Check if the objective supports Hessian computation

Source

fn hessian( &self, _coefficients: &Array1<Float>, _data: &ObjectiveData, ) -> Result<Array2<Float>>

Compute the Hessian matrix (for second-order methods)

Implementors§