Name | Last modified | Size | Description | |
---|---|---|---|---|

Parent Directory | - | |||

Makefile | 2019-03-23 09:59 | 2.2K | ||

README.html | 2019-03-23 09:59 | 18K | ||

array.h | 2019-03-23 09:59 | 4.4K | ||

arrayofmatrices.cpp | 2019-03-23 09:59 | 2.4K | ||

arrayofmatrices.h | 2019-03-23 09:59 | 2.1K | ||

lbfgsb.cpp | 2019-03-23 09:59 | 4.0K | ||

license.txt | 2019-03-23 09:59 | 1.5K | ||

matlabexception.cpp | 2019-03-23 09:59 | 512 | ||

matlabexception.h | 2019-03-23 09:59 | 869 | ||

matlabmatrix.cpp | 2019-03-23 09:59 | 1.6K | ||

matlabmatrix.h | 2019-03-23 09:59 | 2.4K | ||

matlabprogram.cpp | 2019-03-23 09:59 | 7.3K | ||

matlabprogram.h | 2019-03-23 09:59 | 2.8K | ||

matlabscalar.cpp | 2019-03-23 09:59 | 1.0K | ||

matlabscalar.h | 2019-03-23 09:59 | 1.2K | ||

matlabstring.cpp | 2019-03-23 09:59 | 1.0K | ||

matlabstring.h | 2019-03-23 09:59 | 1.1K | ||

program.cpp | 2019-03-23 09:59 | 3.9K | ||

program.h | 2019-03-23 09:59 | 4.9K | ||

solver.f | 2019-03-23 09:59 | 138K | ||

## A MATLAB interface for L-BFGS-Bby Peter CarbonettoDept. of Computer Science University of British Columbia L-BFGS-B is a collection of Fortran 77 routines for solving
large-scale nonlinear optimization problems with bound constraints on
the variables. One of the key features of the nonlinear solver is that
knowledge of the Hessian is not required; the solver computes search
directions by keeping track of a quadratic model of the objective
function with a limited-memory BFGS (Broyden-Fletcher-Goldfarb-Shanno)
approximation to the Hessian. I've designed an interface to the L-BFGS-B solver so that it can be
called like any other function in MATLAB. If you have any questions, praise, or comments, or would like to report a bug, do not hesitate to contact the author. I've tested this software in MATLAB version 7.2 on both the Mac OS X and Linux operating systems.
## InstallationThese installation instructions assume you have a UNIX-based operating system, such as Mac OS X or Linux. It is surely possible to install this software on Windows, I'm just not sure how. These instructions also assume you have GNU make installed.
What we will do is create a MEX file, which is basically a file that contains a routine that can be called from MATLAB as if it were a built-it function. To learn about MEX files, I refer you to this document at the MathWorks website.
On my laptop running Mac OS X 10.3.9 with MATLAB 7.2, my settings for the Makefile are
On my Linux machine, I set the variables in the Makefile like so:
It may be helpful to look at the GCC documentation in order to understand what these various compiler flags mean.
## A brief tutorialI've written a short script The basic MATLAB function call is
The first input argument The script The script starts by generating a bunch of canonical images that
represent topics; if a pixel is white then a word at that position is
more likely to appear in that topic. Note that the order of the pixels
in the image is unimportant, since LDA is a "bag of words"
model. In another figure we show a small sample of the data generated
from the topics. Each image represents a document, and the pixels in
the image depict the word proportions in that document. Next, the script runs the L-BFGS-B solver to find a local minimum
to the variational objective. Buried in the M-file
This example will give us the opportunity to demonstrate some of
the more complicated aspects of the our MATLAB interface. The first
input to It is instructive to examine the callback routines. They look like:
Notice that each entry to the cell array is its own input argument to the callback routines. The same applies for the output arguments of the gradient callback function. The sixth input argument is a cell array that contains auxiliary data. This data will be passed to the MATLAB functions that evaluate the objective and gradient. The seventh input argument specifies a callback routine that is called exactly once for every iteration. This callback routine is most useful for examining the progress of the solver. The remaining input arguments are label/value pairs that override some of the default settings of L-BFGS-B. After converging to a solution, we display topic samples drawn from the variational approximation. A good solution should come close to recovering the true topics from which the data was generated (although they might not be in the same order). Don't be surprised if it takes many iterations before the optimization algorithm converges on a local minimum. (In repeated trials, I found it as many as two thousand iterations to converge to a stationary point of the objective.) This particular problem demonstrates the limitations of limited-memory quasi-Newton approximations to the Hessian; the low storage requirements can come at the cost of slow convergence to the solution. ## The C++ interfaceOne of the nice byproducts of writing a MATLAB interface for
L-BFGS-B is that I've ended up with a neat little C++ class that
encapsulates the nuts and bolts of executing the solver. A brief
description of the Program class can be found in the header file
Program is an abstract class, which means that its impossible to
instantiate a Program object. This is because the class has member
functions that aren't yet implemented. These are called pure virtual
functions. In order to use the Program class, one needs to define
another class that inherits the Program class and that implements the
pure virtual functions. In fact, the class MatlabProgram (in
The new child class must declare and implement these two functions:
See the header file for a detailed description of these functions. The only remaining detail is calling the Program constructor. After that, it is just a matter of declaring a new object of type MyProgram then calling the function runSolver. ## Contents of the tar archive
## Footnotes
| |

March 3, 2007 |