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.dev6.tar.gz (127.4 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.dev6-cp312-abi3-win_arm64.whl (514.3 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.5.dev6-cp312-abi3-win_amd64.whl (553.8 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.5.dev6-cp312-abi3-manylinux_2_39_x86_64.whl (515.2 kB view details)

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

sleipnirgroup_jormungandr-0.6.5.dev6-cp312-abi3-manylinux_2_39_aarch64.whl (470.5 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev6.tar.gz
Algorithm Hash digest
SHA256 8ccbbd00c8c07d072b87f97df7d17c0c63457cc035e603028c1fe96c6bfca579
MD5 c0e64ae720e33608b3822a4572e9f7f7
BLAKE2b-256 020b4e76551198d9f5b3e8dc0a5b777c0b9e50e67c0d203475d0c59f0543917d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev6-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 e28559ff0dba8c40733a1b9c02b7788ff122973eecbc2240c1833d4fcd64e088
MD5 daf52862aa6c1f977e2856f15a24211d
BLAKE2b-256 b5b7b2c29f94117d09460f8c0ba648ff48835fe208d4d87b7ac7fc81602a4929

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev6-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1edbb9b245f570b698409129157c017b6880a2d40508eb66b38868a324316167
MD5 694f764ec61d7b2ea425b53d15361970
BLAKE2b-256 e192b1f2ac37e40f5c146c62af2ef7c244583ef7cd798eed0e393453f30507c7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev6-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 39511edcb61769d84d2439f3b3db1b7452eb92c0e94ddf0fb816b5b8c47718bc
MD5 12af1ad09f27d2a34cb39c92f86109b5
BLAKE2b-256 9f0ea3b46a9b67e6efdae85d79b5efbe6d920a9f4d13d4cd2d0487e99c9a880e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev6-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 6d03f0139d10d947e2ec20f52c0aacd6237d88d813dc24b8dcd891bbe0d53d41
MD5 431dc0a5a67768e04c63642d9bb2f810
BLAKE2b-256 073bb5e73e7d8a392391b264d07979dfcdb2223c7c4f11cf45f410e56034b053

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev6-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 20798abb19a8b2b39b852dcf473bfb0f5e4e763867f512d76689e4946b2fe530
MD5 cf64298c2d2c043a28c1bf7d319734a5
BLAKE2b-256 8fcdbb6f0d4e7ac0c5394efe07a3bd8acfd7aeaef8896371bbe9ab52549f44ec

See more details on using hashes here.

Provenance

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