Trait argmin_core::ArgminOperator
source · pub trait ArgminOperator {
type Parameters;
type OperatorOutput;
type Hessian;
fn apply(&self, _: &Self::Parameters) -> Result<Self::OperatorOutput, Error>;
fn box_clone(
&self
) -> Box<dyn ArgminOperator<Parameters = Self::Parameters, OperatorOutput = Self::OperatorOutput, Hessian = Self::Hessian>>;
fn gradient(&self, : &Self::Parameters) -> Result<Self::Parameters, Error> { ... }
fn hessian(&self, : &Self::Parameters) -> Result<Self::Hessian, Error> { ... }
fn modify(
&mut self,
: &Self::Parameters,
: f64
) -> Result<Self::Parameters, Error> { ... }
}
Expand description
This trait needs to be implemented for every operator/cost function.
It is required to implement the apply
and box_clone
methods, all others are optional and
provide a default implementation which is essentially returning an error which indicates that
the method has not been implemented. Those methods (gradient
and modify
) only need to be
implemented if the uses solver requires it. The box_clone
method can be ‘half automatically’
implemented using the box_clone!
macro.
Required Associated Types
sourcetype Parameters
type Parameters
Type of the parameter vector
sourcetype OperatorOutput
type OperatorOutput
Output of the operator. Most solvers expect f64
.
Required Methods
sourcefn apply(&self, _: &Self::Parameters) -> Result<Self::OperatorOutput, Error>
fn apply(&self, _: &Self::Parameters) -> Result<Self::OperatorOutput, Error>
Applies the operator/cost function to parameters
sourcefn box_clone(
&self
) -> Box<dyn ArgminOperator<Parameters = Self::Parameters, OperatorOutput = Self::OperatorOutput, Hessian = Self::Hessian>>
fn box_clone(
&self
) -> Box<dyn ArgminOperator<Parameters = Self::Parameters, OperatorOutput = Self::OperatorOutput, Hessian = Self::Hessian>>
Allows to clone the boxed trait object.
Provided Methods
sourcefn gradient(&self, : &Self::Parameters) -> Result<Self::Parameters, Error>
fn gradient(&self, : &Self::Parameters) -> Result<Self::Parameters, Error>
Computes the gradient at the given parameters
sourcefn hessian(&self, : &Self::Parameters) -> Result<Self::Hessian, Error>
fn hessian(&self, : &Self::Parameters) -> Result<Self::Hessian, Error>
Computes the hessian at the given parameters
sourcefn modify(
&mut self,
: &Self::Parameters,
: f64
) -> Result<Self::Parameters, Error>
fn modify(
&mut self,
: &Self::Parameters,
: f64
) -> Result<Self::Parameters, Error>
Modifies a parameter vector. Comes with a variable that indicates the “degree” of the modification.
Trait Implementations
sourceimpl<'a, T, U, H> Clone for Box<dyn ArgminOperator<Parameters = T, OperatorOutput = U, Hessian = H> + 'a>
impl<'a, T, U, H> Clone for Box<dyn ArgminOperator<Parameters = T, OperatorOutput = U, Hessian = H> + 'a>
sourcefn clone(
&self
) -> Box<dyn ArgminOperator<Parameters = T, OperatorOutput = U, Hessian = H> + 'a>
fn clone(
&self
) -> Box<dyn ArgminOperator<Parameters = T, OperatorOutput = U, Hessian = H> + 'a>
Implements clone
for a boxed ArgminOperator
. Requires obviously that box_clone
is
implemented (see ArgminOperator
trait).
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more