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.4.dev2.tar.gz (121.1 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.4.dev2-cp312-abi3-win_arm64.whl (512.3 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-win_amd64.whl (542.5 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-manylinux_2_39_x86_64.whl (491.2 kB view details)

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

sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-manylinux_2_39_aarch64.whl (448.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-macosx_14_0_universal2.whl (914.4 kB view details)

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

File details

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev2.tar.gz
Algorithm Hash digest
SHA256 265401951b52a97f4b57302d1876c58128bf7962c79189384b45569ad2f3ce91
MD5 1169ab6d9afc59d04e294689f36d2f55
BLAKE2b-256 4af0706622392817540b42e230b52de6fb7e2e6224705b1e26583ede726303cc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 4d83c81aa37f19927f9f164a9059677ec89c13d1f444b2b8c68add1035e903f9
MD5 c6e5dcffbf2078438539dbf462e19754
BLAKE2b-256 f9b475339cf8bfb5df75c3d8cd9a46108386e2dd05c25cb7d2c7c01ead55ee89

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c7409a9af9626d1550858b0cdb6bb44a56ddebf09b2c3121b7174ae8b2ba2188
MD5 925c648f8b818684329b972a4119230a
BLAKE2b-256 a83bbf1a8435bcfe632f76c36ce196e68dbca6fb6c66d983201299fd70bdfe49

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 955075feb7a685a8a810cd2111e9cb5ad8c2562123f950bcd13290f9ef8e68ea
MD5 cfb74d41509e4fbd8b3ffe35038c28de
BLAKE2b-256 70a57a8f45802496ba01e5d56892383e38c68fe6035d3cca6acc02b27336938f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 207fe09eab0e83894f38b9475d7e8f8df2ad19b82490dd543f3930279c9cd635
MD5 9f35dbef315bca7eca5e930e38906677
BLAKE2b-256 27e6c0f54dd25dfe29e1395c5c4ce79b1dbaaa675a55e816141d30c8116df148

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev2-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 7638bb1c0a247a83c3a1a08baa55703cc033a842422bfb3e5066953598d3a157
MD5 34b7d43641f3da7f9c09fb09e61b652e
BLAKE2b-256 ccb3c95b4e7a5fb85b4eead34fc043aa30d2258ffbc940f2794de46ed736e4e3

See more details on using hashes here.

Provenance

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