pub mod backtracking;
pub mod more_thuente;
pub mod wolfe;
pub use backtracking::Backtracking;
pub use more_thuente::MoreThuente;
pub use wolfe::Wolfe;
pub trait LineSearch<P, V> {
fn next(
&mut self,
problem: &P,
param: &V,
cost: f64,
gradient: &V,
direction: &V,
) -> LineSearchResult;
}
#[derive(Debug, Clone, Copy)]
pub struct LineSearchResult {
pub alpha: f64,
pub cost_evals: u64,
pub gradient_evals: u64,
}
pub struct Constant(pub f64);
impl Constant {
pub fn new(alpha: f64) -> Self {
Self(alpha)
}
}
impl<P, V> LineSearch<P, V> for Constant {
fn next(
&mut self,
_problem: &P,
_param: &V,
_cost: f64,
_gradient: &V,
_direction: &V,
) -> LineSearchResult {
LineSearchResult {
alpha: self.0,
cost_evals: 0,
gradient_evals: 0,
}
}
}