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.2.dev4.tar.gz (126.5 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.2.dev4-cp312-abi3-win_arm64.whl (522.0 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.2.dev4-cp312-abi3-win_amd64.whl (552.3 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.2.dev4-cp312-abi3-manylinux_2_39_x86_64.whl (501.3 kB view details)

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

sleipnirgroup_jormungandr-0.6.2.dev4-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.2.dev4-cp312-abi3-macosx_14_0_universal2.whl (931.5 kB view details)

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

File details

Details for the file sleipnirgroup_jormungandr-0.6.2.dev4.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev4.tar.gz
Algorithm Hash digest
SHA256 7365a2e111c9ba334751f1fc375a7c8633190363e70d31e5294759feda09887a
MD5 1318b1525047ed0c288628252b6a0403
BLAKE2b-256 148aebc728d016e35d341036a056e5cf89992ee795ffdf061aa1bafe921db9ab

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev4-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 697475d2b6f4086c37173551c1dcc4222f5e15cbcf47c43dba111efa21f5db5d
MD5 be853256bfc3ba07f15e4897bfde02b9
BLAKE2b-256 57ecc9d38dec97360570c9cbc1e75e7ab46d7f6c280bbb19eb4a6a08a3fc3af8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev4-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 79cab3f56dec414146aa0a4730917813e3dcc8068fc307b23715ba1e7514aa74
MD5 ab34074d33aeb34621a754124a900458
BLAKE2b-256 f80b751e4a79c0e45b81a430ef79ed9aab03e581e042105b79f48a471789aac8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev4-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 48a4b1e32540b29cbef0d0cc32559673e19d126907ad5ff464ea96639586ef0a
MD5 33fec66ce79ce50a17a4e4e49ec39b2f
BLAKE2b-256 6c9a6d816dc2ba67d034761ea9db5b714902f9393c711974c4309e59a1ad88f7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev4-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 b1170a556aa312c16b7341395bec1eac7d8b27b04b0bfdbf32c4ebda6d944b90
MD5 325872d5051a2f121ec41a14444fb4a0
BLAKE2b-256 ff176c7242112d7979c96ffc7faf9758ded031c14154d5c87c5992de2ab89f8c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev4-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 93aab324afeab8c347157d98846cc1f3dc855d63553d0b346b88ea8e886d1ff8
MD5 046c55b998f7bef2e6cd26ac2525645f
BLAKE2b-256 11a721a6bd9d1e0900dd97de4c57483cd819de1d01fb8cac1e97990022b7b5e1

See more details on using hashes here.

Provenance

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