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.dev11.tar.gz (127.8 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.dev11-cp312-abi3-win_arm64.whl (515.0 kB view details)

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.6.5.dev11-cp312-abi3-win_amd64.whl (554.9 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.6.5.dev11-cp312-abi3-manylinux_2_39_x86_64.whl (515.8 kB view details)

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

sleipnirgroup_jormungandr-0.6.5.dev11-cp312-abi3-manylinux_2_39_aarch64.whl (471.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev11.tar.gz
Algorithm Hash digest
SHA256 62fd6ffcde1d3ddf8724f5a1d1f4794d80a2f5f1640898a9cd2e096ddf79318f
MD5 04b7b3248eff4186c3ea577b965a6141
BLAKE2b-256 954be3a1a6e72c0c024cc8f51c8b25fed8ac5921c3eeb0098627ce852ffb949b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev11-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 ec6539ba1b6a882255ab94e2beefd20fdf37de60fe47ea9ba382a3f242d7b7a8
MD5 17235c8ed5055717eb21d2d74c785013
BLAKE2b-256 5858b2020bc6f03d7e1a1f7b4851769851e350aee0bd4d41c22c2fecc444f17a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev11-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a9c83a617dd9ebb95db42341e83380bbf77db8a2d34d221fd74ff03a958ee5ef
MD5 15259930f678f65da103fef7815e6e2c
BLAKE2b-256 b371f60e47dff4934d23ff3d7a245dab135bbc520ef46424f18339f660b9e88e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev11-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 d07a400ae6c479a2ca8d679c31f4559deb99532e14059744c96695428c9004bf
MD5 62465a45934a878455add4a40b7fc6c1
BLAKE2b-256 260082b928d34a6ae86903e3621221b474a09cdb3b6cf8da1adf97cf23b15c36

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev11-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 aaacddb18826d1ba2bd5a5df417f817bf73a685f72c5d1e301d9a4c094261c0d
MD5 4b5e93ca30e755079d350f0c1041bc95
BLAKE2b-256 71562246a481c13f0ab7aff324343c87cb0e00fd22e7955d2e608d088d6aa028

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.6.5.dev11-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 cdef019b589ef8a0f74e69e96b84744b60f983976ca0da2834cb4a29c1c39f8f
MD5 b1bbc5b8d7df81748266660170d3cd36
BLAKE2b-256 ad028ddd0a05f4ce9c045b839f6dc7a52a18430b1caaa05a9fe5657245e253de

See more details on using hashes here.

Provenance

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