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 python

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.5.dev10.tar.gz (127.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.6.5.dev10-cp312-abi3-win_arm64.whl (515.0 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-win_amd64.whl (554.9 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-manylinux_2_39_x86_64.whl (515.8 kB view details)

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

sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-manylinux_2_39_aarch64.whl (471.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-macosx_14_0_universal2.whl (964.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.5.dev10.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev10.tar.gz
Algorithm Hash digest
SHA256 718b962e9e81f6cbce43a860f3a88cd52939e495ff027f57ceeb6e58797ef7ee
MD5 a1a63e7035acb6659f2d68aeb8ca021c
BLAKE2b-256 1cb4e692db2485fc46a53689de0c739800db13751e4156e93e55794577f62e75

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 72010fa1219070264404020e66ddbf2c6aeb13cd69380b51654de0a839381193
MD5 1f3d0df01c3eb12c30f7d7a5caed7a3c
BLAKE2b-256 b8038102d9035fda4f786549d195318cb140fa03def5ebc6a462ad4e0787d412

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 796c652fca147306c4b3e7399ae460ccdc6e01b4d0cf29de645de77d6620721b
MD5 eeabfc751a7ccbf6fe8b297492d0ce75
BLAKE2b-256 8543c1eac6f7fa9c61113a08af71f2c8053751399e481fa1ecf9a6230db8bb4b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 af3fc11724b5190d8a240ab789e42bb17a53ff5867b0a9bf9383f91e39cda4de
MD5 7296a4ac585cd360d5f8c6799c56f8a1
BLAKE2b-256 fe05d31a73924a672fb8b3e78e2bf8d7680aca463e71e9cf44943aa5c9188919

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 e2943947fc6dcbd5f0e9ba6f6b1212b15d0d50617b1402800f36d7234b0353a5
MD5 81385a9288552d65081f1fa301bb2d4e
BLAKE2b-256 ff5f878819bd1125c7a0409882594e5b8f266423cb2637a5b7d57800258cc2ef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev10-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 e3714cb1ab2b3d0b868d50176257a2d075bbc666a20f5636403161a5b70ae8e7
MD5 83cc176f548a7e88477e171ab51047a4
BLAKE2b-256 60a2b6b6eee11d7e732e10e628c2cf787111c62c5b4176b4aa9ad3d3f945620e

See more details on using hashes here.

Provenance

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