pub struct IterState<O: ArgminOp> {Show 28 fields
pub param: O::Param,
pub prev_param: O::Param,
pub best_param: O::Param,
pub prev_best_param: O::Param,
pub cost: O::Float,
pub prev_cost: O::Float,
pub best_cost: O::Float,
pub prev_best_cost: O::Float,
pub target_cost: O::Float,
pub grad: Option<O::Param>,
pub prev_grad: Option<O::Param>,
pub hessian: Option<O::Hessian>,
pub prev_hessian: Option<O::Hessian>,
pub inv_hessian: Option<O::Hessian>,
pub prev_inv_hessian: Option<O::Hessian>,
pub jacobian: Option<O::Jacobian>,
pub prev_jacobian: Option<O::Jacobian>,
pub population: Option<Vec<(O::Param, O::Float)>>,
pub iter: u64,
pub last_best_iter: u64,
pub max_iters: u64,
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,
pub time: Option<Duration>,
pub termination_reason: TerminationReason,
}
Expand description
Maintains the state from iteration to iteration of a solver
Fields
param: O::Param
Current parameter vector
prev_param: O::Param
Previous parameter vector
best_param: O::Param
Current best parameter vector
prev_best_param: O::Param
Previous best parameter vector
cost: O::Float
Current cost function value
prev_cost: O::Float
Previous cost function value
best_cost: O::Float
Current best cost function value
prev_best_cost: O::Float
Previous best cost function value
target_cost: O::Float
Target cost function value
grad: Option<O::Param>
Current gradient
prev_grad: Option<O::Param>
Previous gradient
hessian: Option<O::Hessian>
Current Hessian
prev_hessian: Option<O::Hessian>
Previous Hessian
inv_hessian: Option<O::Hessian>
Current inverse Hessian
prev_inv_hessian: Option<O::Hessian>
Previous inverse Hessian
jacobian: Option<O::Jacobian>
Current Jacobian
prev_jacobian: Option<O::Jacobian>
Previous Jacobian
population: Option<Vec<(O::Param, O::Float)>>
All members for population-based algorithms as (param, cost) tuples
iter: u64
Current iteration
last_best_iter: u64
Iteration number of last best cost
max_iters: u64
Maximum number of iterations
cost_func_count: u64
Number of cost function evaluations so far
grad_func_count: u64
Number of gradient evaluations so far
hessian_func_count: u64
Number of Hessian evaluations so far
jacobian_func_count: u64
Number of Jacobian evaluations so far
modify_func_count: u64
Number of modify evaluations so far
time: Option<Duration>
Time required so far
termination_reason: TerminationReason
Reason of termination
Implementations
sourceimpl<O: ArgminOp> IterState<O>
impl<O: ArgminOp> IterState<O>
sourcepub fn param(&mut self, param: O::Param) -> &mut Self
pub fn param(&mut self, param: O::Param) -> &mut Self
Set parameter vector. This shifts the stored parameter vector to the previous parameter vector.
sourcepub fn best_param(&mut self, param: O::Param) -> &mut Self
pub fn best_param(&mut self, param: O::Param) -> &mut Self
Set best paramater vector. This shifts the stored best parameter vector to the previous best parameter vector.
sourcepub fn cost(&mut self, cost: O::Float) -> &mut Self
pub fn cost(&mut self, cost: O::Float) -> &mut Self
Set the current cost function value. This shifts the stored cost function value to the previous cost function value.
sourcepub fn best_cost(&mut self, cost: O::Float) -> &mut Self
pub fn best_cost(&mut self, cost: O::Float) -> &mut Self
Set the current best cost function value. This shifts the stored best cost function value to the previous cost function value.
sourcepub fn grad(&mut self, grad: O::Param) -> &mut Self
pub fn grad(&mut self, grad: O::Param) -> &mut Self
Set gradient. This shifts the stored gradient to the previous gradient.
sourcepub fn hessian(&mut self, hessian: O::Hessian) -> &mut Self
pub fn hessian(&mut self, hessian: O::Hessian) -> &mut Self
Set Hessian. This shifts the stored Hessian to the previous Hessian.
sourcepub fn inv_hessian(&mut self, inv_hessian: O::Hessian) -> &mut Self
pub fn inv_hessian(&mut self, inv_hessian: O::Hessian) -> &mut Self
Set inverse Hessian. This shifts the stored inverse Hessian to the previous inverse Hessian.
sourcepub fn jacobian(&mut self, jacobian: O::Jacobian) -> &mut Self
pub fn jacobian(&mut self, jacobian: O::Jacobian) -> &mut Self
Set Jacobian. This shifts the stored Jacobian to the previous Jacobian.
sourcepub fn population(&mut self, population: Vec<(O::Param, O::Float)>) -> &mut Self
pub fn population(&mut self, population: Vec<(O::Param, O::Float)>) -> &mut Self
Set population
sourcepub fn target_cost(&mut self, target_cost: O::Float) -> &mut Self
pub fn target_cost(&mut self, target_cost: O::Float) -> &mut Self
Set target cost value
sourcepub fn last_best_iter(&mut self, last_best_iter: u64) -> &mut Self
pub fn last_best_iter(&mut self, last_best_iter: u64) -> &mut Self
Set iteration number where the previous best parameter vector was found
sourcepub fn termination_reason(
&mut self,
termination_reason: TerminationReason
) -> &mut Self
pub fn termination_reason(
&mut self,
termination_reason: TerminationReason
) -> &mut Self
Set termination_reason
sourcepub fn get_prev_param(&self) -> O::Param
pub fn get_prev_param(&self) -> O::Param
Returns previous parameter vector
sourcepub fn get_best_param(&self) -> O::Param
pub fn get_best_param(&self) -> O::Param
Returns best parameter vector
sourcepub fn get_prev_best_param(&self) -> O::Param
pub fn get_prev_best_param(&self) -> O::Param
Returns previous best parameter vector
sourcepub fn get_prev_cost(&self) -> O::Float
pub fn get_prev_cost(&self) -> O::Float
Returns previous cost function value
sourcepub fn get_best_cost(&self) -> O::Float
pub fn get_best_cost(&self) -> O::Float
Returns current best cost function value
sourcepub fn get_prev_best_cost(&self) -> O::Float
pub fn get_prev_best_cost(&self) -> O::Float
Returns previous best cost function value
sourcepub fn get_target_cost(&self) -> O::Float
pub fn get_target_cost(&self) -> O::Float
Returns target cost
sourcepub fn get_cost_func_count(&self) -> u64
pub fn get_cost_func_count(&self) -> u64
Returns current cost function evaluation count
sourcepub fn get_grad_func_count(&self) -> u64
pub fn get_grad_func_count(&self) -> u64
Returns current gradient function evaluation count
sourcepub fn get_hessian_func_count(&self) -> u64
pub fn get_hessian_func_count(&self) -> u64
Returns current Hessian function evaluation count
sourcepub fn get_jacobian_func_count(&self) -> u64
pub fn get_jacobian_func_count(&self) -> u64
Returns current Jacobian function evaluation count
sourcepub fn get_modify_func_count(&self) -> u64
pub fn get_modify_func_count(&self) -> u64
Returns current Modify function evaluation count
sourcepub fn get_last_best_iter(&self) -> u64
pub fn get_last_best_iter(&self) -> u64
Returns iteration number where the last best parameter vector was found
sourcepub fn get_termination_reason(&self) -> TerminationReason
pub fn get_termination_reason(&self) -> TerminationReason
Get termination_reason
sourcepub fn get_prev_grad(&self) -> Option<O::Param>
pub fn get_prev_grad(&self) -> Option<O::Param>
Returns previous gradient
sourcepub fn get_hessian(&self) -> Option<O::Hessian>
pub fn get_hessian(&self) -> Option<O::Hessian>
Returns current Hessian
sourcepub fn get_prev_hessian(&self) -> Option<O::Hessian>
pub fn get_prev_hessian(&self) -> Option<O::Hessian>
Returns previous Hessian
sourcepub fn get_inv_hessian(&self) -> Option<O::Hessian>
pub fn get_inv_hessian(&self) -> Option<O::Hessian>
Returns current inverse Hessian
sourcepub fn get_prev_inv_hessian(&self) -> Option<O::Hessian>
pub fn get_prev_inv_hessian(&self) -> Option<O::Hessian>
Returns previous inverse Hessian
sourcepub fn get_jacobian(&self) -> Option<O::Jacobian>
pub fn get_jacobian(&self) -> Option<O::Jacobian>
Returns current Jacobian
sourcepub fn get_prev_jacobian(&self) -> Option<O::Jacobian>
pub fn get_prev_jacobian(&self) -> Option<O::Jacobian>
Returns previous Jacobian
sourcepub fn get_max_iters(&self) -> u64
pub fn get_max_iters(&self) -> u64
Returns maximum number of iterations
sourcepub fn increment_iter(&mut self)
pub fn increment_iter(&mut self)
Increment the number of iterations by one
sourcepub fn increment_func_counts(&mut self, op: &OpWrapper<O>)
pub fn increment_func_counts(&mut self, op: &OpWrapper<O>)
Increment all function evaluation counts by the evaluation counts of another operator
wrapped in OpWrapper
.
sourcepub fn set_func_counts(&mut self, op: &OpWrapper<O>)
pub fn set_func_counts(&mut self, op: &OpWrapper<O>)
Set all function evaluation counts to the evaluation counts of another operator
wrapped in OpWrapper
.
sourcepub fn increment_cost_func_count(&mut self, num: u64)
pub fn increment_cost_func_count(&mut self, num: u64)
Increment cost function evaluation count by num
sourcepub fn increment_grad_func_count(&mut self, num: u64)
pub fn increment_grad_func_count(&mut self, num: u64)
Increment gradient function evaluation count by num
sourcepub fn increment_hessian_func_count(&mut self, num: u64)
pub fn increment_hessian_func_count(&mut self, num: u64)
Increment Hessian function evaluation count by num
sourcepub fn increment_jacobian_func_count(&mut self, num: u64)
pub fn increment_jacobian_func_count(&mut self, num: u64)
Increment Jacobian function evaluation count by num
sourcepub fn increment_modify_func_count(&mut self, num: u64)
pub fn increment_modify_func_count(&mut self, num: u64)
Increment modify function evaluation count by num
sourcepub fn is_best(&self) -> bool
pub fn is_best(&self) -> bool
Returns whether the current parameter vector is also the best parameter vector found so far.
sourcepub fn terminated(&self) -> bool
pub fn terminated(&self) -> bool
Return whether the algorithm has terminated or not
Trait Implementations
sourceimpl<O: Clone + ArgminOp> Clone for IterState<O> where
O::Param: Clone,
O::Param: Clone,
O::Param: Clone,
O::Param: Clone,
O::Float: Clone,
O::Float: Clone,
O::Float: Clone,
O::Float: Clone,
O::Float: Clone,
O::Param: Clone,
O::Param: Clone,
O::Hessian: Clone,
O::Hessian: Clone,
O::Hessian: Clone,
O::Hessian: Clone,
O::Jacobian: Clone,
O::Jacobian: Clone,
O::Param: Clone,
O::Float: Clone,
impl<O: Clone + ArgminOp> Clone for IterState<O> where
O::Param: Clone,
O::Param: Clone,
O::Param: Clone,
O::Param: Clone,
O::Float: Clone,
O::Float: Clone,
O::Float: Clone,
O::Float: Clone,
O::Float: Clone,
O::Param: Clone,
O::Param: Clone,
O::Hessian: Clone,
O::Hessian: Clone,
O::Hessian: Clone,
O::Hessian: Clone,
O::Jacobian: Clone,
O::Jacobian: Clone,
O::Param: Clone,
O::Float: Clone,
sourceimpl<O: Debug + ArgminOp> Debug for IterState<O> where
O::Param: Debug,
O::Param: Debug,
O::Param: Debug,
O::Param: Debug,
O::Float: Debug,
O::Float: Debug,
O::Float: Debug,
O::Float: Debug,
O::Float: Debug,
O::Param: Debug,
O::Param: Debug,
O::Hessian: Debug,
O::Hessian: Debug,
O::Hessian: Debug,
O::Hessian: Debug,
O::Jacobian: Debug,
O::Jacobian: Debug,
O::Param: Debug,
O::Float: Debug,
impl<O: Debug + ArgminOp> Debug for IterState<O> where
O::Param: Debug,
O::Param: Debug,
O::Param: Debug,
O::Param: Debug,
O::Float: Debug,
O::Float: Debug,
O::Float: Debug,
O::Float: Debug,
O::Float: Debug,
O::Param: Debug,
O::Param: Debug,
O::Hessian: Debug,
O::Hessian: Debug,
O::Hessian: Debug,
O::Hessian: Debug,
O::Jacobian: Debug,
O::Jacobian: Debug,
O::Param: Debug,
O::Float: Debug,
sourceimpl<'de, O: ArgminOp> Deserialize<'de> for IterState<O> where
O::Param: Deserialize<'de>,
O::Param: Deserialize<'de>,
O::Param: Deserialize<'de>,
O::Param: Deserialize<'de>,
O::Float: Deserialize<'de>,
O::Float: Deserialize<'de>,
O::Float: Deserialize<'de>,
O::Float: Deserialize<'de>,
O::Float: Deserialize<'de>,
impl<'de, O: ArgminOp> Deserialize<'de> for IterState<O> where
O::Param: Deserialize<'de>,
O::Param: Deserialize<'de>,
O::Param: Deserialize<'de>,
O::Param: Deserialize<'de>,
O::Float: Deserialize<'de>,
O::Float: Deserialize<'de>,
O::Float: Deserialize<'de>,
O::Float: Deserialize<'de>,
O::Float: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl<O> RefUnwindSafe for IterState<O> where
<O as ArgminOp>::Float: RefUnwindSafe,
<O as ArgminOp>::Hessian: RefUnwindSafe,
<O as ArgminOp>::Jacobian: RefUnwindSafe,
<O as ArgminOp>::Param: RefUnwindSafe,
impl<O> Send for IterState<O> where
<O as ArgminOp>::Float: Send,
<O as ArgminOp>::Hessian: Send,
<O as ArgminOp>::Jacobian: Send,
<O as ArgminOp>::Param: Send,
impl<O> Sync for IterState<O> where
<O as ArgminOp>::Float: Sync,
<O as ArgminOp>::Hessian: Sync,
<O as ArgminOp>::Jacobian: Sync,
<O as ArgminOp>::Param: Sync,
impl<O> Unpin for IterState<O> where
<O as ArgminOp>::Float: Unpin,
<O as ArgminOp>::Hessian: Unpin,
<O as ArgminOp>::Jacobian: Unpin,
<O as ArgminOp>::Param: Unpin,
impl<O> UnwindSafe for IterState<O> where
<O as ArgminOp>::Float: UnwindSafe,
<O as ArgminOp>::Hessian: UnwindSafe,
<O as ArgminOp>::Jacobian: UnwindSafe,
<O as ArgminOp>::Param: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more