pub trait LineSearch<P, F> {
    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

Set the search direction

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

Set the initial step length

This indicates the first step length which will be tried.

Implementors