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.0.tar.gz (125.7 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.0-cp312-abi3-win_arm64.whl (521.7 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.0-cp312-abi3-win_amd64.whl (551.6 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.0-cp312-abi3-manylinux_2_39_x86_64.whl (499.1 kB view details)

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

sleipnirgroup_jormungandr-0.6.0-cp312-abi3-manylinux_2_39_aarch64.whl (455.6 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.6.0-cp312-abi3-macosx_14_0_universal2.whl (929.4 kB view details)

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

File details

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.0.tar.gz
Algorithm Hash digest
SHA256 cd9e15c37324da9e6587416fc4be77f6696ac01952bea3ba8c249b7247615b6d
MD5 22519323e87d720f26d92eb319584e38
BLAKE2b-256 f4168c3b7248e227cfd026d2d2caa8c28c3ee34eac696ee5530128abcfbf5cae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.0-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 e9efdd7c21738eeb7b6b22f40867d2e48cfb61fe6cfa3e7fb06f0377e3e4e53b
MD5 c035e34099df0e861cd5784178b5e8a8
BLAKE2b-256 8b31ebe23d884139909f36bae10008e7c21a56fa47cb74d025dbd5b3d6800943

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5c6882442d66f6f0eddfa958c95773ab5665cbb05cbd8f8c06d01710d432e0fe
MD5 63c81d91aba51b1263399848275d076c
BLAKE2b-256 43d8256b641ade8591d1b75c0a7a7837f2f1f6e1323972dcb691797e97f120d9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.0-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 24fbe29b6baa3d18bcb2b54f89669e1ac3aa8a340b5143e41ff2b4f92d101e77
MD5 4f8d561951a5c167253d430e438f940d
BLAKE2b-256 105bc2de12af87aad44aac2aa71cabf4362c627288dbc0016e5ac91f1672e745

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.0-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 23ad9132da0dad692e4749cbe3078bc104a06dc3583618fa71742919f1b010c6
MD5 87c40bfe657b1b722415c832bb970847
BLAKE2b-256 a4832799b89f7e50bdefb8253b9c6c1cb79229e98f3c5894568864c2250061d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.0-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 aecf4ee80d16f9e130c406b102e1f6b49c73bdf9ac4f67337419f906ace3ec1f
MD5 080636852398e85f85e84b915011fde1
BLAKE2b-256 b531980cf890a16eec5fee280a40fe911fd7754968d63efb0c4ba0dd25946e67

See more details on using hashes here.

Provenance

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