gosh-linesearch 0.1.0

Line search algorithms for geometry optimization
Documentation
  • Coverage
  • 62.07%
    18 out of 29 items documented0 out of 15 items with examples
  • Size
  • Source code size: 96.96 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.9 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 35s Average build duration of successful builds.
  • all releases: 35s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ybyygu

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 {
        //
    }
}