Skip to content

sseemayer/PyLBFGS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pylbfgs

A simple Python binding for libLBFGS.

import pylbfgs
import numpy as np

def evaluate(instance, x, n, step):

    # sphere function
    fx = np.sum(x * x)
    g = 2 * x

    return fx, g

x = np.random.normal(size=(10,))

print("BEFORE: " + str(x))

param = pylbfgs.default_params()
param.epsilon = 1e-30
param.past = 3

code, fx, x = pylbfgs.lbfgs(x, evaluate)

print("Optimization exited with code {code} and function value {fx:.5f}".format(code=code, fx=fx))

print("AFTER: " + str(x))

Installation

No setup.py yet, but you can simply add the pylbfgs directory into your project after compiling libLBFGS:

  1. clone this repo and cd into it
  2. git submodule init && git submodule update
  3. cd pylbfgs/liblbfgs
  4. ./autogen.sh && ./configure.sh && make

License

MIT

About

NumPy/Ctypes Python bindings for libLBFGS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages