Struct argmin::core::IterState

source ·
pub struct IterState<P, G, J, H, R, F> {
Show 25 fields pub param: Option<P>, pub prev_param: Option<P>, pub best_param: Option<P>, pub prev_best_param: Option<P>, pub cost: F, pub prev_cost: F, pub best_cost: F, pub prev_best_cost: F, pub target_cost: F, pub grad: Option<G>, pub prev_grad: Option<G>, pub hessian: Option<H>, pub prev_hessian: Option<H>, pub inv_hessian: Option<H>, pub prev_inv_hessian: Option<H>, pub jacobian: Option<J>, pub prev_jacobian: Option<J>, pub residuals: Option<R>, pub prev_residuals: Option<R>, pub iter: u64, pub last_best_iter: u64, pub max_iters: u64, pub counts: HashMap<String, u64>, pub time: Option<Duration>, pub termination_status: TerminationStatus,
}
Expand description

Maintains the state from iteration to iteration of a solver

This struct is passed from one iteration of an algorithm to the next.

Keeps track of

  • parameter vector of current and previous iteration
  • best parameter vector of current and previous iteration
  • gradient of current and previous iteration
  • Jacobian of current and previous iteration
  • Hessian of current and previous iteration
  • inverse Hessian of current and previous iteration
  • cost function value of current and previous iteration
  • current and previous best cost function value
  • target cost function value
  • current iteration number
  • iteration number where the last best parameter vector was found
  • maximum number of iterations that will be executed
  • problem function evaluation counts (cost function, gradient, jacobian, hessian, annealing,…)
  • elapsed time
  • termination status

Fields§

§param: Option<P>

Current parameter vector

§prev_param: Option<P>

Previous parameter vector

§best_param: Option<P>

Current best parameter vector

§prev_best_param: Option<P>

Previous best parameter vector

§cost: F

Current cost function value

§prev_cost: F

Previous cost function value

§best_cost: F

Current best cost function value

§prev_best_cost: F

Previous best cost function value

§target_cost: F

Target cost function value

§grad: Option<G>

Current gradient

§prev_grad: Option<G>

Previous gradient

§hessian: Option<H>

Current Hessian

§prev_hessian: Option<H>

Previous Hessian

§inv_hessian: Option<H>

Current inverse Hessian

§prev_inv_hessian: Option<H>

Previous inverse Hessian

§jacobian: Option<J>

Current Jacobian

§prev_jacobian: Option<J>

Previous Jacobian

§residuals: Option<R>

Value of residuals from recent call to apply

§prev_residuals: Option<R>

Value of residuals from previous call to apply

§iter: u64

Current iteration

§last_best_iter: u64

Iteration number of last best cost

§max_iters: u64

Maximum number of iterations

§counts: HashMap<String, u64>

Evaluation counts

§time: Option<Duration>

Time required so far

§termination_status: TerminationStatus

Status of optimization execution

Implementations§

source§

impl<P, G, J, H, R, F> IterState<P, G, J, H, R, F>
where Self: State<Float = F>, F: ArgminFloat,

source

pub fn param(self, param: P) -> Self

Set parameter vector. This shifts the stored parameter vector to the previous parameter vector.

Example
let state = state.param(param);
source

pub fn gradient(self, gradient: G) -> Self

Set gradient. This shifts the stored gradient to the previous gradient.

Example
let state = state.gradient(grad);
source

pub fn hessian(self, hessian: H) -> Self

Set Hessian. This shifts the stored Hessian to the previous Hessian.

Example
let state = state.hessian(hessian);
source

pub fn inv_hessian(self, inv_hessian: H) -> Self

Set inverse Hessian. This shifts the stored inverse Hessian to the previous inverse Hessian.

Example
let state = state.inv_hessian(inv_hessian);
source

pub fn jacobian(self, jacobian: J) -> Self

Set Jacobian. This shifts the stored Jacobian to the previous Jacobian.

Example
let state = state.jacobian(jacobian);
source

pub fn cost(self, cost: F) -> Self

Set the current cost function value. This shifts the stored cost function value to the previous cost function value.

Example
let state = state.cost(cost);
source

pub fn target_cost(self, target_cost: F) -> Self

Set target cost.

When this cost is reached, the algorithm will stop. The default is Self::Float::NEG_INFINITY.

Example
let state = state.target_cost(0.0);
source

pub fn max_iters(self, iters: u64) -> Self

Set maximum number of iterations

Example
let state = state.max_iters(1000);
source

pub fn residuals(self, residuals: R) -> Self

Set residuals. This shifts the stored residuals to the previous residuals.

Example
let state = state.residuals(residuals);
source

pub fn get_cost(&self) -> F

Returns the current cost function value

Example
let cost = state.get_cost();
source

pub fn get_prev_cost(&self) -> F

Returns the previous cost function value

Example
let prev_cost = state.get_prev_cost();
source

pub fn get_best_cost(&self) -> F

Returns the current best cost function value

Example
let best_cost = state.get_best_cost();
source

pub fn get_prev_best_cost(&self) -> F

Returns the previous best cost function value

Example
let prev_best_cost = state.get_prev_best_cost();
source

pub fn get_target_cost(&self) -> F

Returns the target cost function value

Example
let target_cost = state.get_target_cost();
source

pub fn take_param(&mut self) -> Option<P>

Moves the current parameter vector out and replaces it internally with None

Example
let param = state.take_param();  // Option<P>
source

pub fn get_prev_param(&self) -> Option<&P>

Returns a reference to previous parameter vector

Example
let prev_param = state.get_prev_param();  // Option<&P>
source

pub fn take_prev_param(&mut self) -> Option<P>

Moves the previous parameter vector out and replaces it internally with None

Example
let prev_param = state.take_prev_param();  // Option<P>
source

pub fn get_prev_best_param(&self) -> Option<&P>

Returns a reference to previous best parameter vector

Example
let prev_best_param = state.get_prev_best_param();  // Option<&P>
source

pub fn take_best_param(&mut self) -> Option<P>

Moves the best parameter vector out and replaces it internally with None

Example
let best_param = state.take_best_param();  // Option<P>
source

pub fn take_prev_best_param(&mut self) -> Option<P>

Moves the previous best parameter vector out and replaces it internally with None

Example
let prev_best_param = state.take_prev_best_param();  // Option<P>
source

pub fn get_gradient(&self) -> Option<&G>

Returns a reference to the gradient

Example
let grad = state.get_gradient();  // Option<&G>
source

pub fn take_gradient(&mut self) -> Option<G>

Moves the gradient out and replaces it internally with None

Example
let grad = state.take_gradient();  // Option<G>
source

pub fn get_prev_gradient(&self) -> Option<&G>

Returns a reference to the previous gradient

Example
let prev_grad = state.get_prev_gradient();  // Option<&G>
source

pub fn take_prev_gradient(&mut self) -> Option<G>

Moves the gradient out and replaces it internally with None

Example
let prev_grad = state.take_prev_gradient();  // Option<G>
source

pub fn get_hessian(&self) -> Option<&H>

Returns a reference to the current Hessian

Example
let hessian = state.get_hessian();  // Option<&H>
source

pub fn take_hessian(&mut self) -> Option<H>

Moves the Hessian out and replaces it internally with None

Example
let hessian = state.take_hessian();  // Option<H>
source

pub fn get_prev_hessian(&self) -> Option<&H>

Returns a reference to the previous Hessian

Example
let prev_hessian = state.get_prev_hessian();  // Option<&H>
source

pub fn take_prev_hessian(&mut self) -> Option<H>

Moves the previous Hessian out and replaces it internally with None

Example
let prev_hessian = state.take_prev_hessian();  // Option<H>
source

pub fn get_inv_hessian(&self) -> Option<&H>

Returns a reference to the current inverse Hessian

Example
let inv_hessian = state.get_inv_hessian();  // Option<&H>
source

pub fn take_inv_hessian(&mut self) -> Option<H>

Moves the inverse Hessian out and replaces it internally with None

Example
let inv_hessian = state.take_inv_hessian();  // Option<H>
source

pub fn get_prev_inv_hessian(&self) -> Option<&H>

Returns a reference to the previous inverse Hessian

Example
let prev_inv_hessian = state.get_prev_inv_hessian();  // Option<&H>
source

pub fn take_prev_inv_hessian(&mut self) -> Option<H>

Moves the previous Hessian out and replaces it internally with None

Example
let prev_inv_hessian = state.take_prev_inv_hessian();  // Option<H>
source

