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.2.dev3.tar.gz (126.5 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.2.dev3-cp312-abi3-win_arm64.whl (522.0 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.2.dev3-cp312-abi3-win_amd64.whl (552.9 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.2.dev3-cp312-abi3-manylinux_2_39_x86_64.whl (501.3 kB view details)

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

sleipnirgroup_jormungandr-0.6.2.dev3-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.2.dev3-cp312-abi3-macosx_14_0_universal2.whl (931.5 kB view details)

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

File details

Details for the file sleipnirgroup_jormungandr-0.6.2.dev3.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev3.tar.gz
Algorithm Hash digest
SHA256 c597ed72b0e892fbb88f69f3ad8dd5e5e13c74340bb3dadbeae23bffb141b4bc
MD5 58c525e6feab836bc19fb379d8a1a1de
BLAKE2b-256 9a51cc42660c3f0599618c4cadc4e4b0736fcefb8833d84678d1e3924da82af7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev3-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 5784eb4067e15742993621d7b824fd50f60b7fe49d9d03b1a7e13245492364b7
MD5 9eb2953f030e66d179c22d995e2bb1c2
BLAKE2b-256 f2ff0eb38a252a0c39ee17cb5f72a9decbca60e5a7b6f9540529307e8fc95160

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev3-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 00a1760f4a1e2279cfc2e6568b668aa38bee24613f07f159e5b972262b7fa831
MD5 f5f2ab0fd2b83b2c61ef05cbe3351a86
BLAKE2b-256 150997160b1949b3e59b8c2c41d8807cc337bce9c1577e90bc1e42c5f821e264

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev3-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 5a1fb680bcbe92c9d4ba5d31593d580e3cc2b7baa1593876cd718e789b70d04c
MD5 6cbf7e64f2c368959b18324b372b9681
BLAKE2b-256 9b46236092fb3c93ffa14ad1185dca71ecd573c8d3d9352bf9f15b37c4048c16

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev3-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 5a6b7ddfb2a04757d8d2cd97cc80798a6eab02ca21b9d49636c2b345dce0bde6
MD5 995833f7d9bd7438b69f8c7dbf1659fb
BLAKE2b-256 bf29bac3df04089c8718830c4865abda3e3f20e16dbec462e96784da5c0c0e44

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev3-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 ebf75f96974e6b58382e0c94f24baf58ff77b5ca76ee0e21ec4b5aa7a082e50a
MD5 595c97b3c90f1b09c8714c75c8e2d0f3
BLAKE2b-256 bbfd4a3ace949fc0ebfe3365a3c11dd809e39193bf9c5a8dec7b3c0a09e94a65

See more details on using hashes here.

Provenance

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