Skip to main content

DifferentiableObjective

Trait DifferentiableObjective 

Source
pub trait DifferentiableObjective<T: Float>: Objective<T> + Gradient<T> {
    // Provided method
    fn value_and_gradient(&self, x: ArrayView1<'_, T>) -> (T, Array1<T>) { ... }
}
Expand description

An Objective that can also supply its gradient (natively or via adapter).

Blanket impl for any O: Objective<T> + Gradient<T>. Concrete types (surrogates, PyObjective with grad, builtins) can override value_and_gradient for a fused implementation that re-uses intermediate work (exactly as a Ceres CostFunction computes residuals and Jacobians in one shot).

Provided Methods§

Source

fn value_and_gradient(&self, x: ArrayView1<'_, T>) -> (T, Array1<T>)

Returns (f(x), ∇f(x)). Default calls the two methods separately; analytic implementations should override for efficiency.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Float, O> DifferentiableObjective<T> for O
where O: Objective<T> + Gradient<T>,