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

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-win_amd64.whl (552.1 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-manylinux_2_39_x86_64.whl (513.8 kB view details)

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

sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-manylinux_2_39_aarch64.whl (469.4 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-macosx_14_0_universal2.whl (961.2 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.dev2.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev2.tar.gz
Algorithm Hash digest
SHA256 16c61f39bc8a68b176f2ecc721526d856f687de0f302048f6c9554f30cfa9c3f
MD5 c82507a90064d5114ee55ade33c5fbf1
BLAKE2b-256 20fab9ce50828fc7338e94a2c98f1973c7fe8615521dd3d9c526aefc31f39f96

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 88339b7b060a5ce5289524e8686c01ea70b9b41704010a4cee52d0d12a36c82b
MD5 bdb3162d0de9c436fb656ef0ab0ef2de
BLAKE2b-256 e02b36bf15a86e467da3eef0958e74a29d95d1f09b291bf37567fa0f60920e3d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 78f692353022f022ad7dc9581f3353be1db5abf150592b8a8a16cfbe7c09b1b0
MD5 9ef3215f9021fa7a5418ec3358e560b8
BLAKE2b-256 ebfca3f0867ddeb4f1824a0a3d0682bb09b756822d06ee53627247e2247117d4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 106d0c7c8cc342173b1288f08ee81b587ddaa78d21abcaa016aa1e8431681bca
MD5 c2ff63af327133bb73b9a9647b62d8c0
BLAKE2b-256 d1960bfd86e877ada37425eb8bf04da472e20cb2e79704aa5284071f35f94d70

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 130cf80f7c87c9f646511b0c3f1c5c10f46cc9fb342aa649cba828c14cac0621
MD5 83b7e4bebc7bd94b47bd532734f4f318
BLAKE2b-256 5e5ac273c24621d6a3a11937893688da412b62be39733f1f8b3952c63cfa61d8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev2-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 bd0d392be1804b72cca88a1c77ab6bf4862cb9bd675c67fb6dc52d7d8419706a
MD5 41dbe8f03fc04cbc3a0daa9cc916917c
BLAKE2b-256 0be8475dd00a9c7387a30fedcfd3244303cf11b26dbc89afb7eb6e80df9689d3

See more details on using hashes here.

Provenance

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