Skip to main content

Crate lbfgsb_rs_pure

Crate lbfgsb_rs_pure 

Source
Expand description

A compact, self-contained reimplementation of an L-BFGS-B style solver in Rust.

This crate focuses on a safe, idiomatic Rust port of the algorithmic core of the classical L-BFGS-B package. It aims for algorithmic parity and reproducibility rather than maximal performance — for production use link a tuned BLAS/LAPACK provider.

The main public API is the LBFGSB type (in solver), together with the Status and Solution types returned by the solver.

Example

use lbfgsb_rs::{LBFGSB, Status};

let mut x = vec![0.0];
let lower = vec![-1.0];
let upper = vec![1.0];

let mut solver = LBFGSB::new(5);
let sol = solver
    .minimize(&mut x, &lower, &upper, |x| {
        let dx = x[0] - 0.5;
        (dx * dx, vec![2.0 * dx])
    })
    .unwrap();

assert_eq!(sol.status, Status::Converged);
assert!((sol.x[0] - 0.5).abs() < 1e-6);

Modules

  • blas : lightweight level-1 BLAS helpers used throughout the crate.
  • linesearch : line-search helpers (dcstep / lnsrlb / convenience methods).
  • linpack : small linpack routines (Cholesky / triangular solve).
  • subalgorithms: helper routines (active-set initialization, bmv partial port).
  • solver : high-level LBFGS-B driver (uses the above modules).

The crate re-exports LBFGSB from solver and provides the Status and Solution types here so solver can reference them as crate::Status and crate::Solution (matching the original design).

Re-exports§

pub use crate::solver::IterationControl;
pub use crate::solver::IterationInfo;
pub use crate::solver::LBFGSB;

Modules§

linpack
solver
High-level LBFGS-B solver implementation using the helper modules.
subalgorithms

Structs§

Solution
Solution returned by the solver.

Enums§

Status
Enum describing solver termination.

Constants§

CURVATURE_EPS
Minimum curvature s’y to accept BFGS update.
MAX_BACKTRACK
Maximum number of backtracking line search iterations used by convenience routines.

Functions§

daxpy
Compute y := y + a * x in-place.
dcopy
Copy vector x into y (y := x).
dcsrch
Minimal port of dcsrch (More’-Thuente controller).
dcstep
Compute a safeguarded step update for the More’-Thuente algorithm.
ddot
Compute the dot product of x and y.
dscal
Scale vector x by scalar a in-place (x := a * x).
line_search_and_update
Convenience line search for use by the simplified solver.
lnsrlb
Safeguarded More’-Thuente style line search driver.
lnsrlb_search
Convenience wrapper around lnsrlb that mirrors the previous line_search_and_update signature used by the solver. It sets standard More’-Thuente parameters and calls lnsrlb.