https://github.com/chocoteam/pychoco

https://github.com/chocoteam/pychoco

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in JOSS metadata
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software
Last synced: 6 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: chocoteam
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: master
  • Size: 4.89 MB
Statistics
  • Stars: 15
  • Watchers: 4
  • Forks: 3
  • Open Issues: 6
  • Releases: 1
Created over 3 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License

README.md

pychoco

ubuntu_build macos_build windows_build codecov PyPI version Documentation Status PyPI Downloads License

Current choco-solver version: 4.10.17

Python bindings for the Choco Constraint programming solver (https://choco-solver.org/).

Choco-solver is an open-source Java library for Constraint Programming (see https://choco-solver.org/). It comes with many features such as various types of variables, various state-of-the-art constraint, various search strategies, etc.

The pychoco library uses a native-build of the original Java Choco-solver library, in the form of a shared library, which means that it can be used without any JVM. This native-build is created with GraalVM native-image tool.

We heavily relied on JGraphT Python bindings source code to understand how such a thing could be achieved, so many thanks to JGraphT authors!

Installation

We automatically build 64-bit wheels for Python versions >= 3.6 on Linux, Windows and MacOSX. They can be directly downloaded from PyPI (https://pypi.org/project/pychoco/) or using pip:

pip install pychoco

Documentation

If you do not have any knowledge about Constraint Programming (CP) and Choco-solver, you can have a look at https://choco-solver.org/tutos/ for a quick introduction to CP and to Choco-solver features. For this Python API, we also provide an API documentation which is available online at https://pychoco.readthedocs.io/ .

You can also have a look at the pychoco Cheat Sheet : pychoco cheat sheet

Quickstart

pychoco's API is quite close to Choco's Java API. The first thing to do is to import the library and create a model object:

```python from pychoco import Model

model = Model("My Choco Model") ```

Then, you can use this model object to create variables:

python intvars = model.intvars(10, 0, 10) sum_var = model.intvar(0, 100)

You can also create views from this Model object:

python b6 = model.int_ge_view(intvars[6], 6)

Create and post (or reify) constraints:

python model.all_different(intvars).post() model.sum(intvars, "=", sum_var).post() b7 = model.arithm(intvars[7], ">=", 7).reify()

Solve your problem:

python model.get_solver().solve()

And retrieve the solution:

python print("intvars = {}".format([i.get_value() for i in intvars])) print("sum = {}".format(sum_var.get_value())) print("intvar[6] >= 6 ? {}".format(b6.get_value())) print("intvar[7] >= 7 ? {}".format(b7.get_value()))

```

intvars = [3, 5, 9, 6, 7, 2, 0, 1, 4, 8] sum = 45 intvar[6] >= 6 ? False intvar[7] >= 7 ? False ```

Build from source

The following system dependencies are required to build PyChco from sources:

  • GraalVM >= 22 (see https://www.graalvm.org/)
  • Native Image component for GraalVM (see https://www.graalvm.org/22.1/reference-manual/native-image/)
  • Apache Maven (see https://maven.apache.org/)
  • Python >= 3.6 (see https://www.python.org/)
  • SWIG >= 3 (see https://www.swig.org/)

Once these dependencies are satisfied, clone the current repository:

git clone --recurse-submodules https://github.com/chocoteam/pychoco.git

The --recurse-submodules is necessary as the choco-solver-capi is a separate git project included as a submodule (see https://github.com/chocoteam/choco-solver-capi). It contains all the necessary to compile Choco-solver as a shared native library using GraalVM native-image.

Ensure that the $JAVA_HOME environment variable is pointing to GraalVM, and from the cloned repository execute the following command:

sh build.sh

This command will compile Choco-solver into a shared native library and compile the Python bindings to this native API using SWIG.

Finally, run:

pip install .

And voilà !

Citation

Coming soon.

Getting help or contribute

We do our best to maintain pychoco and keep it up-to-date with choco-solver. However, if you see missing features, if you have any questions about using the library, suggestions for improvements, or if you detect a bug, please open an issue.

Owner

  • Name: chocoteam
  • Login: chocoteam
  • Kind: organization

JOSS Publication

pychoco: all-inclusive Python bindings for the Choco-solver constraint programming library
Published
September 29, 2025
Volume 10, Issue 113, Page 8847
Authors
Dimitri Justeau-Allaire ORCID
AMAP, Univ Montpellier, CIRAD, CNRS, INRAE, IRD, Montpellier, France
Charles Prud'homme ORCID
TASC, IMT-Atlantique, LS2N-CNRS, Nantes, France
Editor
Daniel S. Katz ORCID
Tags
bindings native-image constraint programming constraint satisfaction problem constraint optimisation problem decision support

GitHub Events

Total
  • Issues event: 1
  • Watch event: 5
  • Delete event: 14
  • Issue comment event: 4
  • Push event: 46
  • Pull request review event: 3
  • Pull request event: 10
  • Fork event: 2
  • Create event: 19
Last Year
  • Issues event: 1
  • Watch event: 5
  • Delete event: 14
  • Issue comment event: 4
  • Push event: 46
  • Pull request review event: 3
  • Pull request event: 10
  • Fork event: 2
  • Create event: 19

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • cprudhom (6)
  • Dimosts (5)
  • dimitri-justeau (3)
  • ThomSerg (1)
  • JiBBzs (1)
  • IgnaceBleukx (1)
  • Wout4 (1)
Pull Request Authors
  • tlorieul (4)
  • cprudhom (2)
  • ManuelNavarroGarcia (1)
  • IgnaceBleukx (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 1,384 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 7
  • Total maintainers: 2
pypi.org: pychoco

Python bindings to the Choco Constraint Programming solver

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 1,384 Last month
Rankings
Dependent packages count: 10.0%
Average: 16.5%
Downloads: 17.6%
Dependent repos count: 21.7%
Maintainers (2)
Last synced: 6 months ago

Dependencies

.github/workflows/macos.yml actions
  • actions/checkout v2 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v2 composite
  • actions/upload-artifact v2 composite
  • codecov/codecov-action v2 composite
  • helpermethod/graalvm-native-image-toolchain 0.0.2 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/ubuntu.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v2 composite
  • helpermethod/graalvm-native-image-toolchain 0.0.2 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/windows.yml actions
  • actions/checkout v2 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v2 composite
  • actions/upload-artifact v2 composite
  • codecov/codecov-action v2 composite
  • helpermethod/graalvm-native-image-toolchain 0.0.2 composite
  • ilammy/msvc-dev-cmd v1 composite
  • pypa/gh-action-pypi-publish release/v1 composite
requirements_tests.txt pypi
  • networkx >=2 test
requirements_docs.txt pypi
  • Sphinx ==7.0.1
  • geopandas *
  • libpysal *
  • matplotlib *
  • nbsphinx ==0.9.2
  • networkx *
  • numpy *
  • pychoco *
  • rasterio ==1.3.8
  • setuptools *
  • shapely ==2.0.1
  • sphinx-rtd-theme ==1.2.2
  • sphinx_gallery ==0.13.0
setup.py pypi