Skip to main content

Reverse mode autodiff library and NLP solver DSL

Project description

Sleipnir

C++ Python PyPI Downloads Website C++ API Python API Discord

Sleipnir is a reverse mode autodiff library, interior-point method, and NLP solver DSL for C++23 and Python. The DSL automatically chooses the best solver based on the problem structure.

#include <print>

#include <sleipnir/optimization/problem.hpp>

int main() {
  // Find the x, y pair with the largest product for which x + 3y = 36
  slp::Problem<double> problem;

  auto x = problem.decision_variable();
  auto y = problem.decision_variable();

  problem.maximize(x * y);
  problem.subject_to(x + 3 * y == 36);
  problem.solve();

  // x = 18.0, y = 6.0
  std::println("x = {}, y = {}", x.value(), y.value());
}
#!/usr/bin/env python3

from sleipnir.optimization import Problem


def main():
    # Find the x, y pair with the largest product for which x + 3y = 36
    problem = Problem()

    x, y = problem.decision_variable(2)

    problem.maximize(x * y)
    problem.subject_to(x + 3 * y == 36)
    problem.solve()

    # x = 18.0, y = 6.0
    print(f"x = {x.value()}, y = {y.value()}")


if __name__ == "__main__":
    main()

Sleipnir supports easy cross-compilation via CMake toolchain files, provides good performance by default, and contains clean reference implementations of various solvers with links to explanatory material.

The C++ API also supports arbitrary scalar types, so users can specify higher precision floating-point types at the cost of speed.

Install

The following platforms are supported:

  • Windows
  • Linux
    • OS: Ubuntu 24.04
    • Runtime: GCC 14 libstdc++ (run sudo apt install g++-14)
  • macOS
    • OS: macOS 14.5
    • Runtime: Apple Clang 16.0.0 libc++ from Xcode 16.2 (run xcode-select --install)

To use Sleipnir within a CMake project, add the following to CMakeLists.txt:

include(FetchContent)

FetchContent_Declare(
    Sleipnir
    GIT_REPOSITORY https://github.com/SleipnirGroup/Sleipnir.git
    GIT_TAG main
    EXCLUDE_FROM_ALL
    SYSTEM
)
FetchContent_MakeAvailable(Sleipnir)

target_link_libraries(MyApp PUBLIC Sleipnir::Sleipnir)

To use Sleipnir in Python, install sleipnirgroup-jormungandr from PyPI:

pip install sleipnirgroup-jormungandr

If necessary, follow these instructions to build from source.

Docs

See the C++ API docs, Python API docs, and usage docs.

Examples

See the examples folder, C++ optimization unit tests, and Python optimization unit tests.

Benchmarks

See the benchmarks folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sleipnirgroup_jormungandr-0.6.2.dev2.tar.gz (126.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-win_arm64.whl (522.0 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-win_amd64.whl (552.9 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-manylinux_2_39_x86_64.whl (501.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ x86-64

sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-manylinux_2_39_aarch64.whl (457.6 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-macosx_14_0_universal2.whl (931.5 kB view details)

Uploaded CPython 3.12+macOS 14.0+ universal2 (ARM64, x86-64)

File details

Details for the file sleipnirgroup_jormungandr-0.6.2.dev2.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev2.tar.gz
Algorithm Hash digest
SHA256 f2f92fbd281cd2276b09eb5c6958b35e710842fdf3ee5ea132114858830a6e46
MD5 fb3d13c2a2f734cc8ff77e2632bc8469
BLAKE2b-256 08af2dc35ad653b8521bc16b36ec39bdab3643e98def845985f02ce374e74184

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.2.dev2.tar.gz:

Publisher: python.yml on SleipnirGroup/Sleipnir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 0e3a053fb756a61c47a6eb8b4f799f815f430c12c900208b0e6599ebed261bdf
MD5 580f5ac9b88d9da1cd947e26b5591b98
BLAKE2b-256 db2a270b23d46dba71c8ad498634e568d3e122d11b69f2dcf94dc210b2bb2884

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-win_arm64.whl:

Publisher: python.yml on SleipnirGroup/Sleipnir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 66f927d1444caebe6e9487aef62d03c2db8d97c3da03d870b6cfb85ad208abcb
MD5 55dbdcd35f8059e00f51384bb9a8377a
BLAKE2b-256 29d119f8d387a3188a4b612ff2e4d68d13cf7d66b59ecfdaf25576d1445c3a97

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-win_amd64.whl:

Publisher: python.yml on SleipnirGroup/Sleipnir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 8739e80bbb5f4bc75ac1815fcd73fc7ec0dab4946a52773bfea559aa3fcc5c96
MD5 0ae328e04f68694388ce8105b36b92ae
BLAKE2b-256 def7d7217ec563cb20736870e4e61d6873b303ee7d0d2ae0b48296b9f8c3aa65

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-manylinux_2_39_x86_64.whl:

Publisher: python.yml on SleipnirGroup/Sleipnir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 927427519c05a06746f94de7ac7d3f812af6a1ccfd8626ba4032b8ebe7a0aa8b
MD5 4994006c91bf436b246eee326bbc571e
BLAKE2b-256 dfda172f822c6b6f22523c8ae014eefa21d0f960d2949342929959c0f40c58e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-manylinux_2_39_aarch64.whl:

Publisher: python.yml on SleipnirGroup/Sleipnir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-macosx_14_0_universal2.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 6da6bfed9929c68af388dba1ad46c7267e531cf72db0cc6d899eef664bfce5cf
MD5 4d80408307994d7883e33df1f145fe8a
BLAKE2b-256 3b6f12fc5bf761b8ca4274afb15103e7bb5243e2711c6231154bbbd8531537fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.2.dev2-cp312-abi3-macosx_14_0_universal2.whl:

Publisher: python.yml on SleipnirGroup/Sleipnir

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page