pub fn get_jacobian(&self) -> Option<&J>

Returns a reference to the current Jacobian

Example
let jacobian = state.get_jacobian();  // Option<&J>
source

pub fn take_jacobian(&mut self) -> Option<J>

Moves the Jacobian out and replaces it internally with None

Example
let jacobian = state.take_jacobian();  // Option<J>
source

pub fn get_prev_jacobian(&self) -> Option<&J>

Returns a reference to the previous Jacobian

Example
let prev_jacobian = state.get_prev_jacobian();  // Option<&J>
source

pub fn take_prev_jacobian(&mut self) -> Option<J>

Moves the previous Jacobian out and replaces it internally with None

Example
let prev_jacobian = state.take_prev_jacobian();  // Option<J>
source

pub fn get_residuals(&self) -> Option<&R>

Returns a reference to the residuals

Example
let residuals = state.get_residuals();  // Option<&R>
source

pub fn take_residuals(&mut self) -> Option<R>

Moves the residuals out and replaces it internally with None

Example
let residuals = state.take_residuals();  // Option<R>
source

pub fn get_prev_residuals(&self) -> Option<&R>

Returns a reference to the previous residuals

Example
let residuals = state.get_residuals();  // Option<&R>
source

pub fn take_prev_residuals(&mut self) -> Option<R>

Moves the previous residuals out and replaces it internally with None

Example
let residuals = state.take_residuals();  // Option<R>

Trait Implementations§

source§

impl<P: Clone, G: Clone, J: Clone, H: Clone, R: Clone, F: Clone> Clone for IterState<P, G, J, H, R, F>

source§

fn clone(&self) -> IterState<P, G, J, H, R, F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<P: Debug, G: Debug, J: Debug, H: Debug, R: Debug, F: Debug> Debug for IterState<P, G, J, H, R, F>

source§

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

Formats the value using the given formatter. Read more
source§

impl<P: Default, G: Default, J: Default, H: Default, R: Default, F: Default> Default for IterState<P, G, J, H, R, F>

source§

fn default() -> IterState<P, G, J, H, R, F>

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

impl<'de, P, G, J, H, R, F> Deserialize<'de> for IterState<P, G, J, H, R, F>
where P: Deserialize<'de>, G: Deserialize<'de>, J: Deserialize<'de>, H: Deserialize<'de>, R: Deserialize<'de>, F: Deserialize<'de>,

source§

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

Deserialize this value from the given Serde deserializer. Read more
source§

impl<P: PartialEq, G: PartialEq, J: PartialEq, H: PartialEq, R: PartialEq, F: PartialEq> PartialEq for IterState<P, G, J, H, R, F>

source§

fn eq(&self, other: &IterState<P, G, J, H, R, F>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<P, G, J, H, R, F> Serialize for IterState<P, G, J, H, R, F>

source§

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

Serialize this value into the given Serde serializer. Read more
source§

impl<O, F> Solver<O, IterState<F, (), (), (), (), F>> for BrentOpt<F>
where O: CostFunction<Param = F, Output = F>, F: ArgminFloat,

source§

const NAME: &'static str = "BrentOpt"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<F, (), (), (), (), F> ) -> Result<(IterState<F, (), (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<F, (), (), (), (), F> ) -> Result<(IterState<F, (), (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<O, F> Solver<O, IterState<F, (), (), (), (), F>> for BrentRoot<F>
where O: CostFunction<Param = F, Output = F>, F: ArgminFloat,

source§

const NAME: &'static str = "BrentRoot"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<F, (), (), (), (), F> ) -> Result<(IterState<F, (), (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<F, (), (), (), (), F> ) -> Result<(IterState<F, (), (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<O, F> Solver<O, IterState<F, (), (), (), (), F>> for GoldenSectionSearch<F>
where O: CostFunction<Param = F, Output = F>, F: ArgminFloat,

source§

const NAME: &'static str = "Golden-section search"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<F, (), (), (), (), F> ) -> Result<(IterState<F, (), (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<F, (), (), (), (), F> ) -> Result<(IterState<F, (), (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, _state: &IterState<F, (), (), (), (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, P, F> Solver<O, IterState<P, (), (), (), (), F>> for NelderMead<P, F>
where O: CostFunction<Param = P, Output = F>, P: Clone + ArgminSub<P, P> + ArgminAdd<P, P> + ArgminMul<F, P>, F: ArgminFloat + Sum<F>,

source§

const NAME: &'static str = "Nelder-Mead method"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), (), F> ) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), (), F> ) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, _state: &IterState<P, (), (), (), (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, P, F, R> Solver<O, IterState<P, (), (), (), (), F>> for SimulatedAnnealing<F, R>
where O: CostFunction<Param = P, Output = F> + Anneal<Param = P, Output = P, Float = F>, P: Clone, F: ArgminFloat, R: Rng,

source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), (), F> ) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>

Perform one iteration of SA algorithm

source§

const NAME: &'static str = "Simulated Annealing"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), (), F> ) -> Result<(IterState<P, (), (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate( &mut self, _state: &IterState<P, (), (), (), (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<P, O, R, F> Solver<O, IterState<P, (), (), (), R, F>> for ConjugateGradient<P, F>
where O: Operator<Param = P, Output = P>, P: Clone + ArgminDot<P, F> + ArgminSub<P, R> + ArgminScaledAdd<P, F, P> + ArgminConj, R: ArgminMul<F, R> + ArgminMul<F, P> + ArgminConj + ArgminDot<R, F> + ArgminScaledAdd<P, F, R>, F: ArgminFloat + ArgminL2Norm<F>,

source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), R, F> ) -> Result<(IterState<P, (), (), (), R, F>, Option<KV>), Error>

Perform one iteration of CG algorithm

source§

const NAME: &'static str = "Conjugate Gradient"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, (), (), (), R, F> ) -> Result<(IterState<P, (), (), (), R, F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<O, P, J, R, F> Solver<O, IterState<P, (), J, (), R, F>> for GaussNewton<F>
where O: Operator<Param = P, Output = R> + Jacobian<Param = P, Jacobian = J>, P: Clone + ArgminSub<P, P> + ArgminMul<F, P>, R: ArgminL2Norm<F>, J: Clone + ArgminTranspose<J> + ArgminInv<J> + ArgminDot<J, J> + ArgminDot<R, P> + ArgminDot<P, P>, F: ArgminFloat,

source§

const NAME: &'static str = "Gauss-Newton method"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, (), J, (), R, F> ) -> Result<(IterState<P, (), J, (), R, F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, (), J, (), R, F> ) -> Result<(IterState<P, (), J, (), R, F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, (), J, (), R, F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, P, G, L, F> Solver<O, IterState<P, G, (), (), (), F>> for BacktrackingLineSearch<P, G, L, F>
where P: Clone + ArgminScaledAdd<G, F, P>, G: ArgminScaledAdd<G, F, G>, O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, L: LineSearchCondition<G, G, F>, F: ArgminFloat,

source§

const NAME: &'static str = "Backtracking line search"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, (), (), (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<P, G, O, F> Solver<O, IterState<P, G, (), (), (), F>> for HagerZhangLineSearch<P, G, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, P: Clone + ArgminDot<G, F> + ArgminScaledAdd<G, F, P>, G: Clone + ArgminDot<G, F>, F: ArgminFloat,

source§

const NAME: &'static str = "Hager-Zhang line search"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, _state: &IterState<P, G, (), (), (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, L, P, G, F> Solver<O, IterState<P, G, (), (), (), F>> for LBFGS<L, P, G, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, P: Clone + ArgminSub<P, P> + ArgminSub<F, P> + ArgminAdd<P, P> + ArgminAdd<F, P> + ArgminDot<G, F> + ArgminMul<F, P> + ArgminMul<P, P> + ArgminMul<G, P> + ArgminL1Norm<F> + ArgminSignum + ArgminZeroLike + ArgminMinMax, G: Clone + ArgminL2Norm<F> + ArgminSub<G, G> + ArgminAdd<G, G> + ArgminAdd<P, G> + ArgminDot<G, F> + ArgminDot<P, F> + ArgminMul<F, G> + ArgminMul<F, P> + ArgminZeroLike + ArgminMinMax, L: Clone + LineSearch<P, F> + Solver<LineSearchProblem<O, P, G, F>, IterState<P, G, (), (), (), F>>, F: ArgminFloat,

source§

const NAME: &'static str = "L-BFGS"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, (), (), (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, F, P, G> Solver<O, IterState<P, G, (), (), (), F>> for Landweber<F>
where O: Gradient<Param = P, Gradient = G>, P: Clone + ArgminScaledSub<G, F, P>, F: ArgminFloat,

