LBFGSB (L-BFGS-B) mex wrapper

버전 1.7 (160 KB) 작성자: Stephen Becker
L-BFGS-B, converted from Fortran to C, with Matlab wrapper
다운로드 수: 5.9K
업데이트 날짜: 2022/8/5
----------------------- UPDATE Aug 2023 ----------------------------------------
I've linked this code to github ( 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:
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.
The fortran lbfgsb is at,
There are also versions 2.1 and 2.4 of the library.
For v 2.1, Peter Carbonetto's mex interface works; see and also
For v 2.4 (I don't know where you can find this version though), use the mex files from here:
The wikipedia page (this was mainly edited by one of the authors of the L-BFGS-B algorithm):
For installing on 64-bit Windows, if you need a compiler, see
=== 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.

인용 양식

Stephen Becker (2024). LBFGSB (L-BFGS-B) mex wrapper (, GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2010a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
Help CenterMATLAB Answers에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보

See release notes for this release on GitHub:

Link to alternative implementation

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

Removed unnecessary zip file from the package

adding compile_mex_forWindows.m

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.

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.