lpsolvers


Namelpsolvers JSON
Version 2.0.0 PyPI version JSON
download
home_pageNone
SummaryLinear programming solvers in Python with a unified API.
upload_time2024-01-09 16:17:57
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords linear programming solver numerical optimization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LP Solvers for Python

[![CI](https://img.shields.io/github/actions/workflow/status/stephane-caron/lpsolvers/test.yml?branch=main)](https://github.com/stephane-caron/lpsolvers/actions)
[![Coverage](https://coveralls.io/repos/github/stephane-caron/lpsolvers/badge.svg?branch=main)](https://coveralls.io/github/stephane-caron/lpsolvers?branch=main)
[![Documentation](https://img.shields.io/github/actions/workflow/status/qpsolvers/qpsolvers/docs.yml?branch=main&label=docs)](https://stephane-caron.github.io/lpsolvers/)
[![PyPI version](https://img.shields.io/pypi/v/lpsolvers)](https://pypi.org/project/lpsolvers/)
![Status](https://img.shields.io/pypi/status/lpsolvers)

Wrapper around Linear Programming (LP) solvers in Python, with a unified interface.

## Installation

To install the library and all available LP solvers at the same time:

```console
$ pip install lpsolvers[open_source_solvers]
```

To install the library only, assuming LP solvers are installed separately: ``pip install lpsolvers``.

## Usage

The function [`solve_lp`](https://stephane-caron.github.io/lpsolvers//linear-programming.html#lpsolvers.solve_lp) is called with the ``solver`` keyword argument to select the backend solver. The linear program it solves is, in standard form:

$$
\begin{split}
\begin{array}{ll}
    \mbox{minimize} &
        c^T x \\
    \mbox{subject to}
        & G x \leq h \\
        & A x = b
\end{array}
\end{split}
$$

Vector inequalities are taken coordinate by coordinate.

## Example

To solve a linear program, build the matrices that define it and call the ``solve_lp`` function:

```python
from numpy import array
from lpsolvers import solve_lp

c = array([1., 2., 3.])
G = array([[1., 2., -1.], [2., 0., 1.], [1., 2., 1.], [-1., -1., -1.]])
h = array([4., 1., 3., 2.])

x = solve_lp(c, G, h, solver="cvxopt")  # select solver here
print(f"LP solution: {x=}")
```

This example outputs the solution ``[2.2, -0.8, -3.4]``.

## Solvers

The list of supported solvers currently includes:

- [cdd](https://github.com/mcmtroffaes/pycddlib)
- [CVXOPT](http://cvxopt.org/)
- [CVXPY](https://www.cvxpy.org/) (interface)
- [PDLP](https://developers.google.com/optimization/lp/pdlp_math)
- [ProxQP](https://github.com/Simple-Robotics/proxsuite#proxqp)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "lpsolvers",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "St\u00e9phane Caron <stephane.caron@normalesup.org>",
    "keywords": "linear programming,solver,numerical optimization",
    "author": null,
    "author_email": "St\u00e9phane Caron <stephane.caron@normalesup.org>",
    "download_url": "https://files.pythonhosted.org/packages/10/3a/c518f5bc28cdbcb02c941efc3c9c798c352cfbeaee3d5622ae2b82c6d4f6/lpsolvers-2.0.0.tar.gz",
    "platform": null,
    "description": "# LP Solvers for Python\n\n[![CI](https://img.shields.io/github/actions/workflow/status/stephane-caron/lpsolvers/test.yml?branch=main)](https://github.com/stephane-caron/lpsolvers/actions)\n[![Coverage](https://coveralls.io/repos/github/stephane-caron/lpsolvers/badge.svg?branch=main)](https://coveralls.io/github/stephane-caron/lpsolvers?branch=main)\n[![Documentation](https://img.shields.io/github/actions/workflow/status/qpsolvers/qpsolvers/docs.yml?branch=main&label=docs)](https://stephane-caron.github.io/lpsolvers/)\n[![PyPI version](https://img.shields.io/pypi/v/lpsolvers)](https://pypi.org/project/lpsolvers/)\n![Status](https://img.shields.io/pypi/status/lpsolvers)\n\nWrapper around Linear Programming (LP) solvers in Python, with a unified interface.\n\n## Installation\n\nTo install the library and all available LP solvers at the same time:\n\n```console\n$ pip install lpsolvers[open_source_solvers]\n```\n\nTo install the library only, assuming LP solvers are installed separately: ``pip install lpsolvers``.\n\n## Usage\n\nThe function [`solve_lp`](https://stephane-caron.github.io/lpsolvers//linear-programming.html#lpsolvers.solve_lp) is called with the ``solver`` keyword argument to select the backend solver. The linear program it solves is, in standard form:\n\n$$\n\\begin{split}\n\\begin{array}{ll}\n    \\mbox{minimize} &\n        c^T x \\\\\n    \\mbox{subject to}\n        & G x \\leq h \\\\\n        & A x = b\n\\end{array}\n\\end{split}\n$$\n\nVector inequalities are taken coordinate by coordinate.\n\n## Example\n\nTo solve a linear program, build the matrices that define it and call the ``solve_lp`` function:\n\n```python\nfrom numpy import array\nfrom lpsolvers import solve_lp\n\nc = array([1., 2., 3.])\nG = array([[1., 2., -1.], [2., 0., 1.], [1., 2., 1.], [-1., -1., -1.]])\nh = array([4., 1., 3., 2.])\n\nx = solve_lp(c, G, h, solver=\"cvxopt\")  # select solver here\nprint(f\"LP solution: {x=}\")\n```\n\nThis example outputs the solution ``[2.2, -0.8, -3.4]``.\n\n## Solvers\n\nThe list of supported solvers currently includes:\n\n- [cdd](https://github.com/mcmtroffaes/pycddlib)\n- [CVXOPT](http://cvxopt.org/)\n- [CVXPY](https://www.cvxpy.org/) (interface)\n- [PDLP](https://developers.google.com/optimization/lp/pdlp_math)\n- [ProxQP](https://github.com/Simple-Robotics/proxsuite#proxqp)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Linear programming solvers in Python with a unified API.",
    "version": "2.0.0",
    "project_urls": {
        "Changelog": "https://github.com/stephane-caron/lpsolvers/blob/main/CHANGELOG.md",
        "Documentation": "https://stephane-caron.github.io/lpsolvers/",
        "Source": "https://github.com/stephane-caron/lpsolvers",
        "Tracker": "https://github.com/stephane-caron/lpsolvers/issues"
    },
    "split_keywords": [
        "linear programming",
        "solver",
        "numerical optimization"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b20090bb9cfacb29d058016498ece3fde40e37eb1a84088e42ef57e77ebb2b92",
                "md5": "94f59b5e8d857a4ffed718c85e6ca83d",
                "sha256": "fffcecd52b7a40b782d9bd98577537d6a0ca98b5c5c37e0af8b32f96deba2406"
            },
            "downloads": -1,
            "filename": "lpsolvers-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "94f59b5e8d857a4ffed718c85e6ca83d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 14039,
            "upload_time": "2024-01-09T16:17:54",
            "upload_time_iso_8601": "2024-01-09T16:17:54.785537Z",
            "url": "https://files.pythonhosted.org/packages/b2/00/90bb9cfacb29d058016498ece3fde40e37eb1a84088e42ef57e77ebb2b92/lpsolvers-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "103ac518f5bc28cdbcb02c941efc3c9c798c352cfbeaee3d5622ae2b82c6d4f6",
                "md5": "1779757cad03ae03903e191c9589e35d",
                "sha256": "aff363e5e59c48b21a1c1da3ec6d010f2b5f6469bcbf4c8a83bb6f23da31656c"
            },
            "downloads": -1,
            "filename": "lpsolvers-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1779757cad03ae03903e191c9589e35d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 18139,
            "upload_time": "2024-01-09T16:17:57",
            "upload_time_iso_8601": "2024-01-09T16:17:57.139253Z",
            "url": "https://files.pythonhosted.org/packages/10/3a/c518f5bc28cdbcb02c941efc3c9c798c352cfbeaee3d5622ae2b82c6d4f6/lpsolvers-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-09 16:17:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "stephane-caron",
    "github_project": "lpsolvers",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "lpsolvers"
}
        
Elapsed time: 0.17065s