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.
Fields§
§op: Option<O>
Operator
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
Implementations§
Source§impl<O: ArgminOp> OpWrapper<O>
impl<O: ArgminOp> OpWrapper<O>
Sourcepub fn new_from_wrapper(op: &mut OpWrapper<O>) -> Self
pub fn new_from_wrapper(op: &mut OpWrapper<O>) -> Self
Construct struct from other OpWrapper
. Takes the operator from op
(replaces it with
None
) and crates a new OpWrapper
Sourcepub fn apply(&mut self, param: &O::Param) -> Result<O::Output, Error>
pub fn apply(&mut self, param: &O::Param) -> Result<O::Output, Error>
Calls the apply
method of op
and increments cost_func_count
.
Sourcepub fn gradient(&mut self, param: &O::Param) -> Result<O::Param, Error>
pub fn gradient(&mut self, param: &O::Param) -> Result<O::Param, Error>
Calls the gradient
method of op
and increments gradient_func_count
.
Sourcepub fn hessian(&mut self, param: &O::Param) -> Result<O::Hessian, Error>
pub fn hessian(&mut self, param: &O::Param) -> Result<O::Hessian, Error>
Calls the hessian
method of op
and increments hessian_func_count
.
Sourcepub fn jacobian(&mut self, param: &O::Param) -> Result<O::Jacobian, Error>
pub fn jacobian(&mut self, param: &O::Param) -> Result<O::Jacobian, Error>
Calls the jacobian
method of op
and increments jacobian_func_count
.
Sourcepub fn modify(
&mut self,
param: &O::Param,
extent: O::Float,
) -> Result<O::Param, Error>
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
.
Sourcepub fn take_op(&mut self) -> Option<O>
pub fn take_op(&mut self) -> Option<O>
Moves the operator out of the struct and replaces it with None
Sourcepub fn consume_op(&mut self, other: OpWrapper<O>)
pub fn consume_op(&mut self, other: OpWrapper<O>)
Consumes an operator by increasing the function call counts of self
by the ones in
other
.
Sourcepub fn consume_func_counts<O2: ArgminOp>(&mut self, other: OpWrapper<O2>)
pub fn consume_func_counts<O2: ArgminOp>(&mut self, other: OpWrapper<O2>)
Adds function evaluation counts of another operator.
Trait Implementations§
Source§impl<O: ArgminOp> ArgminOp for OpWrapper<O>
impl<O: ArgminOp> ArgminOp for OpWrapper<O>
The OpWrapperArgminOp