Skip to main content

LineSearch

Trait LineSearch 

Source
pub trait LineSearch<D, F> {
    // Required methods
    fn search_direction(&mut self, direction: D);
    fn initial_step_length(&mut self, step_length: F) -> Result<(), Error>;
}
Expand description

§Line search trait

For a method to be used as a line search, it has to implement this trait.

It enables the optimization method to set the search direction and the initial step length of the line search.

§Example

use argmin::solver::linesearch::LineSearch;

struct MyLineSearch<D, F> {
    // `D` is the type of the search direction
    search_direction: D,
    // `F` is a floating point value (f32 or f64)
    init_step_length: F,
    // ...
}

impl<D, F> LineSearch<D, F> for MyLineSearch<D, F> {
    fn search_direction(&mut self, direction: D) {
        self.search_direction = direction;
    }

    fn initial_step_length(&mut self, step_length: F) -> Result<(), argmin::core::Error> {
        self.init_step_length = step_length;
        Ok(())
    }
}

Required Methods§

Source

fn search_direction(&mut self, direction: D)

Set the search direction

This is the direction in which the line search will be performed.

Source

fn initial_step_length(&mut self, step_length: F) -> Result<(), Error>

Set the initial step length

This indicates the first step length which will be tried.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<P, G, F> LineSearch<G, F> for HagerZhangLineSearch<P, G, F>

Source§

impl<P, G, F> LineSearch<G, F> for MoreThuenteLineSearch<P, G, F>
where F: ArgminFloat,

Source§

impl<P, G, L, F> LineSearch<G, F> for BacktrackingLineSearch<P, G, L, F>
where F: ArgminFloat,