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

Uploaded CPython 3.12+Windows ARM64

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

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.2.dev8-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.dev8-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.dev8-cp312-abi3-macosx_14_0_universal2.whl (931.6 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.dev8.tar.gz.

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev8.tar.gz
Algorithm Hash digest
SHA256 bed6f948bb2c79cdae118fda91102e6b02194a2df3f165951f05824933eca59d
MD5 003d7a12c5a10963658f8a52cafe3fd5
BLAKE2b-256 00f261071a8f14772ab4a18dd498cb8c3cea5181b7bf4e437a62cb96f7988b0e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev8-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 588018b65f7eddbcf261ddbf222f691dd15224df0d82ec875aae8badd06c20df
MD5 9ba9054d89a1d18091c33bb71c06374a
BLAKE2b-256 f9252b92661ddbe1837cd5367dede8c12186231c978afed65702701bb59f37e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev8-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 159b21772d941ad5e5831c1722c27af2c448b7b95fe59303e15b356c4a1a9761
MD5 594717e956fa357f7e5d04af40871fcf
BLAKE2b-256 5e0405e60b911a47870f83e829fea39810f1e0140c8043bd6bea9a6572d16a84

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev8-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 2c4ac6393f30120cb0d916153fc9e7b7d56c81055fcf259a7c74d12349d58ff5
MD5 1945e182f948501443c4088e662c7b20
BLAKE2b-256 dbdd8139a2870fa5a2c1846c8dd24aaff4381d30fc6a7475c20df179274ffd55

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev8-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 2911ff9501b6b73fe169b50c9c803c6298a58917381e344be9193d15c7a0a4d6
MD5 1149a090607b299ff820d7c436cebbd2
BLAKE2b-256 134e9bea0c1a6f4302d7efe27931d673ee52079b678c7322f6254d2514c144c6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.2.dev8-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 6b70aac18577a262357b021a5c5a32967aba7cba7bbc8194ad15224dda9841e3
MD5 7f8b093cfb879e0879bf304d8b88e943
BLAKE2b-256 8ab39285854f80e9b613e134024e821b82798d09eed36be1c05c1a24a3a7d5bd

See more details on using hashes here.

Provenance

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