[][src]Trait argmin_core::ArgminSolver

pub trait ArgminSolver: ArgminIter {
    fn apply(&mut self, param: &Self::Param) -> Result<Self::Output, Error>;
fn gradient(&mut self, param: &Self::Param) -> Result<Self::Param, Error>;
fn hessian(&mut self, param: &Self::Param) -> Result<Self::Hessian, Error>;
fn modify(
        &self,
        param: &Self::Param,
        extent: f64
    ) -> Result<Self::Param, Error>;
fn cur_param(&self) -> Self::Param;
fn cur_grad(&self) -> Self::Param;
fn cur_hessian(&self) -> Self::Hessian;
fn set_cur_param(&mut self, param: Self::Param);
fn set_cur_grad(&mut self, grad: Self::Param);
fn set_cur_hessian(&mut self, hessian: Self::Hessian);
fn set_best_param(&mut self, param: Self::Param);
fn run(&mut self) -> Result<ArgminResult<Self::Param>, Error>;
fn run_fast(&mut self) -> Result<ArgminResult<Self::Param>, Error>;
fn result(&self) -> ArgminResult<Self::Param>;
fn set_termination_reason(&mut self, reason: TerminationReason);
fn terminate(&mut self) -> TerminationReason;
fn set_max_iters(&mut self, iters: u64);
fn max_iters(&self) -> u64;
fn cur_iter(&self) -> u64;
fn increment_iter(&mut self);
fn cur_cost(&self) -> f64;
fn set_cur_cost(&mut self, cost: f64);
fn best_cost(&self) -> f64;
fn set_best_cost(&mut self, cost: f64);
fn set_target_cost(&mut self, cost: f64);
fn add_logger(&mut self, logger: Arc<dyn ArgminLog>);
fn add_writer(&mut self, writer: Arc<dyn ArgminWrite<Param = Self::Param>>);
fn base_reset(&mut self);
fn increment_cost_func_count(&mut self);
fn increase_cost_func_count(&mut self, count: u64);
fn cost_func_count(&self) -> u64;
fn increment_grad_func_count(&mut self);
fn increase_grad_func_count(&mut self, count: u64);
fn grad_func_count(&self) -> u64;
fn increment_hessian_func_count(&mut self);
fn increase_hessian_func_count(&mut self, count: u64);
fn hessian_func_count(&self) -> u64; }

Defines the interface to a solver. Usually, there is no need to implement this manually, use the argmin_derive crate instead.

Required methods

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

apply cost function or operator to a parameter vector

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

compute the gradient for a parameter vector

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

compute the hessian for a parameter vector

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

modify the parameter vector

fn cur_param(&self) -> Self::Param

return current parameter vector

fn cur_grad(&self) -> Self::Param

return current gradient

fn cur_hessian(&self) -> Self::Hessian

return current gradient

fn set_cur_param(&mut self, param: Self::Param)

set current parameter vector

fn set_cur_grad(&mut self, grad: Self::Param)

set current gradient

fn set_cur_hessian(&mut self, hessian: Self::Hessian)

set current gradient

fn set_best_param(&mut self, param: Self::Param)

set current parameter vector

fn run(&mut self) -> Result<ArgminResult<Self::Param>, Error>

Execute the optimization algorithm.

fn run_fast(&mut self) -> Result<ArgminResult<Self::Param>, Error>

Execute the optimization algorithm without Ctrl-C handling, logging, writing and anything else which may cost unnecessary time.

fn result(&self) -> ArgminResult<Self::Param>

Returns the best solution found during optimization.

fn set_termination_reason(&mut self, reason: TerminationReason)

Set termination reason (doesn't terminate yet! -- this is helpful for terminating within the iterations)

fn terminate(&mut self) -> TerminationReason

Evaluate all stopping criterions and return the TerminationReason

fn set_max_iters(&mut self, iters: u64)

Set max number of iterations.

fn max_iters(&self) -> u64

Get max number of iterations.

fn cur_iter(&self) -> u64

Get current iteration number.

fn increment_iter(&mut self)

Increment the iteration number by one

fn cur_cost(&self) -> f64

Get current cost function value

fn set_cur_cost(&mut self, cost: f64)

Get current cost function value

fn best_cost(&self) -> f64

Get best cost function value

fn set_best_cost(&mut self, cost: f64)

set best cost value

fn set_target_cost(&mut self, cost: f64)

Set the target cost function value which is used as a stopping criterion

fn add_logger(&mut self, logger: Arc<dyn ArgminLog>)

Add a logger to the array of loggers

fn add_writer(&mut self, writer: Arc<dyn ArgminWrite<Param = Self::Param>>)

Add a writer to the array of writers

fn base_reset(&mut self)

Reset the base of the algorithm to its initial state

fn increment_cost_func_count(&mut self)

Increment the cost function evaluation count

fn increase_cost_func_count(&mut self, count: u64)

Increaese the cost function evaluation count by a given value

fn cost_func_count(&self) -> u64

Return the cost function evaluation count

fn increment_grad_func_count(&mut self)

Increment the gradient evaluation count

fn increase_grad_func_count(&mut self, count: u64)

Increase the gradient evaluation count by a given value

fn grad_func_count(&self) -> u64

Return the gradient evaluation count

fn increment_hessian_func_count(&mut self)

Increment the hessian evaluation count

fn increase_hessian_func_count(&mut self, count: u64)

Increase the hessian evaluation count by a given value

fn hessian_func_count(&self) -> u64

Return the gradient evaluation count

Loading content...

Implementors

Loading content...