Skip to main content

Python bindings for Exact

Project description

Exact

Exact solves decision and optimization problems formulated as integer linear programs. Under the hood, it converts integer variables to binary (0-1) variables and applies highly efficient propagation routines and strong cutting-planes / pseudo-Boolean conflict analysis.

Exact is a fork of RoundingSat and improves upon its predecessor in reliability, performance and ease-of-use. In particular, Exact supports integer variables, reified linear constraints, multiplication constraints, and propagation and count inferences. The name "Exact" reflects that the answers are fully sound, as approximate and floating-point calculations only occur in heuristic parts of the algorithm. As such, Exact can soundly be used for verification and theorem proving, where its envisioned ability to emit machine-checkable certificates of optimality and unsatisfiability should prove useful.

Features

  • Native conflict analysis over binary linear constraints, constructing full-blown cutting planes proofs.
  • Highly efficient watched propagation routines.
  • Fine-grained employment of arbitrary precision calculations - only when needed.
  • Hybrid linear (top-down) and core-guided (bottom-up) optimization.
  • Optional integration with the SoPlex LP solver.
  • Core solver also compiles on macOS and Windows.
  • Python interface with assumption solving and reuse of solver state (Linux only for now).
  • Generation of certificates of optimality and unsatisfiability that can be automatically verified by VeriPB.
  • Excellent performance, as showcased in 2024's PB competition.

Python interface

PyPI package

The easiest way is to use Exact's Python interfaces is on an x86_64 machine with Windows or Linux. In that case, install this precompiled PyPi package, e.g., by running pip install exact.

Compile your own Python package

To use the Exact Python interface with optimal binaries for your machine (and the option to include SoPlex in the binary), compile as a shared library and install it with your package manager. E.g., on Linux systems, running pip install . in Exact's root directory should do the trick. On Windows, uncomment the build options below # FOR WINDOWS and comment out those for # FOR LINUX. Make sure to have the Boost libraries installed (see dependencies).

Documentation

The header file Exact.hpp contains the C++ methods exposed to Python via Pybind11 as well as their description. This is probably the best place to start to learn about Exact's Python interface.

Next, python_examples contains instructive examples. Of particular interest is the knapsack tutorial, which is fully commented, starts simple, and ends with some of Exact's advanced features.

Command line usage

Exact takes as command line input an integer linear program and outputs a(n optimal) solution or reports that none exists. Either pipe the program

cat test/instances/opb/opt/stein15.opb | build/Exact

or pass the file as a parameter

build/Exact test/instances/opb/opt/stein15.opb

Use the flag --help to display a list of runtime parameters.

Exact supports five input formats (described in more detail in InputFormats.md):

  • .opb pseudo-Boolean decision and optimization (equivalent to 0-1 integer linear programming)
  • .wbo weighted pseudo-Boolean optimization (0-1 integer linear programming with weighted soft constraints)
  • .cnf DIMACS Conjunctive Normal Form (CNF)
  • .wcnf Weighted Conjunctive Normal Form (WCNF)
  • .mps Mathematical Programming System (MPS) via the optional CoinUtils library
  • .lp Linear Program (LP) via the optional CoinUtils library

Note that .mps and .lp allow rational variables, which are not supported by Exact. Additionally, these formats permit floating point values, which may lead to tricky issues. Rewrite constraints with fractional values to integral ones by multiplying with the lowest common multiple of the denominators.

By default, Exact decides on the format based on the filename extension, but this can be overridden with the --format option.

Compilation from source

In the root directory of Exact:

cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Replace make by cmake --build . on Windows. For more builds, similar build directories can be created.

For installing system-wide or to the CMAKE_INSTALL_PREFIX root, use make install (on Linux).

Dependencies

  • A recent C++20 compiler (GCC, Clang or MSVC should do)
  • Boost library, minimal version 1.65. On a Debian/Ubuntu system, install with sudo apt install libboost-dev. On Windows, follow the instructions on boost.org
  • Optionally: CoinUtils library to parse MPS and LP file formats. Use CMake option -Dcoinutils=ON after installing the library.
  • Optionally: SoPlex LP solver (see below).

SoPlex (on Linux)

Exact supports an integration with the LP solver SoPlex to improve its search routine. For this, checkout SoPlex from its git repository as a submodule, compile it in some separate directory, and configure the right CMake options when compiling Exact.

By default, the following commands in Exact's root directory should work with a freshly checked out repository:

    git submodule init
    git submodule update

    mkdir soplex_build
    cd soplex_build
    cmake ../soplex -DBUILD_TESTING="0" -DSANITIZE_UNDEFINED="0" -DCMAKE_BUILD_TYPE="Release" -DBOOST="0" -DGMP="0" -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS="0" -DZLIB="0"
    make -j 8

    cd ../build
    cmake .. -DCMAKE_BUILD_TYPE="Release" -Dsoplex="ON"
    make -j 8

The CMake options soplex_src and soplex_build allow to look for SoPlex in a different location.

License

Exact is licensed under the AGPLv3. If this would hinder your intended usage, please contact @JoD.

Benchmarks

The current set of benchmarks which is used to assess performance is available here.

Citations

