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.1.dev1.tar.gz (126.6 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.1.dev1-cp312-abi3-win_arm64.whl (522.1 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.1.dev1-cp312-abi3-win_amd64.whl (552.8 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.1.dev1-cp312-abi3-manylinux_2_39_x86_64.whl (501.4 kB view details)

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

sleipnirgroup_jormungandr-0.6.1.dev1-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.1.dev1-cp312-abi3-macosx_14_0_universal2.whl (930.9 kB view details)

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

File details

Details for the file sleipnirgroup_jormungandr-0.6.1.dev1.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev1.tar.gz
Algorithm Hash digest
SHA256 39839f454cc1c380b4515647a10434cd0cc9aa0108487c8a6a820dfb119b743a
MD5 99b837f82bf2e35e460df5d61464ddda
BLAKE2b-256 2762cb290e23737047c6d7af1f6ee32ce1002d819338d5942ee79f2ef332468b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.1.dev1.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.1.dev1-cp312-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev1-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 cd3bb9e8a688b3443d8f52bc4ccf27f72844c8807000b8ae70a4033a3011a1cf
MD5 ef1133440b7e04e0cc0365ca74791771
BLAKE2b-256 5193ec78894b9174741051b108559c9acaf01e7b4a2f8fa23bc103e95dd80f8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.1.dev1-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.1.dev1-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1396fb2064bf7ea225844d256909bd921edfa7a5a6f440f5e018189a9d7742d4
MD5 551410eeca1ae5340a308f58ad30352d
BLAKE2b-256 ec83f96e83efe4c43d67ab19fe7bbb6ef3707eef2cc9c39a3da38a49b8f5364d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.1.dev1-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.1.dev1-cp312-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev1-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 89c1e87dfc9a1890e68512a3d714d2530f06979bb7b162b5c362817199024390
MD5 b6b7941260a3693621adcc336cf713e6
BLAKE2b-256 ffe669a8eed8906600af61d0e46afdc799b86998b19798dbab0fecc624fe4d58

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.1.dev1-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.1.dev1-cp312-abi3-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev1-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 bd354c6cf288ca94bee7e95989cef0d41c130768a28e3f8da5eab66295398dfc
MD5 256ef24050e8d7cd096831b7614a9352
BLAKE2b-256 f7da6b4e95ea14e33110582d8a641bc065aa33d9a8a8ef0b6c703cffc1410a45

See more details on using hashes here.

Provenance

The following attestation bundles were made for sleipnirgroup_jormungandr-0.6.1.dev1-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.1.dev1-cp312-abi3-macosx_14_0_universal2.whl.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev1-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 c2cd98ff23de08a05241d88559fbdb7b97ba9866ec776dba75017c0800d4b0af
MD5 eea0fd84a44906d350745b2b5d34fea0
BLAKE2b-256 bf337af2121858295da3f8262dbdf809cb9814d074cafdd09fd498a48a5e16ca

See more details on using hashes here.

Provenance

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