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.5.5.tar.gz (121.0 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.5.5-cp312-abi3-win_arm64.whl (512.4 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.5.5-cp312-abi3-win_amd64.whl (542.3 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.5.5-cp312-abi3-manylinux_2_39_x86_64.whl (490.2 kB view details)

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

sleipnirgroup_jormungandr-0.5.5-cp312-abi3-manylinux_2_39_aarch64.whl (447.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.5.5-cp312-abi3-macosx_14_0_universal2.whl (912.6 kB view details)

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

File details

Details for the file sleipnirgroup_jormungandr-0.5.5.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.5.tar.gz
Algorithm Hash digest
SHA256 61986f8f389d9ebc6219ecc7d6643172fb28324b472012d1b64daa4b0e8de78d
MD5 04d3d5cc8d1b1fa654af37f5de8300ec
BLAKE2b-256 1df214e1d897980bb5a3b143d92ef2c1dafe8d12a30ce82ea27651a35bc6d177

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.5-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 91e5705ebe313a2300e58bafe4bd13414f4e8d1d35ba2c0c6df874930b388eaf
MD5 d767348eaa14a3d0e9345ba81d637c3c
BLAKE2b-256 49a27f6bdd7fa8ba5e9d5292abe53fc781d75aa9ee6463d74e2f0c5ed16f342f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.5-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 99992d056f4a99584c1baf0f845ddb19fa311244870e16b959be5c34b9bf44cd
MD5 d6b53d32575033f160f035cc421f3484
BLAKE2b-256 df6dcc93b58cb89df9b80eb43a38f61c649be3597038e8fcfb18fd27d760bdf8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.5-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 8a23fb00d7a3b3b9080b2a20d85cbeff5a54a8219e12ecf110a111a7cb1ef056
MD5 df6779c8af9493e1ffd7b273b00bf0ae
BLAKE2b-256 f26929cf8efd3cf2d4036af24025772de13633b8b484ed785093491f65e88593

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.5-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 b75ab1a0201617eb25fe9b9c6fb4de9dbaa82c399f9b8630a124d0918444c38d
MD5 9d5217366057001cef44a4af6baeafd1
BLAKE2b-256 84a7a9594fcb366af26347c6ee05708ed91a2e845f3b011bfe917996c4bd032c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.5-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 3c7fd5e3021849e7af26878a20fdbe4edfede83c5a779e5c7100971db258fcde
MD5 846f765602b1076b29074f88b0d3889a
BLAKE2b-256 d3e33dee8e6200aa417a699d2349ce013701c27156a7d179ef929fba1d86a49d

See more details on using hashes here.

Provenance

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