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.5.2.tar.gz (121.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.5.2-cp312-abi3-win_arm64.whl (512.3 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.5.2-cp312-abi3-win_amd64.whl (542.4 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.5.2-cp312-abi3-manylinux_2_39_x86_64.whl (491.1 kB view details)

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

sleipnirgroup_jormungandr-0.5.2-cp312-abi3-manylinux_2_39_aarch64.whl (448.2 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.5.2-cp312-abi3-macosx_14_0_universal2.whl (914.3 kB view details)

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

File details

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.2.tar.gz
Algorithm Hash digest
SHA256 2ecc84617ef8fd9947cdb6215032618bb4b66fb8b96210fd6ec22b53c53784b2
MD5 be4b7800b96b343140cab3cacea561f3
BLAKE2b-256 67d13dae0025cba9808f1d606ae9e65b479094615e29592f93a5fe88e6b4affa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.2-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 b99c76bb7008f4cd3e5b405a66bd8caec7efb7245b48606d5147df2dc588f502
MD5 34866db7bf0d592c6690f1d220e2f3f8
BLAKE2b-256 27bad9dfd0b5f8fcf13fef624a84ffab285a0a558bb62c5553c01db9c032ccef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 501f5f0370ac180c011965886a60fca713399e008a6760e2386327e40ac2ae37
MD5 ae8b8d3f1f191b580f19d906152434fc
BLAKE2b-256 f320607b344222484fb9dcb22f491c4e52745097d2af3043260b1a84ea0dd2b7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.2-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 8cdec7093695bd068a4795e3f341a886f39940a1ae08d3ead5d8cbe547c3f67f
MD5 d0245de2de17cef15c4b9d19f318a67f
BLAKE2b-256 784f04a8a4648d67954f0b3276066824f6a0c572dd83259fa12a0d4b708de41a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.2-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 9543ee0c4a9e93cddab9decae651e49900b89ab9ca65449a097d2d187ed2769f
MD5 0af5391789156255af9f1ae2807843de
BLAKE2b-256 dd36a855d80ebb71b36f16fd7edf7275a73a8cbc629b1a95b7e893c3d539fcfc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.2-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 92403d18db0aa6e19d256d33aa89e8fa9aa9b5c80952588f50a83aebd42ae693
MD5 c3ea20390207b3c16c79700955df489a
BLAKE2b-256 b505c6ccf86dd413aa10a4d4e32f29b83fcefe41f195f0a9fe499d1227301ced

See more details on using hashes here.

Provenance

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