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

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.1.dev2-cp312-abi3-win_amd64.whl (552.8 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.1.dev2-cp312-abi3-manylinux_2_39_x86_64.whl (501.4 kB view details)

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

sleipnirgroup_jormungandr-0.6.1.dev2-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.1.dev2-cp312-abi3-macosx_14_0_universal2.whl (930.9 kB view details)

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

File details

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev2.tar.gz
Algorithm Hash digest
SHA256 3310800ce1f92686bd58f1a3a13396ce24fb2ae23ddea545dfd9e77f13e5b168
MD5 1c61729cd9687f9a8c8595004ab45cd4
BLAKE2b-256 7dcfa17a6a2e9a033521ceb73916cf17e11aff380a619da38c9f785420e33e7f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev2-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 9de176ddded613fa624c3b67dd970c4ccfbb7571a1c76582df9e89038ca4157e
MD5 1716661ef55c046d0dc26531a9f774f7
BLAKE2b-256 4092c240badc24b59305ebd90a38d546b76093422fb2e2a7473ff1ef125635c0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 04ea9f33333c577bb6e1163bf3949d4940de2e1158e4364fd89236a4114baf33
MD5 c3253d444abfc18748d30933eaed93d2
BLAKE2b-256 91b1d6f278cf85b888f74fd6671a82a2b8e408625fc89a4da9cddcb4b2c22fe3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev2-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 5f4751b0982d1e657c6e7f710b6efa7397b2d8e8d21364e6492c0a134a4fe47c
MD5 56d4508613728d3309dd228f15c22340
BLAKE2b-256 e0bd79f36d63ed1391d10b37cceaec68195e41e5f851a2b4a7d28d0f6802a9ff

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev2-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 ab43c49f92cce45b66f9ecd3eb5f48f613413d8cf317e492bc70d39c508503ad
MD5 b581fc5239f20eb2deeb0d32497d23d7
BLAKE2b-256 5b20fc8e81b45542bf06676e8cfe647f5a51fa5225ecb3171d6d217b078020b4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.1.dev2-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 2c8966e33b3dd0284fc1387734dd59cf73da292f2a9a5725d000d5695ab9399e
MD5 a62194341c25cc09875d99cc75728490
BLAKE2b-256 ca206aac24c0c47cba2f7de51d1bb947be78b93f8f0dfc9ebb68c3e07aef2f0f

See more details on using hashes here.

Provenance

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