If you use Exact, please star and cite this repository and cite the RoundingSat origin paper (which focuses on cutting planes conflict analysis):
[EN18] J. Elffers, J. Nordström. Divide and Conquer: Towards Faster Pseudo-Boolean Solving. IJCAI 2018

Please cite any of the following papers if they are relevant.

Integration with SoPlex:
[DGN20] J. Devriendt, A. Gleixner, J. Nordström. Learn to Relax: Integrating 0-1 Integer Linear Programming with Pseudo-Boolean Conflict-Driven Search. CPAIOR 2020 / Constraints journal

Watched propagation:
[D20] J. Devriendt. Watched Propagation for 0-1 Integer Linear Constraints. CP 2020

Core-guided optimization:
[DGDNS21] J. Devriendt, S. Gocht, E. Demirović, J. Nordström, P. J. Stuckey. Cutting to the Core of Pseudo-Boolean Optimization: Combining Core-Guided Search with Cutting Planes Reasoning. AAAI 2021

Industrial use cases

After considering Gurobi and OR-tools to extract minimal unsatisfiable subsets for a workforce allocation problem, a big European airplane manufacturer decided Exact was the way to go! (mirror)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

exact-2.2.1-cp313-cp313-win_amd64.whl (912.5 kB view details)

Uploaded CPython 3.13Windows x86-64

exact-2.2.1-cp313-cp313-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

exact-2.2.1-cp312-cp312-win_amd64.whl (912.5 kB view details)

Uploaded CPython 3.12Windows x86-64

exact-2.2.1-cp312-cp312-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

exact-2.2.1-cp311-cp311-win_amd64.whl (912.2 kB view details)

Uploaded CPython 3.11Windows x86-64

exact-2.2.1-cp311-cp311-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

exact-2.2.1-cp310-cp310-win_amd64.whl (911.4 kB view details)

Uploaded CPython 3.10Windows x86-64

exact-2.2.1-cp310-cp310-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

File details

Details for the file exact-2.2.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: exact-2.2.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 912.5 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for exact-2.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8ed9b16af2ce61247f3d5e7284ee40fd7766ffa3d13d975b7ab358e895bb9111
MD5 81afb536cce2d7e9c2d3fba865eeadb1
BLAKE2b-256 cbc4e296ccb98ad1b0fe2471f067ecc5605c764c6edd8808e44388a42417bf49

See more details on using hashes here.

File details

Details for the file exact-2.2.1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exact-2.2.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6605e445d97063fc7ec5691df64949e1a418efaa43fe3870708f24904a1a4ab2
MD5 494f3229efb4d16f97766bd11a1dec2e
BLAKE2b-256 16a70d158306bcc8bd1f529c817ae8851c822b69793eceff5f1dba883b0575fc

See more details on using hashes here.

File details

Details for the file exact-2.2.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: exact-2.2.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 912.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for exact-2.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 732ff1276dcbef456274f0d8411596ed10200ce34ee76bea44026026ba0d1531
MD5 c89d47b4da2ba2480e3e6af75b09b729
BLAKE2b-256 7713021175e9e3fe9211db246633efddec64b718089087ec6745bced0b42c3df

See more details on using hashes here.

File details

Details for the file exact-2.2.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exact-2.2.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c8c5622cc0c219324ee5882d07dc850a6ef73b94051a0d0dd9968f615a327a72
MD5 5fad1471b42a448455966740c9575b18
BLAKE2b-256 cf3ef7a98e7ad01c2ebc6161830b6fba0c359883aa605a6051f46abce45f92ab

See more details on using hashes here.

File details

Details for the file exact-2.2.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: exact-2.2.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 912.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for exact-2.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 91aa45bc51079b79ec37328539303a45ec768553cc7d7cae413871943c4517f9
MD5 2b8a85022a4cf7a58f1814abea4d336d
BLAKE2b-256 f80999d3022d1631cb81ce10b92fd87e36be4633b0eea2d358a2197a24331d88

See more details on using hashes here.

File details

Details for the file exact-2.2.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exact-2.2.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5ebde005153ccd9dce4be444928db44cc40e869d181bacb2e1ca5b8bc859b039
MD5 16f360c5698875360a04489fa766fce1
BLAKE2b-256 3121dae42e0b4b214e7bd03f24049faefc4f90fdcb9eabc30d288246696872c7

See more details on using hashes here.

File details

Details for the file exact-2.2.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: exact-2.2.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 911.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for exact-2.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cd2d9803cfa2dabea06932e351d30004ce2792b3d6e3b5c22ab2eaa89078baf3
MD5 2101953766081af5a564299dba039717
BLAKE2b-256 6fd8ff5bd2ff900a8be941ae6a71c1708f0a592d5cae101c22556f6a2bcad781

See more details on using hashes here.

File details

Details for the file exact-2.2.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for exact-2.2.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f217303e599a785951478e4570e17449645913d2d6f20309c15a32e6c592160c
MD5 c7f3d359ffdac25a1da42e3a3d45de42
BLAKE2b-256 94d768d3869b3c185e7e0447865efb6453a7e8fdaadd083a434fd90d113c9d16

See more details on using hashes here.

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