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

Uploaded CPython 3.12+Windows ARM64

sleipnirgroup_jormungandr-0.5.4.dev4-cp312-abi3-win_amd64.whl (542.5 kB view details)

Uploaded CPython 3.12+Windows x86-64

sleipnirgroup_jormungandr-0.5.4.dev4-cp312-abi3-manylinux_2_39_x86_64.whl (491.2 kB view details)

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

sleipnirgroup_jormungandr-0.5.4.dev4-cp312-abi3-manylinux_2_39_aarch64.whl (448.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.39+ ARM64

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev4.tar.gz
Algorithm Hash digest
SHA256 91b45deac6a241afbf7c4f957c31e1eb77e1c96093bedd97f2b926d76d82adc7
MD5 da16cca1ab307f1879807d5864d10934
BLAKE2b-256 f13d84c43fbd301ce74515cb28e921b4b632eba63bcc4aa25e4fc66723c7fdf6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev4-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 0f94068df4b385a0eb3ed4aac31c9ce2f8bd5c0ab7754f299dbcbade34bd2b7a
MD5 c180d34e1eb4631ea04c541f6f479eb3
BLAKE2b-256 1b08b2d18a7741b77aeca26dd3ff725cdcfe66c938b34bf71ca64ae4312d6ee1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev4-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8040bde583f2e3782dd79e9c34b7750142b841b0be52827564118fd3daaa4380
MD5 2748fdb5a3b3e752c4ac3821d9751619
BLAKE2b-256 c53d60f58f1af2c16b568598eabecd9160b6a2f67c3486761096ae61af6c4353

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev4-cp312-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 f62d404624ff973874b4a7889dd3102de18dbeaff6ef8d91c97f1849b4c29056
MD5 55f5ddc017b092db006bc7b70c4c0274
BLAKE2b-256 a0ab0c6cdf7b2fe058007532f426088bd5d1f4ade2cd91d5b41aa98d11f0140d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev4-cp312-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 2ceb920809a75bdc4201fb3787fd23cb86b12d4a9d0bc0f61b4aceaf19144d25
MD5 15c0939fecb640aba9a43f0f4d846fdb
BLAKE2b-256 39d51cb0296d90574205bd4eeecdd75ca2698897f0f60b31672f8b62a6c4cff7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sleipnirgroup_jormungandr-0.5.4.dev4-cp312-abi3-macosx_14_0_universal2.whl
Algorithm Hash digest
SHA256 f46cc90ab7f4249fa3e616097693a25e3d754cd328a73b1fdc2cfa886e440372
MD5 50c94475b5f63fac55e9e523af6b55c5
BLAKE2b-256 ea35febf47e7f44598a342090dd44679debfd5c783292301b39381e489b0021c

See more details on using hashes here.

Provenance

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