Struct argmin::core::OpWrapper[][src]

pub struct OpWrapper<O: ArgminOp> {
    pub op: Option<O>,
    pub cost_func_count: u64,
    pub grad_func_count: u64,
    pub hessian_func_count: u64,
    pub jacobian_func_count: u64,
    pub modify_func_count: u64,
Expand description

This wraps an operator and keeps track of how often the cost, gradient and Hessian have been computed and how often the modify function has been called. Usually, this is an implementation detail unless a solver is needed within another solver (such as a line search within a gradient descent method), then it may be necessary to wrap the operator in an OpWrapper.


op: Option<O>


cost_func_count: u64

Number of cost function evaluations

grad_func_count: u64

Number of gradient function evaluations

hessian_func_count: u64

Number of Hessian function evaluations

jacobian_func_count: u64

Number of Jacobian function evaluations

modify_func_count: u64

Number of modify function evaluations


impl<O: ArgminOp> OpWrapper<O>[src]

pub fn new(op: O) -> Self[src]


pub fn new_from_wrapper(op: &mut OpWrapper<O>) -> Self[src]

Construct struct from other OpWrapper. Takes the operator from op (replaces it with None) and crates a new OpWrapper

pub fn apply(&mut self, param: &O::Param) -> Result<O::Output, Error>[src]

Calls the apply method of op and increments cost_func_count.

pub fn gradient(&mut self, param: &O::Param) -> Result<O::Param, Error>[src]

Calls the gradient method of op and increments gradient_func_count.

pub fn hessian(&mut self, param: &O::Param) -> Result<O::Hessian, Error>[src]

Calls the hessian method of op and increments hessian_func_count.

pub fn jacobian(&mut self, param: &O::Param) -> Result<O::Jacobian, Error>[src]

Calls the jacobian method of op and increments jacobian_func_count.

pub fn modify(
    &mut self,
    param: &O::Param,
    extent: O::Float
) -> Result<O::Param, Error>

Calls the modify method of op and increments modify_func_count.

pub fn take_op(&mut self) -> Option<O>[src]

Moves the operator out of the struct and replaces it with None

pub fn consume_op(&mut self, other: OpWrapper<O>)[src]

Consumes an operator by increasing the function call counts of self by the ones in other.

pub fn consume_func_counts<O2: ArgminOp>(&mut self, other: OpWrapper<O2>)[src]

Adds function evaluation counts of another operator.

pub fn reset(self) -> Self[src]

Reset the cost function counts to zero.

pub fn get_op(self) -> O[src]

Returns the operator op by taking ownership of self.

Trait Implementations

impl<O: ArgminOp> ArgminOp for OpWrapper<O>[src]

The OpWrapper should behave just like any other ArgminOp

type Param = O::Param

Type of the parameter vector

type Output = O::Output

Output of the operator

type Hessian = O::Hessian

Type of Hessian

type Jacobian = O::Jacobian

Type of Jacobian

type Float = O::Float

Precision of floats

fn apply(&self, param: &Self::Param) -> Result<Self::Output, Error>[src]

Applies the operator/cost function to parameters

fn gradient(&self, param: &Self::Param) -> Result<Self::Param, Error>[src]

Computes the gradient at the given parameters

fn hessian(&self, param: &Self::Param) -> Result<Self::Hessian, Error>[src]

Computes the Hessian at the given parameters

fn jacobian(&self, param: &Self::Param) -> Result<Self::Jacobian, Error>[src]

Computes the Hessian at the given parameters

fn modify(
    param: &Self::Param,
    extent: Self::Float
) -> Result<Self::Param, Error>

Modifies a parameter vector. Comes with a variable that indicates the “degree” of the modification. Read more

impl<O: Clone + ArgminOp> Clone for OpWrapper<O>[src]

fn clone(&self) -> OpWrapper<O>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<O: Debug + ArgminOp> Debug for OpWrapper<O>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<O: Default + ArgminOp> Default for OpWrapper<O>[src]

fn default() -> OpWrapper<O>[src]

Returns the “default value” for a type. Read more

impl<'de, O: ArgminOp> Deserialize<'de> for OpWrapper<O> where
    O: Deserialize<'de>, 

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 

Deserialize this value from the given Serde deserializer. Read more

impl<O: ArgminOp> Serialize for OpWrapper<O> where
    O: Serialize

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
    __S: Serializer

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

impl<O> RefUnwindSafe for OpWrapper<O> where
    O: RefUnwindSafe

impl<O> Send for OpWrapper<O> where
    O: Send

impl<O> Sync for OpWrapper<O> where
    O: Sync

impl<O> Unpin for OpWrapper<O> where
    O: Unpin

impl<O> UnwindSafe for OpWrapper<O> where
    O: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized