Trait argmin::solver::linesearch::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§
sourcefn search_direction(&mut self, direction: D)
fn search_direction(&mut self, direction: D)
Set the search direction
This is the direction in which the line search will be performed.
sourcefn initial_step_length(&mut self, step_length: F) -> Result<(), Error>
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.