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.0.tar.gz (22.7 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.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycsp3_solvers_extra-0.1.0.tar.gz
  • Upload date:
  • Size: 22.7 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.0.tar.gz
Algorithm Hash digest
SHA256 6626ed5e53da05840e3cfde830a5d73aae7816c28b3d6d03be8dd2feb17c6ea9
MD5 4cde381aac1f6ec74dfddf1fdaceeb14
BLAKE2b-256 5b1fe5568eb6c26025e34179a812aa0f3c925656e067724d2f49908364492c7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycsp3_solvers_extra-0.1.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pycsp3_solvers_extra-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6ebd2ad7117031368b4fd388b241e35cd8ca9dddf808450bf44decf2c58c64b
MD5 6614c95cd8b9d4fc73af5029d51d7b16
BLAKE2b-256 cf2345fff5b937f879f9c0c625d6a5be05a8c1b07b27a2b8f4bfffd59048de4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycsp3_solvers_extra-0.1.0-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