A direct Java port of liblbfgs

lbfgs4j is a Java version of liblbfgs, a library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS).

License

License

MIT License
GroupId

GroupId

com.github.vinhkhuc
ArtifactId

ArtifactId

lbfgs4j
Last Version

Last Version

0.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

A direct Java port of liblbfgs
lbfgs4j is a Java version of liblbfgs, a library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS).
Project URL

Project URL

http://maven.apache.org
Source Code Management

Source Code Management

https://github.com/vinhkhuc/lbfgs4j

Download lbfgs4j

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.vinhkhuc/lbfgs4j/ -->
<dependency>
    <groupId>com.github.vinhkhuc</groupId>
    <artifactId>lbfgs4j</artifactId>
    <version>0.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.vinhkhuc/lbfgs4j/
implementation 'com.github.vinhkhuc:lbfgs4j:0.2.1'
// https://jarcasting.com/artifacts/com.github.vinhkhuc/lbfgs4j/
implementation ("com.github.vinhkhuc:lbfgs4j:0.2.1")
'com.github.vinhkhuc:lbfgs4j:jar:0.2.1'
<dependency org="com.github.vinhkhuc" name="lbfgs4j" rev="0.2.1">
  <artifact name="lbfgs4j" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.vinhkhuc', module='lbfgs4j', version='0.2.1')
)
libraryDependencies += "com.github.vinhkhuc" % "lbfgs4j" % "0.2.1"
[com.github.vinhkhuc/lbfgs4j "0.2.1"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

This is a direct Java port of liblbfgs, a library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS).

The L-BFGS optimization method is used to solve unconstrained minimization problem:

                    minimize f(x), where x = (x1, x2, ... xn)
                    f(x) and its gradient are computable.

This library also includes the implementation of the Orthant-Wise Limited-memory Quasi-Newton (OWL-QN) method which is used to minimize the function f(x) + C|x|, where C is a positive number.

Maven dependency

<dependency>
  <groupId>com.github.vinhkhuc</groupId>
  <artifactId>lbfgs4j</artifactId>
  <version>0.2.1</version>
</dependency>

Usage example

Find the minimum value of the function f(x) = (x-5)^2 + 1.

import com.github.lbfgs4j.liblbfgs.Function;
import com.github.lbfgs4j.LbfgsMinimizer;
...

Function f = new Function() {
  public int getDimension() {
    return 1;
  }
  public double valueAt(double[] x) {
    return Math.pow(x[0]-5, 2) + 1;
  }
  public double[] gradientAt(double[] x) {
    return new double[] { 2*(x[0]-5) };
  }
};

LbfgsMinimizer minimizer = new LbfgsMinimizer();
double[] x = minimizer.minimize(f); // x should be [5]
double min = f.valueAt(x);          // min should be 1

The OWL-QN method will be used when initializing the minimizer with, for example, new LbfgsMinimizer(1.0), here 1.0 is the coefficient for |x|.

Other parameters such as memory size, maximum number of iterations, etc. can be set using the class LBFGS_Param.

License

lbfgs4j is released under the MIT License (see the LICENSE file for details).

References

This library is used in several projects:

  1. Moment-Based Quantile Sketches for Efficient High Cardinality Aggregation Queries. Edward Gan, Jialin Ding, Kai Sheng Tai, Vatsal Sharan, Peter Bailis. VLDB 2018. (paper)
  2. Humio, Log Management at Scale. (acknowledgement)

Versions

Version
0.2.1
0.2
0.1