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.4.dev3.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.4.dev3-cp312-abi3-win_arm64.whl (512.3 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-win_amd64.whl (542.5 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-manylinux_2_39_x86_64.whl (491.2 kB view details)

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

sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-manylinux_2_39_aarch64.whl (448.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-macosx_14_0_universal2.whl (914.4 kB view details)

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

File details

Details for the file sleipnirgroup_jormungandr-0.5.4.dev3.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev3.tar.gz
Algorithm Hash digest
SHA256 98b0cecb4fa6ff95a0541ebaaf49b2783e3263fa148f837dcda197ee0b9f73a5
MD5 27dc546d7dd80b29ce2b7209256cf205
BLAKE2b-256 d0dda06120e1aa3472f24f4ff3b026c897b88a9a3c9dc5b135698ebf28422807

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 11b6b3846f4cc90fa19c10b88611bbd0786c4d2692943ba01cdcd80fa8e60785
MD5 03bcd4b33a07b87c54b3e1a91589d99f
BLAKE2b-256 1bcdf99b852dc59fa378ddd88217b76a0cb5dd3add43b81f251e6405ad6bd085

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 eec8fe65f5eeb6bfd024da99a24714f1f7cc125740550a8d0fb363d838a936c5
MD5 8cde2eeb14d9996f0f4dab82e49ffa9c
BLAKE2b-256 c3e8794de7acbf7934dc953e551991210d258a8d1f620a6cf50aa11e7e617f33

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 7bb40e701adcbd8c8c864beaebff80011caaf491996d42959f399d9091be5500
MD5 27ce63f174f494c83d44b3c64abba74b
BLAKE2b-256 2e28f54b7743716035d35cab9c74785766c561199d3b246dbb5b7d4f5fd880c1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 919bca91ed45af2ed602e72ccc4501e0497a144085a8baa0c819f83e1037e4bc
MD5 c4b67c3da38aaf9bcd4b12c5898010d8
BLAKE2b-256 6b1f701eb14a3337375c2f5a204f397565a07f0c78d9eaab8a7439473b85c3fb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev3-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 967f1f0477a6b8e246afdde81926e843b726f915fb22030482cb75cd0a03c995
MD5 9dcb107be2aabca2d77b73fe402851fd
BLAKE2b-256 d60e4842ac08ec7a8a67215bb8fd2f83be69380a99011c9aa38de027ac3c4d97

See more details on using hashes here.

Provenance

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