pub trait LineSearch<P, F> {
    // Required methods
    fn search_direction(&mut self, direction: P);
    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<P, F> {
    // `P` is the type of the search direction, typically the same as the parameter vector
    search_direction: P,
    // `F` is a floating point value (f32 or f64)
    init_step_length: F,
    // ...
}

impl<P, F> LineSearch<P, F> for MyLineSearch<P, F> {
    fn search_direction(&mut self, direction: P) {
        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: P)

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.

Implementors§

source§

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

source§

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

source§

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