Skip to main content

Extra solver backends for pycsp3 (OR-Tools, IBM CPO)

Project description

pycsp3-solvers-extra

Extension library that adds some extra solver backends to pycsp3.

Supported Solvers

  • OR-Tools CP-SAT - Google's constraint programming solver
  • IBM DOcplex CP Optimizer - IBM's CP solver (requires CPLEX Studio)

Installation

pip install pycsp3-solvers-extra

Dependencies

  • pycsp3 - base constraint modeling library
  • ortools - for OR-Tools backend
  • docplex - for CPO backend (requires IBM CPLEX Studio installed separately)

Usage

from pycsp3 import *
from pycsp3_solvers_extra import solve

# Define your model
x = VarArray(size=3, dom=range(1, 10))
satisfy(AllDifferent(x))
minimize(Sum(x))

# Solve with OR-Tools
status = solve(solver="ortools")

# Or solve with CPO
status = solve(solver="cpo")

# Of course, you still can use the native supported pycsp3 solvers as well ('ace', 'choco')
status = solve(solver="ace")

# Access solution values
print([v.value for v in x])

API

solve(
    solver="ortools",  # "ortools" or "cpo"
    time_limit=None,   # seconds
    sols=None,         # number of solutions to find
    verbose=0,         # verbosity level (0-2)
    options=""         # solver-specific options
)

Returns TypeStatus.SAT, TypeStatus.OPTIMUM, TypeStatus.UNSAT, or TypeStatus.UNKNOWN.

Examples

See the examples/ directory:

python examples/send_more_money.py --solvers ortools cpo

Running Tests

pytest tests/ -v

License

This project is licensed under the MIT License.

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

pycsp3_solvers_extra-0.1.2.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

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

pycsp3_solvers_extra-0.1.2-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file pycsp3_solvers_extra-0.1.2.tar.gz.

File metadata

  • Download URL: pycsp3_solvers_extra-0.1.2.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycsp3_solvers_extra-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b95eeb1946bbf3fa4476a2d30e5fd6197a89835feaa48ee1fea9821a3a2f5145
MD5 761ee1acfa43cf2ee68fd88244cdc0b2
BLAKE2b-256 71648ef9928c7e0a367661922e4eca03c0bc3acf9edbbfea084f701b9ac71725

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycsp3_solvers_extra-0.1.2.tar.gz:

Publisher: publish.yml on sohaibafifi/pycsp3-solvers-extra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycsp3_solvers_extra-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pycsp3_solvers_extra-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c91fbb4a46b0bcdc50917c20a1910f67e7fbf6c7b8d32a3f32b756abb5b265f
MD5 5df3be3edeb8be5270454c759249ad43
BLAKE2b-256 6082088ef82c0b20d192a84c34949bc0d803f2b3c3615cdca255f57e6b710225

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycsp3_solvers_extra-0.1.2-py3-none-any.whl:

Publisher: publish.yml on sohaibafifi/pycsp3-solvers-extra

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