# NpyCVX
A small library to connect [numpy](https://numpy.org/) and [CVXOPT](https://cvxopt.org/) together and solves all messy conversions in between.
## Install
```bash
pip install npycvx
```
## Example usage
A simple example when maximizing `w^T x` over the same system of linear inequalities.
```python
import numpy as np
import npycvx
import functools # <- built-in python lib...
# Some dummy data...
A = np.array([
[-1, 1, 1],
[-2,-1,-1]
])
b = np.array([0,-3])
objectives = np.array([
[ 0, 0, 0],
[ 1, 1, 1],
[-1,-1,-1],
[ 1, 0, 1],
])
# Load solve-function with the now converted numpy
# matrices/vectors into cvxopt data type...
solve_part_fn = functools.partial(
npycvx.solve_lp,
*npycvx.convert_numpy(A, b),
False
)
# Exectue each objective with solver function
solutions = list(
map(
solve_part_fn,
objectives
)
)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "npycvx",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "cvxopt, glpk, solver, ilp, integer linear programming",
"author": "znittzel",
"author_email": "rikard@ourstudio.se",
"download_url": "https://files.pythonhosted.org/packages/45/a3/ad745fc09da6f7023c7dc67d5a501ab910522a12fc24059156cd738c7a98/npycvx-0.0.4.tar.gz",
"platform": null,
"description": "# NpyCVX\nA small library to connect [numpy](https://numpy.org/) and [CVXOPT](https://cvxopt.org/) together and solves all messy conversions in between.\n\n## Install\n```bash\npip install npycvx\n```\n\n## Example usage\nA simple example when maximizing `w^T x` over the same system of linear inequalities.\n```python\n\nimport numpy as np\nimport npycvx\nimport functools # <- built-in python lib... \n\n# Some dummy data...\nA = np.array([\n [-1, 1, 1],\n [-2,-1,-1]\n])\nb = np.array([0,-3])\nobjectives = np.array([\n [ 0, 0, 0],\n [ 1, 1, 1],\n [-1,-1,-1],\n [ 1, 0, 1],\n])\n\n# Load solve-function with the now converted numpy\n# matrices/vectors into cvxopt data type...\nsolve_part_fn = functools.partial(\n npycvx.solve_lp, \n *npycvx.convert_numpy(A, b), \n False\n)\n\n# Exectue each objective with solver function\nsolutions = list(\n map(\n solve_part_fn, \n objectives\n )\n)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Converter from numpy to cvxopt.",
"version": "0.0.4",
"project_urls": null,
"split_keywords": [
"cvxopt",
" glpk",
" solver",
" ilp",
" integer linear programming"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "db96c9a2e388d6d5a5a13caaeea81e24e0a929ea564c672c2401ed636a36a5b0",
"md5": "0ce0d84ce361ee5f309a1b3faad82ea7",
"sha256": "2da9a37d47a9229e785b91ecd0dcad0daeb6b57a84ccddecf8db23bc2c625082"
},
"downloads": -1,
"filename": "npycvx-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0ce0d84ce361ee5f309a1b3faad82ea7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 4672,
"upload_time": "2024-10-23T18:34:57",
"upload_time_iso_8601": "2024-10-23T18:34:57.985652Z",
"url": "https://files.pythonhosted.org/packages/db/96/c9a2e388d6d5a5a13caaeea81e24e0a929ea564c672c2401ed636a36a5b0/npycvx-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "45a3ad745fc09da6f7023c7dc67d5a501ab910522a12fc24059156cd738c7a98",
"md5": "353ffae0d26c1b0fbe4fe818533ce418",
"sha256": "ddba97e66a31863b90cf7844d78ac4f3d69e28d3c13cbbf84bac5d256ac708e1"
},
"downloads": -1,
"filename": "npycvx-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "353ffae0d26c1b0fbe4fe818533ce418",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 4187,
"upload_time": "2024-10-23T18:34:59",
"upload_time_iso_8601": "2024-10-23T18:34:59.890457Z",
"url": "https://files.pythonhosted.org/packages/45/a3/ad745fc09da6f7023c7dc67d5a501ab910522a12fc24059156cd738c7a98/npycvx-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-23 18:34:59",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "npycvx"
}