Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lostella/liblbfgs
implemention of the L-BFGS method for smooth unconstrained optimization
https://github.com/lostella/liblbfgs
Last synced: about 1 month ago
JSON representation
implemention of the L-BFGS method for smooth unconstrained optimization
- Host: GitHub
- URL: https://github.com/lostella/liblbfgs
- Owner: lostella
- Created: 2015-07-27T17:02:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-09T14:03:34.000Z (over 7 years ago)
- Last Synced: 2024-10-13T22:33:47.892Z (2 months ago)
- Language: C
- Homepage:
- Size: 31.3 KB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libLBFGS
[![Build Status](https://travis-ci.org/lostella/libLBFGS.svg)](https://travis-ci.org/lostella/libLBFGS)
`libLBFGS` is a small piece of C code computing
limited-memory BFGS (also known as L-BFGS) directions for minimizing smooth functions. Contains a MATLAB interface [briefly documented here](#matlab-interface).The library implements the necessary functions to allocate a FIFO buffer for some pairs of vectors to be stored;
to cyclically push and pull pairs `(s, y)` of vectors into the buffer;
to compute matrix vector products with the resulting approximate inverse Hessian matrix.For more information about the L-BFGS method, see:
* J. Nocedal, "Updating quasi-Newton matrices with limited storage," in *Mathematics of Computation*, vol. 35, issue 151, pp. 773-782 (1980). [Available here](http://www.ams.org/journals/mcom/1980-35-151/S0025-5718-1980-0572855-7/)
* D. Liu, J. Nocedal, "On the limited memory BFGS method for large scale optimization," in *Mathematical Programming*, vol. 45, pp. 503-528 (1989). [Available here](http://link.springer.com/article/10.1007%2FBF01589116)## MATLAB interface
To setup `libLBFGS` for MATLAB, navigate to `libLBFGS/matlab` from your MATLAB command line and
```matlab
>> setup_libLBFGS
>> test_libLBFGS
```Now you can use `libLBFGS`. The easiest way is through the `LBFGS` class:
```matlab
H = LBFGS(n, mem); % create an operator of dimension n and memory mem
H.push(s, y); % push a pair (s, y) into the buffer and update the operator
d = -(H*grad); % multiply H by (minus) grad, to obtain a search direction
```## C interface (Linux/Unix/MacOS X)
To compile the library simply navigate to its directory and type `make`.
This will produce `libLBFGS.o`, that you will need to statically link to your project.
The following routines are exported in `libLBFGS.h`:* `libLBFGS_buffer * libLBFGS_init (int n, int mem);`
Initialize a libLBFGS_buffer structure.* Parameters
`int n`: dimension of the vectors to handle
`int mem`: memory of the buffer
* Return value
`libLBFGS_buffer * b`: pointer to the buffer structure
* `int libLBFGS_push (libLBFGS_buffer * b, double * s, double * y);`
Pushes a new pair (s, y) into the buffer, and discards the oldest one if necessary.* Parameters
`libLBFGS_buffer * b`: pointer to the buffer structure
`double * s`: double vector of length n, containing the difference between to points x and x'
`double * y`: double vector of length n, containing the difference between the two gradients at x and x'
* Return value
`int status`: some integer status code
* `void libLBFGS_matvec (libLBFGS_buffer * b, double H0, double * g, double * d);`
Performs a MATVEC operation between the inverse Hessian approximation stored so far and a given vector.
* Parameters
`libLBFGS_buffer * b`: pointer to the buffer structure
`double H0`: value of the diagonal initial Hessian approximation to use; can be any positive value, a good choice for this is suggested in Nocedal, Wright, "Numerical Optimization", eq. (7.20)
`double * g`: double vector of length n, containing the vector to multiply with the inverse Hessian approximation
`double * d`: double vector of length n, where to store the result of the matrix-vector product
* `void libLBFGS_reset (libLBFGS_buffer * b);`
Resets the memory of the given buffer structure.
* Parameters
`libLBFGS_buffer * b`: pointer to the buffer structure
* `void libLBFGS_clear (libLBFGS_buffer * b);`
Deallocates the given buffer structure: all the referenced memory locations will be cleared, including the buffer itself, and the pointer will no longer be usable.
* Parameters
`libLBFGS_buffer * b`: pointer to the buffer structure