{ "info": { "author": "Brian Schiller", "author_email": "bgschiller@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "\n# Citrus\n\nIntended to work like [PuLP](https://github.com/coin-or/pulp), but with a few convenience functions thrown in.\n\n```\npip install citrus\n```\n\n# Comparisons\n\n## ANDing two variables\n\n```\n# without citrus\nimport pulp\np = pulp.LpProblem('and example', pulp.LpMinimize)\n\nx = pulp.LpVariable('x', cat=pulp.LpBinary)\ny = pulp.LpVariable('y', cat=pulp.LpBinary)\nx_and_y = pulp.LpVariable('x_and_y', cat=pulp.LpBinary)\nmodel.addConstraint(x_and_y >= x + y - 1)\nmodel.addConstraint(x_and_y <= x)\nmodel.addConstraint(x_and_y <= y)\n```\n\n```\n# with citrus\nimport citrus\np = citrus.Problem('and example', pulp.LpMinimize)\n\nx = p.make_var('x', cat=pulp.LpBinary)\ny = p.make_var('y', cat=pulp.LpBinary)\nx_and_y = x & y\n# alternatively, x_and_y = citrus.logical_and(x, y)\n```\n\n## ORing two variables\n\n```\n# without citrus\nimport pulp\np = pulp.LpProblem('or example', pulp.LpMinimize)\n\nx = pulp.LpVariable('x', cat=pulp.LpBinary)\ny = pulp.LpVariable('y', cat=pulp.LpBinary)\nx_or_y = pulp.LpVariable('x_or_y', cat=pulp.LpBinary)\nmodel.addConstraint(x_or_y <= x + y)\nmodel.addConstraint(x_or_y >= x)\nmodel.addConstraint(x_or_y >= y)\n```\n\n```\n# with citrus\nimport citrus\np = citrus.Problem('or example', pulp.LpMinimize)\n\nx = p.make_var('x', cat=pulp.LpBinary)\ny = p.make_var('y', cat=pulp.LpBinary)\nx_or_y = x | y\n# alternatively, x_or_y = citrus.logical_or(x, y)\n```\n\n## Negating a variable\n\n```\n# without citrus\np = pulp.LpProblem('negation test', pulp.LpMinimize)\n\nx = pulp.LpVariable('x', cat=pulp.LpBinary)\nnot_x = pulp.LpVariable('not_x', cat=pulp.LpBinary)\np.addConstraint(not_x == 1 - x)\n```\n\n```\n# With citrus\nimport citrus\np = citrus.Problem('negation test', pulp.LpMinimize)\n\nx = p.make_var('x', cat=pulp.LpBinary)\nnot_x = citrus.negate(x)\n```\n\n# Tips & Tricks\n\nSometimes, you'll have many variables that you want to AND or OR together:\n\n```\np = citrus.Problem('vacation at some point', pulp.Maximize)\n\nvacation_in_x_month = [\n p.make_var('vacation in ' + month, cat=pulp.LpBinary)\n for month in MONTHS\n]\n\ntake_a_vacation = reduce(citrus.logical_or, vacation_in_x_month)\np.addConstraint(take_a_vacation)\n```\n\n# API\n\n## Classes\n\n- `Variable` is a subclass of `pulp.LpVariable`. It adds the following methods:\n - (classmethod) `from_lp_var`. Upgrade a `pulp.LpVariable` to a Variable.\n - `__or__(self, other)` Compute the `logical_or` of two binary `Variable`s\n - `__and__(self, other)` Compute the `logical_and` of two binary `Variable`s\n - `__and__(self, other)` Compute the `logical_and` of two binary `Variable`s\n\n- `Problem` A subclass of `pulp.LpProblem`. It adds the following method\n - `make_var()` accepts same arguments as `pulp.LpVariable`, but produces a `Variable`\n\n## Functions\n\n- `negate(x: Variable)` Produce a new `Variable` with the opposite value of `x`.\n- `logical_and(x: Variable, y: Variable)` Produce a new `Variable` constrained to take on the AND of `x` and `y`.\n- `logical_or(x: Variable, y: Variable)` Produce a new `Variable` constrained to take on the OR of `x` and `y`.\n- `logical_xor(x: Variable, y: Variable)` Produce a new `Variable` constrained to take on the XOR of `x` and `y`.\n- `implies(x: Variable, y: Variable)` Produce a new variable constrained to take on the value of `x => y`\n- `minimum(*xs)` Produce a new `Variable` that can be no larger than the smallest in `xs`\n- `maximum(*xy)` Produce a new `Variable` that can be no smaller than the largest in `xs`\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bgschiller/citrus", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "citrus", "package_url": "https://pypi.org/project/citrus/", "platform": "", "project_url": "https://pypi.org/project/citrus/", "project_urls": { "Homepage": "https://github.com/bgschiller/citrus" }, "release_url": "https://pypi.org/project/citrus/0.0.3/", "requires_dist": [ "pulp" ], "requires_python": ">=3.2.6", "summary": "A more convenient interface to doing Binary Linear Programming with PuLP", "version": "0.0.3" }, "last_serial": 5142238, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "2493831de9c6d52f5bcea516050af18e", "sha256": "8ea111d6768de910e0a80111847782eb9579003baf1d176613a5f2502a224946" }, "downloads": -1, "filename": "citrus-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2493831de9c6d52f5bcea516050af18e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.2.6", "size": 4988, "upload_time": "2018-06-02T20:55:41", "url": "https://files.pythonhosted.org/packages/7b/77/1ed05cec6c2de50825bab3e9e4c4af77d3720b258625ee95106d33cc9cf5/citrus-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e260204bdd40c623b0d1a92145176b9", "sha256": "fbfcc20540560cd186521f94096fe289da900fb455dadccabe343213af19a90e" }, "downloads": -1, "filename": "citrus-0.0.1.tar.gz", "has_sig": false, "md5_digest": "3e260204bdd40c623b0d1a92145176b9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.2.6", "size": 6061, "upload_time": "2018-06-02T20:55:42", "url": "https://files.pythonhosted.org/packages/3c/b2/526fbd1501fb620cef9d6439eb97531a6d2f521daef09eb1257108547992/citrus-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "3e73f9a346b53bd69e6fb75959a4bfb8", "sha256": "a41864399506577ab40ac62a4286d75b70d7e1b7c5951e3599917162cb75c999" }, "downloads": -1, "filename": "citrus-0.0.2-py2.7.egg", "has_sig": false, "md5_digest": "3e73f9a346b53bd69e6fb75959a4bfb8", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": ">=3.2.6", "size": 8255, "upload_time": "2019-04-14T23:13:38", "url": "https://files.pythonhosted.org/packages/7e/1f/76c2f607a3a63a336ac301b7c9d87739dfb0ba8a50ff94d8893fcef0058e/citrus-0.0.2-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "f94188a8ac13afbde6ba82f4556ed39f", "sha256": "3e6a82e5f35a24f0b8bc3ec1e3bc55a8b508435f405e60227d4201b5ce05b209" }, "downloads": -1, "filename": "citrus-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "f94188a8ac13afbde6ba82f4556ed39f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.2.6", "size": 5002, "upload_time": "2019-01-27T20:58:55", "url": "https://files.pythonhosted.org/packages/a9/d9/4a047839bdc1d702b532d054d5c196949bd39ef641a0f1547f5a3739254c/citrus-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0836d600d28a3ebfee5a21577e36901b", "sha256": "75e6fee9e4c5b29c1a49499731007917772f9d0d1942cd3fbfbe05d962d6c4b8" }, "downloads": -1, "filename": "citrus-0.0.2.tar.gz", "has_sig": false, "md5_digest": "0836d600d28a3ebfee5a21577e36901b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.2.6", "size": 6038, "upload_time": "2019-01-27T20:59:52", "url": "https://files.pythonhosted.org/packages/dd/c9/7b63d4e65c8f0e355ef54776c1944be39a2414c5a4fb5e1da0bd243127e6/citrus-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "a81b7804623b156a247a3b3ae57f1ee7", "sha256": "563c1c6053176ca75b1152635a2f8484ae13e6674f218fdd500d8a71e4bc21be" }, "downloads": -1, "filename": "citrus-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "a81b7804623b156a247a3b3ae57f1ee7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.2.6", "size": 6299, "upload_time": "2019-04-14T23:13:37", "url": "https://files.pythonhosted.org/packages/24/2a/bf3795e34e867bea77a027301ecc06b59eacb006829a17360e1da94421ec/citrus-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a54dabf1e38ee1dc1d096a4020435979", "sha256": "a0842a7ecb6292545f39e6167261d4a761aeed968d316b66e93665396e4e69f9" }, "downloads": -1, "filename": "citrus-0.0.3.tar.gz", "has_sig": false, "md5_digest": "a54dabf1e38ee1dc1d096a4020435979", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.2.6", "size": 6521, "upload_time": "2019-04-14T23:13:40", "url": "https://files.pythonhosted.org/packages/27/5b/dff6a9af25d031fa22d5487e33e2468137ae0df0fe6989a10f184e19b90f/citrus-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a81b7804623b156a247a3b3ae57f1ee7", "sha256": "563c1c6053176ca75b1152635a2f8484ae13e6674f218fdd500d8a71e4bc21be" }, "downloads": -1, "filename": "citrus-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "a81b7804623b156a247a3b3ae57f1ee7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.2.6", "size": 6299, "upload_time": "2019-04-14T23:13:37", "url": "https://files.pythonhosted.org/packages/24/2a/bf3795e34e867bea77a027301ecc06b59eacb006829a17360e1da94421ec/citrus-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a54dabf1e38ee1dc1d096a4020435979", "sha256": "a0842a7ecb6292545f39e6167261d4a761aeed968d316b66e93665396e4e69f9" }, "downloads": -1, "filename": "citrus-0.0.3.tar.gz", "has_sig": false, "md5_digest": "a54dabf1e38ee1dc1d096a4020435979", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.2.6", "size": 6521, "upload_time": "2019-04-14T23:13:40", "url": "https://files.pythonhosted.org/packages/27/5b/dff6a9af25d031fa22d5487e33e2468137ae0df0fe6989a10f184e19b90f/citrus-0.0.3.tar.gz" } ] }