{ "info": { "author": "Jeff Hui", "author_email": "jeff@jeffhui.net", "bugtrack_url": null, "classifiers": [], "description": "PyConstraints\n===\n\nA simple, constraints satisfaction problem solver. Used for the [YACS][] course\nscheduler project.\n\n[yacs]: http://github.com/jeffh/yacs\n\nUsage\n-----\n\nThe Problem is the primary interface:\n\n >>> from pyconstraints import Problem\n\nAnd then specify your problem to solve with various constraints:\n\n >>> p = Problem()\n >>> p.add_variable('x', range(4)) # variable-name, domain\n >>> p.add_variable('y', range(4))\n # give constraint function and list of variables used\n >>> p.add_constraint(lambda x, y: x != y, ['x', 'y'])\n >>> p.add_constraint(lambda x: x % 2 == 0)\n\nThen get your solutions:\n\n >>> p.get_solutions()\n # => ({'y': 0, 'x': 2},\n # {'y': 1, 'x': 0},\n # {'y': 1, 'x': 2},\n # {'y': 2, 'x': 0},\n # {'y': 3, 'x': 0},\n # {'y': 3, 'x': 2})\n\nOr iteratively:\n\n >>> p.iter_solutions().next()\n # => {'y': 0, 'x': 2}\n\nAnd that's it!\n\nUsing Another Solver\n--------------------\n\nSimply pass the solver to the Problem constructor:\n\n >>> from pyconstraints import BruteForceSolver, BacktrackingSolver\n >>> p = Problem(BacktrackingSolver()) # BruteForceSolver is default\n\nBecause the BruteForceSolver uses itertools, there may be cases where it is\nfaster than the BacktrackingSolver.\n\n\nWriting Your Own Solver\n-----------------------\n\nFor convinence, there is a ``pyconstraints.SolverInterface`` Abstract-Base Class if you want to\nimplement all the features manually:\n\n @abstractproperty\n def solutions_seen(self):\n \"Returns the number of solutions currently seen by the solver.\"\n\n @abstractproperty\n def solutions_at_points(self):\n \"\"\"Returns a dictionary of {iteration_index: solution} of all known\n solutions while iterating.\n \"\"\"\n\n @abstractmethod\n def set_conditions(self, variables, constraints):\n \"\"\"Called by the Problem class to assign the variables and constraints\n for the problem.\n\n variables = {variable-name: list-of-domain-values}\n constraints = [(constraint_function,\n variable-names,\n default-variable-values)]\n \"\"\"\n\n @abstractmethod\n def restore_point(self, starting_point=None):\n \"Restores the iteration state to a given starting point.\"\n\n @abstractmethod\n def save_point(self):\n \"\"\"Returns data to indicate a way to restore to the current iteration\n point.\n \"\"\"\n\n @abstractmethod\n def __iter__(self):\n \"Yields solutions.\"\n\nBut for convinence, you can inherit from the ``pyconstraints.SolverBase`` class\nwhich provides a primitive implementation for all the interface methods except\nfor ``__iter__`` and ``set_conditions``.\n\n\nTodo\n-----\n\n- Speed up backtracking solver\n- Add more solvers?", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/jeffh/pyconstraints", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "pyconstraints", "package_url": "https://pypi.org/project/pyconstraints/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyconstraints/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/jeffh/pyconstraints" }, "release_url": "https://pypi.org/project/pyconstraints/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "A simple constraints satisfaction solver", "version": "1.0.1" }, "last_serial": 797070, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "17ef14489e2a8fe7079ef244ade71f2a", "sha256": "6ff7d8c57d162bf2438c855ae697d914e0b11d1a911a7da540a665372a7ba523" }, "downloads": -1, "filename": "pyconstraints-1.0.0.zip", "has_sig": false, "md5_digest": "17ef14489e2a8fe7079ef244ade71f2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9317, "upload_time": "2012-08-21T06:32:07", "url": "https://files.pythonhosted.org/packages/84/25/7b8ee563a9b399ef4fc854661d62c3fbf32d5fdb712d29f0a61d2af168c4/pyconstraints-1.0.0.zip" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "4cd5c4aea08f159da1adc2b334767f25", "sha256": "f1980ad47933091f74c87dccec86d91c4919674ab26e0b63b67ea8332430f758" }, "downloads": -1, "filename": "pyconstraints-1.0.1.zip", "has_sig": false, "md5_digest": "4cd5c4aea08f159da1adc2b334767f25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8646, "upload_time": "2012-08-21T06:46:32", "url": "https://files.pythonhosted.org/packages/ce/33/32feb5e770056176adf7b96c4bf5b9d0426be3eee04537eb77fbc005e02a/pyconstraints-1.0.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4cd5c4aea08f159da1adc2b334767f25", "sha256": "f1980ad47933091f74c87dccec86d91c4919674ab26e0b63b67ea8332430f758" }, "downloads": -1, "filename": "pyconstraints-1.0.1.zip", "has_sig": false, "md5_digest": "4cd5c4aea08f159da1adc2b334767f25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8646, "upload_time": "2012-08-21T06:46:32", "url": "https://files.pythonhosted.org/packages/ce/33/32feb5e770056176adf7b96c4bf5b9d0426be3eee04537eb77fbc005e02a/pyconstraints-1.0.1.zip" } ] }