Skip to content

C++ implementation of the SQP algorithm SOLNP, utilizing Lagrangian Relaxation to handle both Inequality and Equality constraint functions. Good for solving constrained objective functions on convex surfaces.

License

Notifications You must be signed in to change notification settings

KristerSJakobsson/solnp

Repository files navigation

codecov Documentation Status

See full documentation on http://solnp.readthedocs.io.

Python/C++ SOLNP

This is a C++ implementation of the SOLNP algorithm by Yinyu Ye (1989) with Python Wrappers. The algorithm was originally implemented in Matlab, and have gained some fame through it's R implementation (RSOLNP). Various implementations of the algorithm exists already, however, this version utilizes the power of DLIB and C++11.

This algorithm solves the general nonlinear optimization problem on the form:

    minimize f(x)
      subject to
       g(x) = 0
   l_h <= h(x) <= u_h
   l_x <   x   < u_X

where f(x), g(x) and h(x) are smooth functions.

Getting Started in Python

Simply install the package: pip install pysolnp
See the /python_examples folder for examples.

Getting Started in C++

The files are header-only and only rely on dlib. Import solnp.hpp and call the solnp function.
See the /test folder for examples.

Prerequisites

The sources for all prerequisites are linked using github submodules. To compile the tests, run the CMake script.

Prerequisites for running the C++ SOLNP tests are:

  • dlib - A C++ mathematical library
  • catch2 (for tests) - A testing library

Additionally, when building the Python wheels you need:

  • pybind11 - Bindings for C++ to Python

Running the tests

Run the tests in the solnp_test and export the results to xml by running below in the solnp root folder:

$ cmake .
$ make solnp_tests
$ ./solnp_tests -r junit > solnp_tests_result.xml
$ make utils_tests
$ ./utils_tests -r junit > utils_tests_result.xml

CI and building Wheels

This project uses CI to automatically build wheels for a wide range of distributions. Notably currently only builds for CPython are available on PyPi, but one can also manually installing the package from source as explained above. Apple Silicon (M1 etc) compiling is not currently available on Github Actions.

Github Actions:

  • Windows with Visual Studio
  • Mac OS with Clang
  • manylinux2014 Docker with GCC
  • CodeCov

ReadTheDocs CI:

  • Building and hosting the docs

Built With

Libraries:

  • dlib - C++ math library
  • pybind11 - Bindings for building Python Wheels with C++11
  • manylinux - Docker images for building Linux wheels
  • cibuildwheels - Library for building Python Wheels through CI

Tools:

Authors

License

This project is licensed under the Boost License - see the license file for details

Acknowledgments

  • Yinyu Ye - Publisher and mastermind behind the original SOLNP algorithm, Original Sources
  • Alexios Ghalanos and Stefan Theussl - The people behind RSOLNP, Github repository
  • Davis King - The mastermind behind Dlib, check out his blog! Blog

About

C++ implementation of the SQP algorithm SOLNP, utilizing Lagrangian Relaxation to handle both Inequality and Equality constraint functions. Good for solving constrained objective functions on convex surfaces.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published