libLBFGS: a library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS)
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Code
Latest commit
The default line search for `liblbfgs` is specified by [1]. Its implementation had a bug when searching for the minimum of a cubic interpolant used to identify the next trial point during the line search. This patch fixes the bug. In #28, user @jonasson2 identified a bug in the `CUBIC_MINIMIZER2` macro, which finds the minimum of the cubic interpolant used for trial step size selection. To be honest, @jonasson2 did most of the hard work here, even providing a test case, I'm just writing up my understanding and submitting the PR so the bug is fixed. `CUBIC_MINIMIZER2` minimizes the cubic fit in case 3 of [1]. We can see similar logic in the `MCSTEP` routine of Nocedal's original [code](http://users.iems.northwestern.edu/~nocedal/lbfgs.html). ``` C C THE CASE GAMMA = 0 ONLY ARISES IF THE CUBIC DOES NOT TEND C TO INFINITY IN THE DIRECTION OF THE STEP. C GAMMA = S*SQRT(MAX(0.0D0,(THETA/S)**2 - (DX/S)*(DP/S))) IF (STP .GT. STX) GAMMA = -GAMMA P = (GAMMA - DP) + THETA Q = (GAMMA + (DX - DP)) + GAMMA R = P/Q IF (R .LT. 0.0 .AND. GAMMA .NE. 0.0) THEN STPC = STP + R*(STX - STP) ELSE IF (STP .GT. STX) THEN STPC = STPMAX ELSE STPC = STPMIN END IF ``` Above, the Fortran condition `STP .GT. STX` is equivalent to `d > 0` in C as `STP, STX` correspond to `v, u`. [1] Jorge J. More and David J. Thuente. Line search algorithm with guaranteed sufficient decrease. ACM Transactions on Mathematical Software (TOMS), Vol 20, No 3, pp. 286-307, 1994. At the previous commit 7fc7876 it is possible to trigger faulty behavior by simply adding a `params.gtol = 0.1` to the sample Rosenbrock optimization function. The patch at the end of this message below does so. On my machine, this results in a failed optimization, ending as follows: ``` Iteration 7: fx = 95.209157, x[0] = -0.287044, x[1] = 0.032625 xnorm = 2.042774, gnorm = 91.591482, step = 1.355833 L-BFGS optimization terminated with status code = -1001 fx = 69.604508, x[0] = -0.287044, x[1] = 0.032625 ``` After my change, optimization terminates successfully, showing ``` Iteration 23: fx = 0.000000, x[0] = 1.000000, x[1] = 1.000000 xnorm = 10.000003, gnorm = 0.000078, step = 1.000000 L-BFGS optimization terminated with status code = 0 fx = 0.000000, x[0] = 1.000000, x[1] = 1.000000 ``` Testing out a couple of other settings, including default, results in normal optimization results. ``` diff --git a/sample/sample.c b/sample/sample.c index 90e36cd..512bc7b 100644 --- a/sample/sample.c +++ b/sample/sample.c @@ -70,6 +70,7 @@ int main(int argc, char *argv[]) Start the L-BFGS optimization; this will invoke the callback functions evaluate() and progress() when necessary. */ + param.gtol = 0.1; ret = lbfgs(N, x, &fx, evaluate, progress, NULL, ¶m); /* Report the result. */ ```
05bdaad
Git stats
Files
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
libLBFGS: C library of limited-memory BFGS (L-BFGS)
Copyright (c) 1990, Jorge Nocedal
Copyright (c) 2007-2010, Naoaki Okazaki
=========================================================================
1. Introduction
=========================================================================
libLBFGS is a C port of the implementation of Limited-memory
Broyden-Fletcher-Goldfarb-Shanno (L-BFGS) method written by Jorge Nocedal.
The original FORTRAN source code is available at:
http://www.ece.northwestern.edu/~nocedal/lbfgs.html
The L-BFGS method solves the unconstrainted minimization problem:
minimize F(x), x = (x1, x2, ..., xN),
only if the objective function F(x) and its gradient G(x) are computable.
Refer to the libLBFGS web site for more information.
http://www.chokkan.org/software/liblbfgs/
=========================================================================
2. How to build
=========================================================================
[Microsoft Visual Studio 2008]
Open the solution file "lbfgs.sln" and build it.
[GCC]
On top of a compiler and GNU Make, you will also need to install libtool
and automake to build.
On Debian distributions, this can be installed with:
sudo apt install libtool automake
$ ./autogen.sh
$ ./configure
$ make
$ make install # To install libLBFGS library and header.
=========================================================================
3. Note on SSE/SSE2 optimization
=========================================================================
This library has SSE/SSE2 optimization routines for vector arithmetic
operations on Intel/AMD processors. The SSE2 routine is for 64 bit double
values, and the SSE routine is for 32 bit float values. Since the default
parameters in libLBFGS are tuned for double precision values, it may need
to modify these parameters to use the SSE optimization routines.
To use the SSE2 optimization routine, specify --enable-sse2 option to the
configure script.
$ ./configure --enable-sse2
To build libLBFGS with SSE2 optimization enabled on Microsoft Visual
Studio 2005, define USE_SSE and __SSE2__ symbols.
Make sure to run libLBFGS on processors where SSE2 instrunctions are
available. The library does not check the existence of SSE2 instructions.
To package maintainers,
Please do not enable SSE/SSE2 optimization routine. The library built
with SSE/SSE2 optimization will crash without any notice when necessary
SSE/SSE2 instructions are unavailable on CPUs.
=========================================================================
4. License
=========================================================================
libLBFGS is distributed under the term of the MIT license.
Please refer to COPYING file in the distribution.
$Id$
About
libLBFGS: a library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS)
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published