All Projects → ssloy → stlbfgs

ssloy / stlbfgs

Licence: AGPL-3.0 license
C++ L-BFGS implementation using plain STL

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to stlbfgs

Logician
Logic programming in Swift
Stars: ✭ 182 (+766.67%)
Mutual labels:  solver
SkytilsMod
A Hypixel Skyblock Utilities mod
Stars: ✭ 236 (+1023.81%)
Mutual labels:  solver
dae-cpp
A simple but powerful C++ DAE (Differential Algebraic Equation) solver
Stars: ✭ 33 (+57.14%)
Mutual labels:  solver
Sundials
SUNDIALS is a SUite of Nonlinear and DIfferential/ALgebraic equation Solvers. This is a mirror of current releases, and development will move here eventually. Pull requests are welcome for bug fixes and minor changes.
Stars: ✭ 194 (+823.81%)
Mutual labels:  solver
mSAT
A modular sat/smt solver with proof output.
Stars: ✭ 91 (+333.33%)
Mutual labels:  solver
MinifyAll
A 𝗩𝗦𝗖𝗼𝗱𝗲 𝗺𝗶𝗻𝗶𝗳𝗶𝗲𝗿 for JS, JSON/C, CSS, and HTML, you will love its simplicity! 🌟 𝘾𝙤𝙢𝙥𝙧𝙚𝙨𝙨 and 𝙜𝙯𝙞𝙥 files and folders 📦 Reduce your bundle and file sizes with lightning speed ⚡
Stars: ✭ 54 (+157.14%)
Mutual labels:  minimization
Qpsolvers
Quadratic Programming solvers in Python with a unified API
Stars: ✭ 157 (+647.62%)
Mutual labels:  solver
optaplanner-quickstarts
OptaPlanner quick starts for AI optimization: many use cases shown in many different technologies.
Stars: ✭ 226 (+976.19%)
Mutual labels:  solver
libdnf
Package management library.
Stars: ✭ 157 (+647.62%)
Mutual labels:  solver
flipy
A Python linear programming interface library
Stars: ✭ 23 (+9.52%)
Mutual labels:  solver
Cubejs
cube.js -- JavaScript library for modeling and solving the 3x3x3 Rubik's Cube
Stars: ✭ 215 (+923.81%)
Mutual labels:  solver
WarpPI
WarpPI Calculator, Step-by-step algebra calculator for Raspberry Pi. (abandoned project)
Stars: ✭ 93 (+342.86%)
Mutual labels:  solver
glpk.js
GLPK for browser & node
Stars: ✭ 72 (+242.86%)
Mutual labels:  solver
Optaplanner
AI constraint solver in Java to optimize the vehicle routing problem, employee rostering, task assignment, maintenance scheduling, conference scheduling and other planning problems.
Stars: ✭ 2,454 (+11585.71%)
Mutual labels:  solver
blt
Lattice-based integer linear programming solver
Stars: ✭ 60 (+185.71%)
Mutual labels:  solver
Pyro2
A framework for hydrodynamics explorations and prototyping
Stars: ✭ 181 (+761.9%)
Mutual labels:  solver
sudokufx
AR Sudoku grabber and solver using JavaCV, JavaFX and Scala
Stars: ✭ 64 (+204.76%)
Mutual labels:  solver
Hodoku
Hodoku is a solver/generator/trainer/analyzer for standard sudoku.
Stars: ✭ 49 (+133.33%)
Mutual labels:  solver
odex-js
Bulirsch-Stoer integration of systems of ordinary differential equations in JavaScript
Stars: ✭ 52 (+147.62%)
Mutual labels:  solver
PyMiniSolvers
A Python API for the MiniSat and MiniCard constraint solvers.
Stars: ✭ 18 (-14.29%)
Mutual labels:  solver

C++ L-BFGS implementation using plain STL

Build Nightly

L-BFGS is a quasi-Newton optimization algorithm for solving large nonlinear optimization problems [1,2]. It employs function value and gradient information to search for the local optimum. It uses (as the name suggests) the BGFS (Broyden-Goldfarb-Fletcher-Shanno) algorithm to approximate the inverse Hessian matrix. The size of the memory available to store the approximation of the inverse Hessian is limited (hence L- in the name): in fact, we do not need to store the approximated matrix directly, but rather we need to be able to multiply it by a vector (most often the gradient), and this can be done efficiently by using the history of past updates.

The project has zero external dependencies, no Eigen, nothing, plain standard library. It is a from-scratch implementation and not a wrapper/translation of the original Fortran/Matlab codes by Jorge Nocedal / Dianne O'Leary.

This implementation uses Moré-Thuente line search algorithm [3]. The preconditioning is performed using the M1QN3 strategy [5,6]. Moré-Thuente line search routine is tested against data [3] (Tables 1-6), and L-BFGS routine is tested on problems taken from [4].

Hello world

Here is a minimal usage example: it shows a minimization of a 2D quadratic function f(x, y) = (x-7)^2 + (y-1)^2, whose minimizer is (x, y) = (7, 1):

#include "stlbfgs.h"

int main() {
    const STLBFGS::Optimizer::func_grad_eval func = [](const std::vector<double> &x, double &f, std::vector<double> &g) {
        f = (x[0] - 7)*(x[0] - 7) +
            (x[1] - 1)*(x[1] - 1);
        g[0] = 2*(x[0] - 7);
        g[1] = 2*(x[1] - 1);
    };

    STLBFGS::Optimizer opt{func};
    std::vector<double> x = {10, 10};
    opt.run(x);

    return std::abs(x[0]-7)>1e-3 || std::abs(x[1]-1)>1e-3;
}

Build and run unit tests:

git clone https://github.com/ssloy/stlbfgs.git &&
cd stlbfgs &&
mkdir build &&
cd build &&
cmake -DSTLBFGS_UNIT_TESTS:BOOL=ON .. &&
cmake --build . -j &&
cd tests &&
ctest

References

[1] J. Nocedal (1980). Updating quasi-Newton matrices with limited storage. Mathematics of Computation, 35/151, 773-782. 3

[2] Dong C. Liu, Jorge Nocedal. On the limited memory BFGS method for large scale optimization. Mathematical Programming (1989).

[3] Jorge J. Moré, David J. Thuente. Line search algorithms with guaranteed sufficient decrease. ACM Transactions on Mathematical Software (1994)

[4] Jorge J. Moré, Burton S. Garbow, Kenneth E. Hillstrom, "Testing Unconstrained Optimization Software", ACM Transactions on Mathematical Software (1981)

[5] Gilbert JC, Lemaréchal C. The module M1QN3. INRIA Rep., version. 2006;3:21.

[6] Gilbert JC, Lemaréchal C. Some numerical experiments with variable-storage quasi-Newton algorithms. Mathematical Programming 45, pp. 407-435, 1989.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].