pub trait LineSearchCondition<T, G, F> {
    // Required methods
    fn evaluate_condition(
        &self,
        current_cost: F,
        current_gradient: Option<&G>,
        initial_cost: F,
        initial_gradient: &G,
        search_direction: &T,
        step_length: F
    ) -> bool;
    fn requires_current_gradient(&self) -> bool;
}
Expand description

Interface which a condition needs to implement.

§Example

use argmin::solver::linesearch::condition::LineSearchCondition;

pub struct MyCondition {}

impl<T, G, F> LineSearchCondition<T, G, F> for MyCondition {
    fn evaluate_condition(
        &self,
        current_cost: F,
        current_gradient: Option<&G>,
        initial_cost: F,
        initial_gradient: &G,
        search_direction: &T,
        step_length: F,
    ) -> bool {
        // Use the current cost function value, the current gradient, the initial cost function
        // value, the initial gradient, the search direction and the current step length to
        // compute whether your condition is met (return `true`) or not (return `false`).
    }

    fn requires_current_gradient(&self) -> bool {
        // Indicate to the calling method whether your condition requires the current gradient
        // (at the position defined by the current step length).
        true
    }
}

Required Methods§

source

fn evaluate_condition( &self, current_cost: F, current_gradient: Option<&G>, initial_cost: F, initial_gradient: &G, search_direction: &T, step_length: F ) -> bool

Evaluate the condition

This method has access to the initial cost function value and the initial gradient (at the initial point from where to search from), the current cost function value at the initial point plus a step in search direction of length step_length as well as (optionally) the gradient at that point. It further has access to the search direction and the step length.

It returns true if the condition was met and false if not.

source

fn requires_current_gradient(&self) -> bool

Indicates whether this condition requires the computation of the gradient at the new point

This should return false if the evaluation of the condition does not require the gradient at the current point and true otherwise.

Implementors§

source§

impl<T, G, F> LineSearchCondition<T, G, F> for ArmijoCondition<F>
where G: ArgminDot<T, F>, F: ArgminFloat,

source§

impl<T, G, F> LineSearchCondition<T, G, F> for GoldsteinCondition<F>
where G: ArgminDot<T, F>, F: ArgminFloat,

source§

impl<T, G, F> LineSearchCondition<T, G, F> for StrongWolfeCondition<F>
where G: ArgminDot<T, F>, F: ArgminFloat,

source§

impl<T, G, F> LineSearchCondition<T, G, F> for WolfeCondition<F>
where G: ArgminDot<T, F>, F: ArgminFloat,