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

Uploaded CPython 3.12+Windows ARM64

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

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.5.1-cp312-abi3-manylinux_2_39_x86_64.whl (490.9 kB view details)

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

sleipnirgroup_jormungandr-0.5.1-cp312-abi3-manylinux_2_39_aarch64.whl (448.1 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.5.1-cp312-abi3-macosx_14_0_universal2.whl (914.2 kB view details)

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

File details

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.1.tar.gz
Algorithm Hash digest
SHA256 2ba5496175be2703398c9d911a4fe85fec92b804124c3f9f8d71fd2bb18b6361
MD5 cb15c8237da1d4d7b08546e9918b3955
BLAKE2b-256 f98618c145716524efa0b8ec4af483d6e3d5f7a6ff4804cd0d234a39a92b2ca0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.1-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 54eb21ef226a3379e432fbb549f3d0a4f13563d0310ce7813c08c509d0099522
MD5 b28c7851570b745de9f05048b63b8bc8
BLAKE2b-256 572327966108fca782a826b7f3144a2f3d688092c6e016ddea2e9d1993d7d2b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5805528970291ba578ff62ca136d61ce45f4d350bd8490e2cef79fd1712a0289
MD5 c02ae3412d7ee553a48472c86e755a24
BLAKE2b-256 432cb02cfb761ffe9e1ca7eaa6af7c07b3d967c31d606de70a2ccbd61c820032

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.1-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 bd226c8e3e81ae64e9dd0aed6ac431c7c2a08088cee68c3e004c73ad9fdd33ce
MD5 304600e31f6554067eb00699a299759e
BLAKE2b-256 d24c2907c49aa70f65be8b18a4ea73e90e48de02278f56620b9460f117ab4641

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.1-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 b66ab19c478e9c9ee7c236b148da29052c718f05f32d4ab2301d2aa7d4729abf
MD5 5fdff78f06013f39502a36f55e5b0b61
BLAKE2b-256 7a2f6235c2d4deae8a99b9c8f412c9ff33df650fd45f5cc2a78cdb5557f3e55d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.1-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 8bf10e8f6b5e0a766c7c1361867973ebc7a109645f9aa4e91821defc74cd5553
MD5 88ee43c502349156274e848206d66d4f
BLAKE2b-256 d37bdcd2e5b785d7103bf753fc025d95acb4df08033010edb0456278668b65f9

See more details on using hashes here.

Provenance

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