Skip to main content

Objective

Trait Objective 

Source
pub trait Objective {
    type Error;

    // Required methods
    fn dim(&self) -> usize;
    fn value(&mut self, theta: &[f64]) -> Result<f64, Self::Error>;
    fn gradient(
        &mut self,
        theta: &[f64],
        grad: &mut [f64],
    ) -> Result<(), Self::Error>;

    // Provided method
    fn value_gradient(
        &mut self,
        theta: &[f64],
        grad: &mut [f64],
    ) -> Result<f64, Self::Error> { ... }
}
Expand description

Независимый от оптимизатора оракул над плоским вектором параметров.

Методы принимают &mut self, чтобы реализации могли переиспользовать временные буферы, не раскрывая состояние, специфичное для оптимизатора, в gamlss-core.

Required Associated Types§

Source

type Error

Recoverable error returned by objective evaluation.

Required Methods§

Source

fn dim(&self) -> usize

Dimension of the flat parameter vector accepted by this objective.

Source

fn value(&mut self, theta: &[f64]) -> Result<f64, Self::Error>

Objective value at theta.

Source

fn gradient( &mut self, theta: &[f64], grad: &mut [f64], ) -> Result<(), Self::Error>

Writes the gradient at theta into preallocated grad.

Provided Methods§

Source

fn value_gradient( &mut self, theta: &[f64], grad: &mut [f64], ) -> Result<f64, Self::Error>

Computes objective value and gradient at theta.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F, Blocks> Objective for CachedGamlss<F, Blocks>
where Blocks: GamlssBlocks<F>,

Source§

impl<F, Blocks> Objective for Gamlss<F, Blocks>
where Blocks: GamlssBlocks<F>,

Source§

impl<O, GP> Objective for WithGlobalPenalties<O, GP>
where O: Objective, GP: GlobalPenalty,

Source§

impl<O> Objective for BlockObjective<'_, O>
where O: Objective, O::Error: From<ModelError>,