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.dev6.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.dev6-cp312-abi3-win_arm64.whl (512.6 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-win_amd64.whl (542.8 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-manylinux_2_39_x86_64.whl (490.6 kB view details)

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

sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-manylinux_2_39_aarch64.whl (447.7 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-macosx_14_0_universal2.whl (912.6 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.dev6.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev6.tar.gz
Algorithm Hash digest
SHA256 b9ce311b9d12b825dbbc591a2539f2257c1a0daa1b2ed03fce0e7f35dc6a3c66
MD5 5048b785c59899a230ec13702b34679c
BLAKE2b-256 1f8c6a2ccfd5a00209bda0a6f82ae45149796164b19ad0ba6c7bd41b938d123a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 24d5b799a1e4af3571c3c9b0f8548c72e58dffc097cbbc8a498a17ac8bbe1868
MD5 ef6f9b65fb4487083b28f099a1929a44
BLAKE2b-256 40cf9ec3634c0cc9a5f7932356da5286819226dd66c32cca632e44f7b8dc929f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 40a3b2c0b76432a60e7da3ca26121340fa1f4208de61443a888bc62182d1ba23
MD5 34ed0d0de61ddb9ef4a20540c763bf0d
BLAKE2b-256 32af72f6cd2706a85ba49c4a05d83531cf20f96e7f3662a49c39e20a7c402fec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 9d6b4262446eaab4a3b3ac758a1aaf99f23da6927eb4886f805a7ca295451e7d
MD5 6bfb4f9b61ac2f2a4bf2ab5fe018c3c6
BLAKE2b-256 385e5b874f3edd544486fa6df587df21a2c0b0f3b665178e88feedbc393334ca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 5b9857abef1a63c19e13bdd3de9b12f728db3e0b75845990ce673ac521596e4d
MD5 cc136c2eb7498fc808aa02c346600dac
BLAKE2b-256 ad5120515f6c10b60f2c5a50dff0e5cf4cb4ab8557a365d00def1ae448f58795

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev6-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 22d601b196aa19a721675abe78fa718f381a3a7953337d919f613d26ad457ef1
MD5 6cbe75a4576a1735eee80377dcc14a26
BLAKE2b-256 cf8c7e8cc0deb06759613483a1f654e2a31d98498e077d9ce5564c7605af5b56

See more details on using hashes here.

Provenance

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