Crate gosh_linesearch

Crate gosh_linesearch 

Source
Expand description

Line search, also called one-dimensional search, refers to an optimization procedure for univariable functions.

§Available algorithms

  • MoreThuente
  • BackTracking
  • BackTrackingArmijo
  • BackTrackingWolfe
  • BackTrackingStrongWolfe

§References

  • Sun, W.; Yuan, Y. Optimization Theory and Methods: Nonlinear Programming, 1st ed.; Springer, 2006.
  • Nocedal, J.; Wright, S. Numerical Optimization; Springer Science & Business Media, 2006.

§Examples

use line::linesearch;

let mut step = 1.0;
let count = linesearch()
    .with_initial_step(1.5) // the default is 1.0
    .with_algorithm("BackTracking") // the default is MoreThuente
    .find(5, |a: f64, out: &mut Output| {
        // restore position
        x.veccpy(&x_k);
        // update position with step along d
        x.vecadd(&d_k, a);
        // update value and gradient
        out.fx = f(x, &mut gx)?;
        // update line search gradient
        out.gx = gx.vecdot(d);
        // update optimal step size
        step = a;
        // return any user defined data
        Ok(())
    })?;

let ls = linesearch()
    .with_max_iterations(5) // the default is 10
    .with_initial_step(1.5) // the default is 1.0
    .with_algorithm("BackTracking") // the default is MoreThuente
    .find_iter(|a: f64, out: &mut Output| {
        // restore position
        x.veccpy(&x_k);
        // update position with step along d
        x.vecadd(&d_k, a);
        // update value and gradient
        out.fx = f(x, &mut gx)?;
        // update line search gradient
        out.gx = gx.vecdot(d);
        // update optimal step size
        step = a;
        // return any user defined data
        Ok(())
    })?;

for success in ls {
    if success {
        //
    } else {
        //
    }
}

Structs§

LineSearch
LineSearchEval
T is user defined data
LineSearchIter
Output
Progress

Enums§

LineSearchAlgorithm
Line search algorithms.
LineSearchCondition

Traits§

LineSearchFindNext

Functions§

linesearch
A unified interface to line search methods.

Type Aliases§

Input