Struct argmin_core::ArgminBase
source · pub struct ArgminBase<'a, T, U, H> { /* private fields */ }
Expand description
Storage for data needed by most solvers
TODO: cur_cost, best_cost and target_cost should be U
, but then initialization is difficult
as it cannot be expected that each U
has something like INFINITY
and NEG_INFINITY
…
Implementations
sourceimpl<'a, T, U, H> ArgminBase<'a, T, U, H>where
T: Clone + Default,
H: Clone + Default,
impl<'a, T, U, H> ArgminBase<'a, T, U, H>where
T: Clone + Default,
H: Clone + Default,
sourcepub fn new(
operator: &'a dyn ArgminOperator<Parameters = T, OperatorOutput = U, Hessian = H>,
param: T
) -> Self
pub fn new(
operator: &'a dyn ArgminOperator<Parameters = T, OperatorOutput = U, Hessian = H>,
param: T
) -> Self
Constructor
sourcepub fn kv_for_logs(&self) -> ArgminKV
pub fn kv_for_logs(&self) -> ArgminKV
Return the KV for the initial logging
sourcepub fn kv_for_iter(&self) -> ArgminKV
pub fn kv_for_iter(&self) -> ArgminKV
Return the KV for logging of the iterations
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset self
to its initial state.
This is dangerous the way it is implemented right now. This has to be done better. For instance, all old data needs to be kept in order to be able to actually go back to the initial state. Also, this method definitely needs to be kept up to date otherwise nasty bugs may happen.
sourcepub fn modify(&self, param: &T, factor: f64) -> Result<T, Error>
pub fn modify(&self, param: &T, factor: f64) -> Result<T, Error>
Modify a param
with the modify
method of operator
.
sourcepub fn set_cur_param(&mut self, param: T) -> &mut Self
pub fn set_cur_param(&mut self, param: T) -> &mut Self
Set the current parameter vector
sourcepub fn set_best_param(&mut self, param: T) -> &mut Self
pub fn set_best_param(&mut self, param: T) -> &mut Self
Set the new best parameter vector
sourcepub fn best_param(&self) -> T
pub fn best_param(&self) -> T
Return the current best parameter vector
sourcepub fn set_cur_cost(&mut self, cost: f64) -> &mut Self
pub fn set_cur_cost(&mut self, cost: f64) -> &mut Self
Set the current cost function value
sourcepub fn set_best_cost(&mut self, cost: f64) -> &mut Self
pub fn set_best_cost(&mut self, cost: f64) -> &mut Self
Set the cost function value of the current best parameter vector
sourcepub fn best_cost(&self) -> f64
pub fn best_cost(&self) -> f64
Return the cost function value of the current best parameter vector
sourcepub fn set_cur_grad(&mut self, grad: T) -> &mut Self
pub fn set_cur_grad(&mut self, grad: T) -> &mut Self
Set the current gradient
sourcepub fn set_cur_hessian(&mut self, hessian: H) -> &mut Self
pub fn set_cur_hessian(&mut self, hessian: H) -> &mut Self
Set the current hessian
sourcepub fn cur_hessian(&self) -> H
pub fn cur_hessian(&self) -> H
Return the current hessian
sourcepub fn set_target_cost(&mut self, cost: f64) -> &mut Self
pub fn set_target_cost(&mut self, cost: f64) -> &mut Self
Set the target cost function value
sourcepub fn target_cost(&self) -> f64
pub fn target_cost(&self) -> f64
Return the target cost function value
sourcepub fn increment_iter(&mut self) -> &mut Self
pub fn increment_iter(&mut self) -> &mut Self
Increment the number of iterations.
sourcepub fn increment_cost_func_count(&mut self) -> &mut Self
pub fn increment_cost_func_count(&mut self) -> &mut Self
Increment the cost function evaluation count
sourcepub fn increase_cost_func_count(&mut self, count: u64) -> &mut Self
pub fn increase_cost_func_count(&mut self, count: u64) -> &mut Self
Increaese the cost function evaluation count by a given value
sourcepub fn cost_func_count(&self) -> u64
pub fn cost_func_count(&self) -> u64
Return the cost function evaluation count
sourcepub fn increment_grad_func_count(&mut self) -> &mut Self
pub fn increment_grad_func_count(&mut self) -> &mut Self
Increment the gradient evaluation count
sourcepub fn increase_grad_func_count(&mut self, count: u64) -> &mut Self
pub fn increase_grad_func_count(&mut self, count: u64) -> &mut Self
Increase the gradient evaluation count by a given value
sourcepub fn grad_func_count(&self) -> u64
pub fn grad_func_count(&self) -> u64
Return the gradient evaluation count
sourcepub fn increment_hessian_func_count(&mut self) -> &mut Self
pub fn increment_hessian_func_count(&mut self) -> &mut Self
Increment the hessian evaluation count
sourcepub fn increase_hessian_func_count(&mut self, count: u64) -> &mut Self
pub fn increase_hessian_func_count(&mut self, count: u64) -> &mut Self
Increase the hessian evaluation count by a given value
sourcepub fn hessian_func_count(&self) -> u64
pub fn hessian_func_count(&self) -> u64
Return the gradient evaluation count
sourcepub fn set_max_iters(&mut self, iters: u64) -> &mut Self
pub fn set_max_iters(&mut self, iters: u64) -> &mut Self
Set the maximum number of iterations.
sourcepub fn set_termination_reason(&mut self, reason: TerminationReason) -> &mut Self
pub fn set_termination_reason(&mut self, reason: TerminationReason) -> &mut Self
Set the TerminationReason
sourcepub fn termination_reason(&self) -> TerminationReason
pub fn termination_reason(&self) -> TerminationReason
Return the TerminationReason
sourcepub fn termination_reason_text(&self) -> &str
pub fn termination_reason_text(&self) -> &str
Return the textual representation of the TerminationReason
sourcepub fn terminated(&self) -> bool
pub fn terminated(&self) -> bool
Return whether the algorithm has terminated or not
sourcepub fn result(&self) -> ArgminResult<T>
pub fn result(&self) -> ArgminResult<T>
Return the result.
sourcepub fn set_total_time(&mut self, time: Duration) -> &mut Self
pub fn set_total_time(&mut self, time: Duration) -> &mut Self
Set the total time needed by the solver
sourcepub fn total_time(&self) -> Duration
pub fn total_time(&self) -> Duration
Return the total time
sourcepub fn add_logger(&mut self, logger: Box<dyn ArgminLog>) -> &mut Self
pub fn add_logger(&mut self, logger: Box<dyn ArgminLog>) -> &mut Self
Add a logger to the list of loggers
sourcepub fn add_writer(
&mut self,
writer: Box<dyn ArgminWrite<Param = T>>
) -> &mut Self
pub fn add_writer(
&mut self,
writer: Box<dyn ArgminWrite<Param = T>>
) -> &mut Self
Add a writer to the list of writers