pychoco


Namepychoco JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryPython bindings to the Choco Constraint Programming solver
upload_time2024-10-01 13:05:53
maintainerNone
docs_urlNone
authorDimitri Justeau-Allaire, Charles Prud'homme
requires_python>=3.6
licenseBSD-4
keywords constraint programming optimization graphs artificial intelligence combinatorics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pychoco

[![ubuntu_build](https://github.com/chocoteam/pychoco/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/chocoteam/pychoco/actions)
[![macos_build](https://github.com/chocoteam/pychoco/actions/workflows/macos.yml/badge.svg)](https://github.com/chocoteam/pychoco/actions)
[![windows_build](https://github.com/chocoteam/pychoco/actions/workflows/windows.yml/badge.svg)](https://github.com/chocoteam/pychoco/actions)
[![codecov](https://codecov.io/gh/chocoteam/pychoco/branch/master/graph/badge.svg?token=JRW8NQG8I7)](https://codecov.io/gh/chocoteam/pychoco)
[![PyPI version](https://badge.fury.io/py/pychoco.svg)](https://pypi.org/project/pychoco/)
[![Documentation Status](https://readthedocs.org/projects/pychoco/badge/?version=latest)](https://pychoco.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/badge/License-BSD_4--Clause-blue.svg)](https://directory.fsf.org/wiki/License:BSD-4-Clause)

*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](https://www.graalvm.org/) native-image tool.

We heavily relied on [JGraphT Python bindings](https://python-jgrapht.readthedocs.io/) 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, 3.7, 3.8, 3.9, and 3.10 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/ .

## 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](https://github.com/chocoteam/pychoco/issues/new/choose).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pychoco",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "constraint programming, optimization, graphs, artificial intelligence, combinatorics",
    "author": "Dimitri Justeau-Allaire, Charles Prud'homme",
    "author_email": "dimitri.justeau@gmail.com, charles.prudhomme@imt-atlantique.fr",
    "download_url": null,
    "platform": "any",
    "description": "# pychoco\n\n[![ubuntu_build](https://github.com/chocoteam/pychoco/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/chocoteam/pychoco/actions)\n[![macos_build](https://github.com/chocoteam/pychoco/actions/workflows/macos.yml/badge.svg)](https://github.com/chocoteam/pychoco/actions)\n[![windows_build](https://github.com/chocoteam/pychoco/actions/workflows/windows.yml/badge.svg)](https://github.com/chocoteam/pychoco/actions)\n[![codecov](https://codecov.io/gh/chocoteam/pychoco/branch/master/graph/badge.svg?token=JRW8NQG8I7)](https://codecov.io/gh/chocoteam/pychoco)\n[![PyPI version](https://badge.fury.io/py/pychoco.svg)](https://pypi.org/project/pychoco/)\n[![Documentation Status](https://readthedocs.org/projects/pychoco/badge/?version=latest)](https://pychoco.readthedocs.io/en/latest/?badge=latest)\n[![License](https://img.shields.io/badge/License-BSD_4--Clause-blue.svg)](https://directory.fsf.org/wiki/License:BSD-4-Clause)\n\n*Current choco-solver version: 4.10.17*\n\nPython bindings for the Choco Constraint programming solver (https://choco-solver.org/).\n\nChoco-solver is an open-source Java library for Constraint Programming (see https://choco-solver.org/).\nIt comes with many features such as various types of variables, various state-of-the-art constraint,\nvarious search strategies, etc.\n\nThe pychoco library uses a *native-build* of the original Java Choco-solver library, in the form\nof a shared library, which means that it can be used without any JVM. This native-build is created\nwith [GraalVM](https://www.graalvm.org/) native-image tool.\n\nWe heavily relied on [JGraphT Python bindings](https://python-jgrapht.readthedocs.io/) source code to\nunderstand how such a thing could be achieved, so many thanks to JGraphT authors!\n\n## Installation\n\nWe automatically build 64-bit wheels for Python versions 3.6, 3.7, 3.8, 3.9, and 3.10 on Linux, Windows and\nMacOSX. They can be directly downloaded from PyPI (https://pypi.org/project/pychoco/) or using pip:\n\n    pip install pychoco\n\n## Documentation\n\nIf you do not have any knowledge about Constraint Programming (CP) and Choco-solver, you can have a look at \nhttps://choco-solver.org/tutos/ for a quick introduction to CP and to Choco-solver features. For this Python API,\nwe also provide an API documentation which is available online at https://pychoco.readthedocs.io/ .\n\n## Quickstart\n\npychoco's API is quite close to Choco's Java API. The first thing to do is to import the\nlibrary and create a model object:\n\n```python\nfrom pychoco import Model\n\nmodel = Model(\"My Choco Model\")\n```\n\nThen, you can use this model object to create variables:\n\n```python\nintvars = model.intvars(10, 0, 10)\nsum_var = model.intvar(0, 100)\n```\n\nYou can also create views from this Model object:\n\n```python\nb6 = model.int_ge_view(intvars[6], 6)\n```\n\nCreate and post (or reify) constraints:\n\n```python\nmodel.all_different(intvars).post()\nmodel.sum(intvars, \"=\", sum_var).post()\nb7 = model.arithm(intvars[7], \">=\", 7).reify()\n```\n\nSolve your problem:\n\n```python\nmodel.get_solver().solve()\n```\n\nAnd retrieve the solution:\n\n```python\nprint(\"intvars = {}\".format([i.get_value() for i in intvars]))\nprint(\"sum = {}\".format(sum_var.get_value()))\nprint(\"intvar[6] >= 6 ? {}\".format(b6.get_value()))\nprint(\"intvar[7] >= 7 ? {}\".format(b7.get_value()))\n```\n\n```\n> intvars = [3, 5, 9, 6, 7, 2, 0, 1, 4, 8]\n> sum = 45\n> intvar[6] >= 6 ? False\n> intvar[7] >= 7 ? False\n```\n\n## Build from source\n\nThe following system dependencies are required to build PyChco from sources:\n\n- GraalVM >= 22 (see https://www.graalvm.org/)\n- Native Image component for GraalVM (see https://www.graalvm.org/22.1/reference-manual/native-image/)\n- Apache Maven (see https://maven.apache.org/)\n- Python >= 3.6 (see https://www.python.org/)\n- SWIG >= 3 (see https://www.swig.org/)\n\nOnce these dependencies are satisfied, clone the current repository:\n\n    git clone --recurse-submodules https://github.com/chocoteam/pychoco.git\n\nThe `--recurse-submodules` is necessary as the `choco-solver-capi` is a separate git project included\nas a submodule (see https://github.com/chocoteam/choco-solver-capi). It contains all the necessary\nto compile Choco-solver as a shared native library using GraalVM native-image.\n\nEnsure that the `$JAVA_HOME` environment variable is pointing to GraalVM, and from the cloned repository\nexecute the following command:\n\n    sh build.sh\n\nThis command will compile Choco-solver into a shared native library and compile the Python bindings\nto this native API using SWIG.\n\nFinally, run:\n\n    pip install .\n\nAnd voil\u00e0 !\n\n## Citation\n\nComing soon.\n\n## Getting help or contribute\n\nWe do our best to maintain pychoco and keep it up-to-date with choco-solver. However, if you see missing\nfeatures, if you have any questions about using the library, suggestions for improvements, or if you\ndetect a bug, please [open an issue](https://github.com/chocoteam/pychoco/issues/new/choose).\n",
    "bugtrack_url": null,
    "license": "BSD-4",
    "summary": "Python bindings to the Choco Constraint Programming solver",
    "version": "0.2.1",
    "project_urls": null,
    "split_keywords": [
        "constraint programming",
        " optimization",
        " graphs",
        " artificial intelligence",
        " combinatorics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a149219e18aa678c9467ff2fce719ee128eeda9642206e3c27cef2c3f82608ae",
                "md5": "c5dcef869b5331a8794434c8ba3ab85f",
                "sha256": "efa57666c34de742ac92be349151ad9a0653d72f8a14b3c363e352f289f40147"
            },
            "downloads": -1,
            "filename": "pychoco-0.2.1-cp310-cp310-manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "c5dcef869b5331a8794434c8ba3ab85f",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.6",
            "size": 10693349,
            "upload_time": "2024-10-01T13:05:53",
            "upload_time_iso_8601": "2024-10-01T13:05:53.483150Z",
            "url": "https://files.pythonhosted.org/packages/a1/49/219e18aa678c9467ff2fce719ee128eeda9642206e3c27cef2c3f82608ae/pychoco-0.2.1-cp310-cp310-manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "efd52abf402e151ed3ae967e65bc70bcf079a69317ae0ae69333a6f73b111cb1",
                "md5": "3d3907c9637277821dad0c9bde419008",
                "sha256": "40bd290ba84363c86c933e408daee182a58a7451736265575f9b4b6ce8835a27"
            },
            "downloads": -1,
            "filename": "pychoco-0.2.1-cp310-cp310-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "3d3907c9637277821dad0c9bde419008",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.6",
            "size": 19540392,
            "upload_time": "2024-10-01T13:11:54",
            "upload_time_iso_8601": "2024-10-01T13:11:54.978614Z",
            "url": "https://files.pythonhosted.org/packages/ef/d5/2abf402e151ed3ae967e65bc70bcf079a69317ae0ae69333a6f73b111cb1/pychoco-0.2.1-cp310-cp310-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e28c14ccf3bc6c819e3737e6917bc1236fe5381e17336b8ca83b7233b6272242",
                "md5": "e2042442209d2808711b90cb89114fe7",
                "sha256": "d1be602045ceecd778032801a9c577aeb18c4fa5cecc44db3537517dade95dc4"
            },
            "downloads": -1,
            "filename": "pychoco-0.2.1-cp311-cp311-manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "e2042442209d2808711b90cb89114fe7",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.6",
            "size": 10701439,
            "upload_time": "2024-10-01T13:05:51",
            "upload_time_iso_8601": "2024-10-01T13:05:51.667697Z",
            "url": "https://files.pythonhosted.org/packages/e2/8c/14ccf3bc6c819e3737e6917bc1236fe5381e17336b8ca83b7233b6272242/pychoco-0.2.1-cp311-cp311-manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "94362f1d498b5e4094046e109291c72648c8d678a8917727c448c0813bd1c8fc",
                "md5": "ef9400dda28af177c7801c88b0102ea0",
                "sha256": "ee55be15f70ecafc7e1eec968831ba95fb0f8fb62dc32e1d27e9dd622700ec89"
            },
            "downloads": -1,
            "filename": "pychoco-0.2.1-cp311-cp311-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "ef9400dda28af177c7801c88b0102ea0",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.6",
            "size": 19534762,
            "upload_time": "2024-10-01T13:11:50",
            "upload_time_iso_8601": "2024-10-01T13:11:50.759146Z",
            "url": "https://files.pythonhosted.org/packages/94/36/2f1d498b5e4094046e109291c72648c8d678a8917727c448c0813bd1c8fc/pychoco-0.2.1-cp311-cp311-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dff8625f2f90a8168ad156b1257d698a2999712c3b885b38538c1e058f5beee9",
                "md5": "21c25de61d7bf8b3568b56ba8edecfd2",
                "sha256": "4c1aa0ed182509676a1db936a4a4762160c455ec746f00740532846c8ef1bad5"
            },
            "downloads": -1,
            "filename": "pychoco-0.2.1-cp312-cp312-manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "21c25de61d7bf8b3568b56ba8edecfd2",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.6",
            "size": 10699891,
            "upload_time": "2024-10-01T13:06:14",
            "upload_time_iso_8601": "2024-10-01T13:06:14.316406Z",
            "url": "https://files.pythonhosted.org/packages/df/f8/625f2f90a8168ad156b1257d698a2999712c3b885b38538c1e058f5beee9/pychoco-0.2.1-cp312-cp312-manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "337345b3bb727197844d283858cd308da661e736c010b2b5834a12bb4ce03f35",
                "md5": "fd1890b18b147fadc1074e5212bd4cd2",
                "sha256": "dfa06621afab6653885d099b5e3e90e61e7da7de104fb2f883f87ebaa7dbbc67"
            },
            "downloads": -1,
            "filename": "pychoco-0.2.1-cp312-cp312-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "fd1890b18b147fadc1074e5212bd4cd2",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.6",
            "size": 19536566,
            "upload_time": "2024-10-01T13:11:50",
            "upload_time_iso_8601": "2024-10-01T13:11:50.373540Z",
            "url": "https://files.pythonhosted.org/packages/33/73/45b3bb727197844d283858cd308da661e736c010b2b5834a12bb4ce03f35/pychoco-0.2.1-cp312-cp312-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e714305f8df3f7a94943738e2b451eff95131d48179e8e825c28d4a4886b2cd7",
                "md5": "ca8afa18400e7ec4194d608a9b06788d",
                "sha256": "399ba6d565ee504524e0e5e017fd6c7654717c892aca3f51ed3e54af28e6bd04"
            },
            "downloads": -1,
            "filename": "pychoco-0.2.1-cp39-cp39-manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "ca8afa18400e7ec4194d608a9b06788d",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.6",
            "size": 10729903,
            "upload_time": "2024-10-01T13:17:23",
            "upload_time_iso_8601": "2024-10-01T13:17:23.959217Z",
            "url": "https://files.pythonhosted.org/packages/e7/14/305f8df3f7a94943738e2b451eff95131d48179e8e825c28d4a4886b2cd7/pychoco-0.2.1-cp39-cp39-manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7ea16fcbc00ca637058e0a0a8124fc03eb157b988ee3fb8e09919924545f402",
                "md5": "0c1dbc0fa31d267ec6cbd336a6cf7b77",
                "sha256": "d75b29d56e5221eeb5415f31ec2609c9d545d64985d9400668cb5765a5a4671f"
            },
            "downloads": -1,
            "filename": "pychoco-0.2.1-cp39-cp39-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "0c1dbc0fa31d267ec6cbd336a6cf7b77",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.6",
            "size": 19564446,
            "upload_time": "2024-10-01T13:11:54",
            "upload_time_iso_8601": "2024-10-01T13:11:54.958403Z",
            "url": "https://files.pythonhosted.org/packages/b7/ea/16fcbc00ca637058e0a0a8124fc03eb157b988ee3fb8e09919924545f402/pychoco-0.2.1-cp39-cp39-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-01 13:05:53",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pychoco"
}
        
Elapsed time: 1.40632s