source§

const NAME: &'static str = "Landweber"

Name of the solver. Mainly used in Observers.
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn init( &mut self, _problem: &mut Problem<O>, state: I ) -> Result<(I, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<P, G, O, F> Solver<O, IterState<P, G, (), (), (), F>> for MoreThuenteLineSearch<P, G, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, P: Clone + ArgminDot<G, F> + ArgminScaledAdd<G, F, P>, G: Clone + ArgminDot<G, F>, F: ArgminFloat,

source§

const NAME: &'static str = "More-Thuente Line search"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<O, P, G, L, B, F> Solver<O, IterState<P, G, (), (), (), F>> for NonlinearConjugateGradient<P, L, B, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, P: Clone + ArgminAdd<P, P> + ArgminMul<F, P>, G: Clone + ArgminMul<F, P> + ArgminDot<G, F> + ArgminL2Norm<F>, L: Clone + LineSearch<P, F> + Solver<O, IterState<P, G, (), (), (), F>>, B: NLCGBetaUpdate<G, P, F>, F: ArgminFloat,

source§

const NAME: &'static str = "Nonlinear Conjugate Gradient"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<O, L, P, G, F> Solver<O, IterState<P, G, (), (), (), F>> for SteepestDescent<L>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, P: Clone, G: Clone + ArgminMul<F, G>, L: Clone + LineSearch<G, F> + Solver<O, IterState<P, G, (), (), (), F>>, F: ArgminFloat,

source§

const NAME: &'static str = "Steepest Descent"

Name of the solver. Mainly used in Observers.
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), (), (), F> ) -> Result<(IterState<P, G, (), (), (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn init( &mut self, _problem: &mut Problem<O>, state: I ) -> Result<(I, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<O, R, P, G, B, F> Solver<O, IterState<P, G, (), B, (), F>> for SR1TrustRegion<R, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G> + Hessian<Param = P, Hessian = B>, P: Clone + ArgminSub<P, P> + ArgminAdd<P, P> + ArgminDot<P, F> + ArgminDot<P, B> + ArgminL2Norm<F> + ArgminZeroLike, G: Clone + ArgminL2Norm<F> + ArgminDot<P, F> + ArgminSub<G, P>, B: Clone + ArgminDot<P, P> + ArgminAdd<B, B> + ArgminMul<F, B>, R: Clone + TrustRegionRadius<F> + Solver<O, IterState<P, G, (), B, (), F>>, F: ArgminFloat + ArgminL2Norm<F>,

source§

const NAME: &'static str = "SR1 trust region"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), B, (), F> ) -> Result<(IterState<P, G, (), B, (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), B, (), F> ) -> Result<(IterState<P, G, (), B, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, (), B, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, L, P, G, H, F> Solver<O, IterState<P, G, (), H, (), F>> for BFGS<L, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, P: Clone + ArgminSub<P, P> + ArgminDot<G, H> + ArgminDot<P, H>, G: Clone + ArgminL2Norm<F> + ArgminMul<F, P> + ArgminDot<P, F> + ArgminSub<G, G>, H: ArgminSub<H, H> + ArgminDot<G, G> + ArgminDot<H, H> + ArgminAdd<H, H> + ArgminMul<F, H> + ArgminTranspose<H> + ArgminEye, L: Clone + LineSearch<P, F> + Solver<O, IterState<P, G, (), (), (), F>>, F: ArgminFloat,

source§

const NAME: &'static str = "BFGS"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, (), H, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, F, P, G, H> Solver<O, IterState<P, G, (), H, (), F>> for CauchyPoint<F>
where O: Gradient<Param = P, Gradient = G> + Hessian<Param = P, Hessian = H>, P: Clone + ArgminMul<F, P> + ArgminWeightedDot<P, F, H>, G: ArgminMul<F, P> + ArgminWeightedDot<G, F, H> + ArgminL2Norm<F>, F: ArgminFloat,

source§

const NAME: &'static str = "Cauchy Point"

Name of the solver. Mainly used in Observers.
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, (), H, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn init( &mut self, _problem: &mut Problem<O>, state: I ) -> Result<(I, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, L, P, G, H, F> Solver<O, IterState<P, G, (), H, (), F>> for DFP<L, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, P: Clone + ArgminSub<P, P> + ArgminDot<G, F> + ArgminDot<P, H> + ArgminMul<F, P>, G: Clone + ArgminSub<G, G> + ArgminL2Norm<F> + ArgminDot<P, F>, H: Clone + ArgminSub<H, H> + ArgminDot<G, P> + ArgminAdd<H, H> + ArgminMul<F, H>, L: Clone + LineSearch<P, F> + Solver<O, IterState<P, G, (), (), (), F>>, F: ArgminFloat,

source§

const NAME: &'static str = "DFP"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, (), H, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, P, G, H, F> Solver<O, IterState<P, G, (), H, (), F>> for Newton<F>
where O: Gradient<Param = P, Gradient = G> + Hessian<Param = P, Hessian = H>, P: Clone + ArgminScaledSub<P, F, P>, H: ArgminInv<H> + ArgminDot<G, P>, F: ArgminFloat,

source§

const NAME: &'static str = "Newton method"

Name of the solver. Mainly used in Observers.
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn init( &mut self, _problem: &mut Problem<O>, state: I ) -> Result<(I, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<O, L, P, G, H, F> Solver<O, IterState<P, G, (), H, (), F>> for NewtonCG<L, F>
where O: Gradient<Param = P, Gradient = G> + Hessian<Param = P, Hessian = H>, P: Clone + ArgminSub<P, P> + ArgminDot<P, F> + ArgminScaledAdd<P, F, P> + ArgminMul<F, P> + ArgminConj + ArgminZeroLike, G: ArgminL2Norm<F> + ArgminMul<F, P>, H: Clone + ArgminDot<P, P>, L: Clone + LineSearch<P, F> + Solver<O, IterState<P, G, (), (), (), F>>, F: ArgminFloat + ArgminL2Norm<F>,

source§

const NAME: &'static str = "Newton-CG"

Name of the solver. Mainly used in Observers.
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, (), H, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn init( &mut self, _problem: &mut Problem<O>, state: I ) -> Result<(I, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, L, P, G, H, F> Solver<O, IterState<P, G, (), H, (), F>> for SR1<L, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G>, P: Clone + ArgminSub<P, P> + ArgminDot<G, F> + ArgminDot<P, F> + ArgminDot<P, H> + ArgminL2Norm<F> + ArgminMul<F, P>, G: Clone + ArgminSub<P, P> + ArgminL2Norm<F> + ArgminSub<G, G>, H: ArgminDot<G, P> + ArgminDot<P, P> + ArgminAdd<H, H> + ArgminMul<F, H>, L: Clone + LineSearch<P, F> + Solver<O, IterState<P, G, (), (), (), F>>, F: ArgminFloat,

source§

const NAME: &'static str = "SR1"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, (), H, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, R, F, P, G, H> Solver<O, IterState<P, G, (), H, (), F>> for TrustRegion<R, F>
where O: CostFunction<Param = P, Output = F> + Gradient<Param = P, Gradient = G> + Hessian<Param = P, Hessian = H>, P: Clone + ArgminL2Norm<F> + ArgminDot<P, F> + ArgminDot<G, F> + ArgminAdd<P, P>, G: Clone, H: Clone + ArgminDot<P, P>, R: Clone + TrustRegionRadius<F> + Solver<O, IterState<P, G, (), H, (), F>>, F: ArgminFloat,

source§

const NAME: &'static str = "Trust region"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, (), H, (), F> ) -> Result<(IterState<P, G, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, _state: &IterState<P, G, (), H, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, L, F, P, G, J, U, R> Solver<O, IterState<P, G, J, (), R, F>> for GaussNewtonLS<L, F>
where O: Operator<Param = P, Output = U> + Jacobian<Param = P, Jacobian = J>, P: Clone + ArgminMul<F, P>, G: Clone, U: ArgminL2Norm<F>, J: Clone + ArgminTranspose<J> + ArgminInv<J> + ArgminDot<J, J> + ArgminDot<G, P> + ArgminDot<U, G>, L: Clone + LineSearch<P, F> + Solver<LineSearchProblem<O, F>, IterState<P, G, (), (), R, F>>, F: ArgminFloat, R: Clone,

source§

const NAME: &'static str = "Gauss-Newton method with line search"

Name of the solver. Mainly used in Observers.
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, G, J, (), R, F> ) -> Result<(IterState<P, G, J, (), R, F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, G, J, (), R, F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn init( &mut self, _problem: &mut Problem<O>, state: I ) -> Result<(I, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O, F, P, H> Solver<O, IterState<P, P, (), H, (), F>> for Dogleg<F>
where O: Gradient<Param = P, Gradient = P> + Hessian<Param = P, Hessian = H>, P: Clone + ArgminMul<F, P> + ArgminL2Norm<F> + ArgminDot<P, F> + ArgminAdd<P, P> + ArgminSub<P, P>, H: ArgminInv<H> + ArgminDot<P, P>, F: ArgminFloat,

source§

const NAME: &'static str = "Dogleg"

Name of the solver. Mainly used in Observers.
source§

fn next_iter( &mut self, problem: &mut Problem<O>, state: IterState<P, P, (), H, (), F> ) -> Result<(IterState<P, P, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, P, (), H, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn init( &mut self, _problem: &mut Problem<O>, state: I ) -> Result<(I, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<P, O, F, H> Solver<O, IterState<P, P, (), H, (), F>> for Steihaug<P, F>
where P: Clone + ArgminMul<F, P> + ArgminL2Norm<F> + ArgminDot<P, F> + ArgminAdd<P, P> + ArgminZeroLike, H: ArgminDot<P, P>, F: ArgminFloat,

source§

const NAME: &'static str = "Steihaug"

Name of the solver. Mainly used in Observers.
source§

fn init( &mut self, _problem: &mut Problem<O>, state: IterState<P, P, (), H, (), F> ) -> Result<(IterState<P, P, (), H, (), F>, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn next_iter( &mut self, _problem: &mut Problem<O>, state: IterState<P, P, (), H, (), F> ) -> Result<(IterState<P, P, (), H, (), F>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn terminate( &mut self, state: &IterState<P, P, (), H, (), F> ) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

impl<O> Solver<O, IterState<Vec<f64>, (), (), (), (), f64>> for TestSolver

source§

const NAME: &'static str = "TestSolver"

Name of the solver. Mainly used in Observers.
source§

fn next_iter( &mut self, _problem: &mut Problem<O>, state: IterState<Vec<f64>, (), (), (), (), f64> ) -> Result<(IterState<Vec<f64>, (), (), (), (), f64>, Option<KV>), Error>

Computes a single iteration of the algorithm and has access to the optimization problem definition and the internal state of the solver. Returns an updated state and optionally a KV which holds key-value pairs used in Observers.
source§

fn init( &mut self, _problem: &mut Problem<O>, state: I ) -> Result<(I, Option<KV>), Error>

Initializes the algorithm. Read more
source§

fn terminate_internal(&mut self, state: &I) -> TerminationStatus

Checks whether basic termination reasons apply. Read more
source§

fn terminate(&mut self, _state: &I) -> TerminationStatus

Used to implement stopping criteria, in particular criteria which are not covered by (terminate_internal. Read more
source§

impl<P, G, J, H, R, F> State for IterState<P, G, J, H, R, F>
where P: Clone, F: ArgminFloat,

§

type Param = P

Type of parameter vector

§

type Float = F

Floating point precision

source§

fn new() -> Self

Create a new IterState instance

Example
let state: IterState<Vec<f64>, Vec<f64>, Vec<Vec<f64>>, Vec<Vec<f64>>, Vec<f64>, f64> = IterState::new();
source§

fn update(&mut self)

Checks if the current parameter vector is better than the previous best parameter value. If a new best parameter vector was found, the state is updated accordingly.

Example
let mut state: IterState<Vec<f64>, (), (), (), (), f64> = IterState::new();

// Simulating a new, better parameter vector
state.best_param = Some(vec![1.0f64]);
state.best_cost = 10.0;
state.param = Some(vec![2.0f64]);
state.cost = 5.0;

// Calling update
state.update();

// Check if update was successful
assert_eq!(state.best_param.as_ref().unwrap()[0], 2.0f64);
assert_eq!(state.best_cost.to_ne_bytes(), state.best_cost.to_ne_bytes());
assert!(state.is_best());

For algorithms which do not compute the cost function, every new parameter vector will be the new best:

let mut state: IterState<Vec<f64>, (), (), (), (), f64> = IterState::new();

// Simulating a new, better parameter vector
state.best_param = Some(vec![1.0f64]);
state.param = Some(vec![2.0f64]);

// Calling update
state.update();

// Check if update was successful
assert_eq!(state.best_param.as_ref().unwrap()[0], 2.0f64);
assert_eq!(state.best_cost.to_ne_bytes(), state.best_cost.to_ne_bytes());
assert!(state.is_best());
source§

fn get_param(&self) -> Option<&P>

Returns a reference to the current parameter vector

Example
let param = state.get_param();  // Option<&P>
source§

fn get_best_param(&self) -> Option<&P>

Returns a reference to the current best parameter vector

Example
let best_param = state.get_best_param();  // Option<&P>
source§

fn terminate_with(self, reason: TerminationReason) -> Self

Sets the termination status to Terminated with the given reason

Example
let state = state.terminate_with(TerminationReason::MaxItersReached);
source§

fn time(&mut self, time: Option<Duration>) -> &mut Self

Sets the time required so far.

Example
let state = state.time(Some(instant::Duration::new(0, 12)));
source§

fn get_cost(&self) -> Self::Float

Returns current cost function value.

Example
let cost = state.get_cost();
source§

fn get_best_cost(&self) -> Self::Float

Returns current best cost function value.

Example
let best_cost = state.get_best_cost();
source§

fn get_target_cost(&self) -> Self::Float

Returns target cost function value.

Example
let target_cost = state.get_target_cost();
source§

fn get_iter(&self) -> u64

Returns current number of iterations.

Example
let iter = state.get_iter();
source§

fn get_last_best_iter(&self) -> u64

Returns iteration number of last best parameter vector.

Example
let last_best_iter = state.get_last_best_iter();
source§

fn get_max_iters(&self) -> u64

Returns the maximum number of iterations.

Example
let max_iters = state.get_max_iters();
source§

fn get_termination_status(&self) -> &TerminationStatus

Returns the termination status.

Example
let termination_status = state.get_termination_status();
source§

fn get_termination_reason(&self) -> Option<&TerminationReason>

Returns the termination reason if terminated, otherwise None.

Example
let termination_reason = state.get_termination_reason();
source§

fn get_time(&self) -> Option<Duration>

Returns the time elapsed since the start of the optimization.

Example
let time = state.get_time();
source§

fn increment_iter(&mut self)

Increments the number of iterations by one

Example
state.increment_iter();
source§

fn func_counts<O>(&mut self, problem: &Problem<O>)

Set all function evaluation counts to the evaluation counts of another Problem.

state.func_counts(&problem);
source§

fn get_func_counts(&self) -> &HashMap<String, u64>

Returns function evaluation counts

Example
let counts = state.get_func_counts();
source§

fn is_best(&self) -> bool

Returns whether the current parameter vector is also the best parameter vector found so far.

Example
let is_best = state.is_best();
source§

fn terminated(&self) -> bool

Return whether the algorithm has terminated or not
source§

impl<P: Eq, G: Eq, J: Eq, H: Eq, R: Eq, F: Eq> Eq for IterState<P, G, J, H, R, F>

source§

impl<P, G, J, H, R, F> StructuralEq for IterState<P, G, J, H, R, F>

source§

impl<P, G, J, H, R, F> StructuralPartialEq for IterState<P, G, J, H, R, F>

Auto Trait Implementations§

§

impl<P, G, J, H, R, F> RefUnwindSafe for IterState<P, G, J, H, R, F>

§

impl<P, G, J, H, R, F> Send for IterState<P, G, J, H, R, F>
where F: Send, G: Send, H: Send, J: Send, P: Send, R: Send,

§

impl<P, G, J, H, R, F> Sync for IterState<P, G, J, H, R, F>
where F: Sync, G: Sync, H: Sync, J: Sync, P: Sync, R: Sync,

§

impl<P, G, J, H, R, F> Unpin for IterState<P, G, J, H, R, F>
where F: Unpin, G: Unpin, H: Unpin, J: Unpin, P: Unpin, R: Unpin,

§

impl<P, G, J, H, R, F> UnwindSafe for IterState<P, G, J, H, R, F>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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.
source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

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

source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

source§

impl<T> SendAlias for T

source§

impl<T> SyncAlias for T