{ "info": { "author": "Gustavo Niemeyer", "author_email": "gustavo@niemeyer.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Cython", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Scientific/Engineering" ], "description": "|Build Status| |Code Health| |Code Coverage|\n\npython-constraint\n=================\n\nIntroduction\n------------\nThe Python constraint module offers solvers for `Constraint Satisfaction Problems (CSPs) `_ over finite domains in simple and pure Python. CSP is class of problems which may be represented in terms of variables (a, b, ...), domains (a in [1, 2, 3], ...), and constraints (a < b, ...).\n\nExamples\n--------\n\nBasics\n~~~~~~\n\nThis interactive Python session demonstrates the module basic operation:\n\n.. code-block:: python\n\n >>> from constraint import *\n >>> problem = Problem()\n >>> problem.addVariable(\"a\", [1,2,3])\n >>> problem.addVariable(\"b\", [4,5,6])\n >>> problem.getSolutions()\n [{'a': 3, 'b': 6}, {'a': 3, 'b': 5}, {'a': 3, 'b': 4},\n {'a': 2, 'b': 6}, {'a': 2, 'b': 5}, {'a': 2, 'b': 4},\n {'a': 1, 'b': 6}, {'a': 1, 'b': 5}, {'a': 1, 'b': 4}]\n\n >>> problem.addConstraint(lambda a, b: a*2 == b,\n (\"a\", \"b\"))\n >>> problem.getSolutions()\n [{'a': 3, 'b': 6}, {'a': 2, 'b': 4}]\n\n >>> problem = Problem()\n >>> problem.addVariables([\"a\", \"b\"], [1, 2, 3])\n >>> problem.addConstraint(AllDifferentConstraint())\n >>> problem.getSolutions()\n [{'a': 3, 'b': 2}, {'a': 3, 'b': 1}, {'a': 2, 'b': 3},\n {'a': 2, 'b': 1}, {'a': 1, 'b': 2}, {'a': 1, 'b': 3}]\n\nRooks problem\n~~~~~~~~~~~~~\n\nThe following example solves the classical Eight Rooks problem:\n\n.. code-block:: python\n\n >>> problem = Problem()\n >>> numpieces = 8\n >>> cols = range(numpieces)\n >>> rows = range(numpieces)\n >>> problem.addVariables(cols, rows)\n >>> for col1 in cols:\n ... for col2 in cols:\n ... if col1 < col2:\n ... problem.addConstraint(lambda row1, row2: row1 != row2,\n ... (col1, col2))\n >>> solutions = problem.getSolutions()\n >>> solutions\n >>> solutions\n [{0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1, 7: 0},\n {0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 0, 7: 1},\n {0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 1, 6: 2, 7: 0},\n {0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 1, 6: 0, 7: 2},\n ...\n {0: 7, 1: 5, 2: 3, 3: 6, 4: 2, 5: 1, 6: 4, 7: 0},\n {0: 7, 1: 5, 2: 3, 3: 6, 4: 1, 5: 2, 6: 0, 7: 4},\n {0: 7, 1: 5, 2: 3, 3: 6, 4: 1, 5: 2, 6: 4, 7: 0},\n {0: 7, 1: 5, 2: 3, 3: 6, 4: 1, 5: 4, 6: 2, 7: 0},\n {0: 7, 1: 5, 2: 3, 3: 6, 4: 1, 5: 4, 6: 0, 7: 2},\n ...]\n\n\nMagic squares\n~~~~~~~~~~~~~\n\nThis example solves a 4x4 magic square:\n\n.. code-block:: python\n\n >>> problem = Problem()\n >>> problem.addVariables(range(0, 16), range(1, 16 + 1))\n >>> problem.addConstraint(AllDifferentConstraint(), range(0, 16))\n >>> problem.addConstraint(ExactSumConstraint(34), [0, 5, 10, 15])\n >>> problem.addConstraint(ExactSumConstraint(34), [3, 6, 9, 12])\n >>> for row in range(4):\n ... problem.addConstraint(ExactSumConstraint(34),\n [row * 4 + i for i in range(4)])\n >>> for col in range(4):\n ... problem.addConstraint(ExactSumConstraint(34),\n [col + 4 * i for i in range(4)])\n >>> solutions = problem.getSolutions()\n\nFeatures\n--------\n\nThe following solvers are available:\n\n- Backtracking solver\n- Recursive backtracking solver\n- Minimum conflicts solver\n\n\n.. role:: python(code)\n :language: python\n\nPredefined constraint types currently available:\n\n- :python:`FunctionConstraint`\n- :python:`AllDifferentConstraint`\n- :python:`AllEqualConstraint`\n- :python:`ExactSumConstraint`\n- :python:`MaxSumConstraint`\n- :python:`MinSumConstraint`\n- :python:`InSetConstraint`\n- :python:`NotInSetConstraint`\n- :python:`SomeInSetConstraint`\n- :python:`SomeNotInSetConstraint`\n\nAPI documentation\n-----------------\nDocumentation for the module is available at: http://labix.org/doc/constraint/\n\nDownload and install\n--------------------\n\n.. code-block:: shell\n\n $ pip install python-constraint\n\nRoadmap\n-------\n\nThis GitHub organization and repository is a global effort to help to\nmaintain python-constraint which was written by Gustavo Niemeyer\nand originaly located at https://labix.org/python-constraint\n\n- Create some unit tests - DONE\n- Enable continuous integration - DONE\n- Port to Python 3 (Python 2 being also supported) - DONE\n- Respect Style Guide for Python Code (PEP8) - DONE\n- Improve code coverage writting more unit tests - ToDo\n- Move doc to Sphinx or MkDocs - https://readthedocs.org/ - ToDo\n\nContact\n-------\n- `Gustavo Niemeyer `_ \n- `S\u00e9bastien Celles `_ \n\nBut it's probably better to `open an issue `_.\n\n\n.. |Build Status| image:: https://travis-ci.org/python-constraint/python-constraint.svg?branch=master\n :target: https://travis-ci.org/python-constraint/python-constraint\n.. |Code Health| image:: https://landscape.io/github/python-constraint/python-constraint/master/landscape.svg?style=flat\n :target: https://landscape.io/github/python-constraint/python-constraint/master\n :alt: Code Health\n.. |Code Coverage| image:: https://coveralls.io/repos/github/python-constraint/python-constraint/badge.svg\n :target: https://coveralls.io/github/python-constraint/python-constraint", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/python-constraint/python-constraint", "keywords": "csp constraint solving problems problem solver", "license": "", "maintainer": "", "maintainer_email": "", "name": "python-constraint", "package_url": "https://pypi.org/project/python-constraint/", "platform": "", "project_url": "https://pypi.org/project/python-constraint/", "project_urls": { "Homepage": "https://github.com/python-constraint/python-constraint" }, "release_url": "https://pypi.org/project/python-constraint/1.4.0/", "requires_dist": null, "requires_python": "", "summary": "python-constraint is a module implementing support for handling CSPs (Constraint Solving Problems) over finite domain", "version": "1.4.0" }, "last_serial": 4452140, "releases": { "1.0": [], "1.1": [], "1.2": [ { "comment_text": "", "digests": { "md5": "d58de49c85992493db53fcb59b9a0a45", "sha256": "7f6a6bceb1dbe3caebd516e52b2cac20c610640c8344b283763b4015afdf05bd" }, "downloads": -1, "filename": "python-constraint-1.2.tar.bz2", "has_sig": false, "md5_digest": "d58de49c85992493db53fcb59b9a0a45", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14394, "upload_time": "2014-04-04T23:02:59", "url": "https://files.pythonhosted.org/packages/4a/dd/00a20955e01fa91747aa99e0640a8f24eb005b468a4cf4b36ef938804edf/python-constraint-1.2.tar.bz2" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "2d586e1a7c35b099647b5d40d9fdc9b1", "sha256": "5747588df788e4775e92cf9b3b91333d6e5bff7cfcc8c78141510756c686944e" }, "downloads": -1, "filename": "python_constraint-1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2d586e1a7c35b099647b5d40d9fdc9b1", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 26819, "upload_time": "2017-03-31T08:16:54", "url": "https://files.pythonhosted.org/packages/cb/5e/ea5c047c6930780e205a5ea3aeece5fbca24f29c6389d60f6df6855f7c28/python_constraint-1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "94cf874a8ccf1aa2cf1c16797f04e384", "sha256": "539df4fd5d881c3c94e03876b5041fe567f282e9f587bbd339da667aa440ceb7" }, "downloads": -1, "filename": "python-constraint-1.3.tar.bz2", "has_sig": false, "md5_digest": "94cf874a8ccf1aa2cf1c16797f04e384", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18393, "upload_time": "2017-03-31T08:16:51", "url": "https://files.pythonhosted.org/packages/ba/e4/0aff197618fe85ea97acf56f60e43bfae16034ab85ca186c83063ac43fdf/python-constraint-1.3.tar.bz2" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "1478fc6da3bbc6feb02f4e74d18fe7f5", "sha256": "973583372775fe93aa06e1ae5d2ce26458569abd35e7da4eacd1a4bdb4723e6b" }, "downloads": -1, "filename": "python_constraint-1.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1478fc6da3bbc6feb02f4e74d18fe7f5", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 26861, "upload_time": "2017-03-31T08:33:29", "url": "https://files.pythonhosted.org/packages/c7/c7/cd77b2992c565ff70e9cd9b2d29f4b83cc754aab9936f9d1937a980b459c/python_constraint-1.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7fbe98dac30829f3b7595650524505b", "sha256": "936df450be4e535f3499ec9f392f12850855d2f31a15759852bbf54bb4a2e554" }, "downloads": -1, "filename": "python-constraint-1.3.1.tar.bz2", "has_sig": false, "md5_digest": "a7fbe98dac30829f3b7595650524505b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18410, "upload_time": "2017-03-31T08:33:27", "url": "https://files.pythonhosted.org/packages/56/2a/16da19a97dc66c2b8f8df6b8a6fd891a417fb2bb01c14f248e624a5d47c6/python-constraint-1.3.1.tar.bz2" } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "53e4d375d8c84b383d9debf5e517d21b", "sha256": "501d6f17afe0032dfc6ea6c0f8acc12e44f992733f00e8538961031ef27ccb8e" }, "downloads": -1, "filename": "python-constraint-1.4.0.tar.bz2", "has_sig": false, "md5_digest": "53e4d375d8c84b383d9debf5e517d21b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18416, "upload_time": "2018-11-05T09:02:44", "url": "https://files.pythonhosted.org/packages/37/8b/5f1bc2734ca611943e1d6733ee244238679f6410a10cd45ede55a61a8402/python-constraint-1.4.0.tar.bz2" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "53e4d375d8c84b383d9debf5e517d21b", "sha256": "501d6f17afe0032dfc6ea6c0f8acc12e44f992733f00e8538961031ef27ccb8e" }, "downloads": -1, "filename": "python-constraint-1.4.0.tar.bz2", "has_sig": false, "md5_digest": "53e4d375d8c84b383d9debf5e517d21b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18416, "upload_time": "2018-11-05T09:02:44", "url": "https://files.pythonhosted.org/packages/37/8b/5f1bc2734ca611943e1d6733ee244238679f6410a10cd45ede55a61a8402/python-constraint-1.4.0.tar.bz2" } ] }