LBFGSB (L-BFGS-B) mex wrapper

L-BFGS-B, converted from Fortran to C, with Matlab wrapper
5.9K Downloads
Updated 5 Aug 2022
----------------------- UPDATE Aug 2023 ----------------------------------------
I've linked this code to github (https://github.com/stephenbeckr/L-BFGS-B-C). If you want the original code, you can find that under the "Version History" tab (v1.6 and earlier).
----------------------- UPDATE Feb 2015 ----------------------------------------
Due to the difficulty of compiling Fortran for most people (including myself), I have converted the v3.0 L-BFGS-B Fortran code into C (using f2c and some hand-coded changes). I have a new wrapper for it as well; both the C code and the mex wrapper are available at: https://github.com/stephenbeckr/L-BFGS-B-C
You are still welcome to try this code, and if you get it to compile, there will be no major difference in speed or performance. Feel free to leave comments/feedback below. However, I will no longer support this version of the code.
----------------------- END UPDATE ----------------------------------------------
Description: L-BFGS-B is a variant of the well-known "BFGS" quasi-Newton method. This variant uses limited-memory (like L-BFGS), and also handles simple constraints (to be specific, bound constraints, so this includes x >=0 constraints).
The authors of LBFGSB have had fortran implementations available since 1996, but in 2011 they released a major update (v3.0) which has an improved algorithm (you should use this version!). There are existing mex file wrappers for earlier versions, but none worked with v3.0, so I created this file.
This submission tries to make the mex wrapper simple, and then includes a nice .m file solver that requires very few parameters, yet is customizable for advanced users. Run the compile_mex.m file to compile the files. compile_mex.m also includes two quick sanity checks (the file driver1.m is a helper file for one of these checks)
I also have an example of using L-BFGS-B to solve the non-negative least-squares
(NNLS) problem, and comparing it to other existing solvers. To put it simply,
L-BFGS-B is a fantastic NNLS solver, and much better than Matlab's lsqnonneg.
Links:
The fortran lbfgsb is at http://users.eecs.northwestern.edu/~nocedal/lbfgsb.html,
There are also versions 2.1 and 2.4 of the library.
For v 2.1, Peter Carbonetto's mex interface works; see http://www.mathworks.com/matlabcentral/fileexchange/15061-matlab-interface-for-l-bfgs-b and also http://www.cs.ubc.ca/~pcarbo/lbfgsb-for-matlab.html
For v 2.4 (I don't know where you can find this version though), use the mex files from here: http://www.cs.toronto.edu/~liam/software.shtml
The wikipedia page (this was mainly edited by one of the authors of the L-BFGS-B algorithm): http://en.wikipedia.org/wiki/L-BFGS-B:_Optimization_subject_to_simple_bounds
For installing on 64-bit Windows, if you need a compiler, see http://www.mathworks.com/support/compilers/R2011b/win64.html
=== Update, Jan 2015 ===
I am not able to completely support installation/compiling of this toolbox. If you have issues, please mention in the comments below (there are also some solutions from other users in the comments below). Newer versions of Matlab keep changing how files compile (e.g., recent versions do not allow fortran and C to be compiled together), and I am not able to keep up.
If you are using mac or linux, there is a good chance that we can get it to compile. If you are using 64-bit Windows, there is a slim chance you can get it to compile. So please take this as a warning! If anyone is good at software installation and wants to take over the installation script, please do so. The actual wrapper script is quite simple.

Cite As

Stephen Becker (2024). LBFGSB (L-BFGS-B) mex wrapper (https://github.com/stephenbeckr/L-BFGS-B-C/releases/tag/v1.7), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Nonlinear Optimization in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.7

See release notes for this release on GitHub: https://github.com/stephenbeckr/L-BFGS-B-C/releases/tag/v1.7

1.6.0.0

Link to alternative implementation

1.5.0.0

No changes to files, just declaring that I cannot support 64-bit Windows. Sorry!

1.4.0.0

Removed unnecessary zip file from the package

1.3.0.0

adding compile_mex_forWindows.m

1.2.0.0

June 25, minor tweaks to code and install script to help with 64-bit computers. I also include an experimental f2c version (all in C) that doesn't require a fortran.

1.0.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.