l_bfgs_b: Limited-memory BFGS with Box Constraints (L-BFGS-B)

View source: R/l_bfgs_b.R

l_bfgs_bR Documentation

Limited-memory BFGS with Box Constraints (L-BFGS-B)

Description

Performs bound-constrained minimization using the L-BFGS-B algorithm. This implementation handles box constraints via Generalized Cauchy Point (GCP) estimation and subspace minimization, featuring a limited-memory (two-loop recursion) inverse Hessian approximation.

Usage

l_bfgs_b(
  start,
  objective,
  gradient = NULL,
  hessian = NULL,
  lower = -Inf,
  upper = Inf,
  control = list(),
  ...
)

Arguments

start

Numeric vector. Initial values for the parameters.

objective

Function. The scalar objective function to be minimized.

gradient

Function (optional). Returns the gradient vector. If NULL, numerical derivatives are used.

hessian

Function (optional). Returns the Hessian matrix. Used for final positive definiteness verification if use_posdef = TRUE.

lower, upper

Numeric vectors. Lower and upper bounds for the parameters. Can be scalars if all parameters share the same bounds.

control

A list of control parameters:

  • use_abs_f: Logical. Criterion: |f_{new} - f_{old}| < tol_abs_f.

  • use_rel_f: Logical. Criterion: |(f_{new} - f_{old}) / f_{old}| < tol_rel_f.

  • use_abs_x: Logical. Criterion: \max |x_{new} - x_{old}| < tol_abs_x.

  • use_rel_x: Logical. Criterion: \max |(x_{new} - x_{old}) / x_{old}| < tol_rel_x.

  • use_grad: Logical. Criterion: \|g\|_\infty < tol_grad.

  • use_posdef: Logical. Criterion: Positive definiteness of the Hessian.

  • max_iter: Maximum number of iterations (default: 10000).

  • m: Number of L-BFGS memory updates (default: 5).

  • tol_abs_f, tol_rel_f: Tolerances for function value change.

  • tol_abs_x, tol_rel_x: Tolerances for parameter change.

  • tol_grad: Tolerance for the projected gradient (default: 1e-4).

...

Additional arguments passed to objective, gradient, and Hessian functions.

Value

A list containing optimization results and metadata.

Comparison with Existing Functions

This function adds three features for rigorous convergence control. First, it applies an AND rule: all selected convergence criteria must be satisfied simultaneously. Second, users can choose among eight distinct criteria (e.g., changes in f, x, gradient, or predicted decrease) instead of relying on fixed defaults. Third, it provides an optional verification using the Hessian computed from derivatives (analytically when provided, or via numerical differentiation). Checking the positive definiteness of this Hessian at the final solution reduces the risk of declaring convergence at non-minimizing stationary points, such as saddle points.

References

Byrd, R. H., Lu, P., Nocedal, J., & Zhu, C. (1995). A limited memory algorithm for bound constrained optimization. SIAM Journal on Scientific Computing, 16(5), 1190-1208.

Morales, J. L., & Nocedal, J. (2011). L-BFGS-B: Remark on algorithm 778: L-BFGS-B: Fortran subroutines for large-scale bound-constrained optimization. ACM Transactions on Mathematical Software, 38(1), 1-4.

Examples

quad <- function(x) (x[1] - 2)^2 + (x[2] + 1)^2
res <- l_bfgs_b(start = c(0, 0), objective = quad)
print(res$par)

optimflex documentation built on April 11, 2026, 5:06 p.m.