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 python

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.5.dev12.tar.gz (127.9 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.5.dev12-cp312-abi3-win_arm64.whl (515.0 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-win_amd64.whl (554.9 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-manylinux_2_39_x86_64.whl (515.8 kB view details)

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

sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-manylinux_2_39_aarch64.whl (471.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-macosx_14_0_universal2.whl (964.4 kB view details)

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

File details

Details for the file sleipnirgroup_jormungandr-0.6.5.dev12.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev12.tar.gz
Algorithm Hash digest
SHA256 9bf16fe47bcbd8399f58b3f09285872a29c31e0d7d0e2cfe07d53aab060b242b
MD5 9dbfe9a506eadbb2ba97631097cbea96
BLAKE2b-256 d327fcffc9660c5e13c5ffa54dcbc0c69b788c17ee382f6da814055c01f636a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.5.dev12.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.5.dev12-cp312-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 46f5a8c3865c517b68e13e01b9b2a6dd10374c277c13ba1c8a26110db39330ca
MD5 a923ebf3aa0bf21fa7f88081d392090f
BLAKE2b-256 d29abf288623f64b2a33ec824f25af6f28343bbd028cc9c172e8837d01437231

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.5.dev12-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.5.dev12-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 58e66eb0b88ec99b80fdece2db02b2f62e0e8bc82fd032c1904f79efa910b2e6
MD5 ed475187ad1d96f8b0c6154f308aee34
BLAKE2b-256 4ef05025b801349094253a4c9dcb7199659838d894d2b08290234ef44eeb4cba

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.5.dev12-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.5.dev12-cp312-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 b5adb961e24bdf9c2c393a1bdd8c422281beb842d53399c189f6c1669f577cde
MD5 74a4c257696511cbb8a556a7e9631039
BLAKE2b-256 fbb60559aa3ada1bca9482ec76219a7bd3032fdfda91651bd6c56395e570a156

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.5.dev12-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.5.dev12-cp312-abi3-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 3481c18dcbc5737ad8721ebeec0dd12712d0690e7a7e0080a168c642c83ae562
MD5 c7773db638e877f24b36bfc79786b0b7
BLAKE2b-256 1107961f49889fc481fbe35179d735a56b2d6f688eda0e07af001f64c52e0570

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.5.dev12-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.5.dev12-cp312-abi3-macosx_14_0_universal2.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev12-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 6769b6ab5fafc93c568a814fa5b46d3308032e235e204e41e929c0d9a972cc8f
MD5 8c7694d2efaff962836faba0efa41573
BLAKE2b-256 7204e611e1e55a4b1bf399ab3e802e81246a2866e4eed503300956971c2366c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.5.dev12-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