Skip to content
/ lbfgs-d Public

A native D implementation of Limited Memory Broyden–Fletcher–Goldfarb–Shanno optimizer

License

Notifications You must be signed in to change notification settings

AdRoll/lbfgs-d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

LBFGS-D

LBFGS-D provides a native implementation of the Limited-Memory Broyden–Fletcher–Goldfarb–Shanno algorithm (L-BFGS) in the D programming language.

The implementation is meant to be as simple and readable as possible, as a single self-contained file module.

It doesn't rely on any third-party dependency and follows closely Nocedal & Wright's algorithm description provided in Numerical Optimization (2 ed. Springer, 2006) book. It is particularly well suited for cases where the function & gradient evaluations are relatively expensive compared to the actual quasi-Newton variables updates.

The API requires you to specify a:

void delegate(const float[] x, ref float[] resGrad, out float resFunc)

which computes at point x the value resFunc of the function to minimize, as well as its gradient resGrad at point x.

import LBFGS : LBFGS;
auto d = 30; // 30 dimensions
auto m = 5; // rank of inv-Hessian approximation
void my_function(const float[] x, ref float[] res_grad, out float res_func)
{
  ...
}
auto solution = new float[d];
solution[] = 0; // specify your starting point here
float min_val;
auto lbfgs = new LBFGS(d, &my_function, m); // will allocate memory
lbfgs.solve(solution, min_val); // run optimizer

Additionaly, one can specify a Jacobi preconditioner to be used.

More examples of usage can be found in the module unit-tests:

rdmd -main -unittest LBFGS.d

About

A native D implementation of Limited Memory Broyden–Fletcher–Goldfarb–Shanno optimizer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages