PuLP


NamePuLP JSON
Version 3.0.1 PyPI version JSON
download
home_pagehttps://github.com/coin-or/pulp
SummaryPuLP is an LP modeler written in python. PuLP can generate MPS or LP files and call GLPK, COIN CLP/CBC, CPLEX, and GUROBI to solve linear problems.
upload_time2025-02-20 11:39:39
maintainerNone
docs_urlNone
authorJ.S. Roy and S.A. Mitchell and F. Peschiera
requires_python>=3.7
licenseMIT
keywords optimization linear programming operations research
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pulp
**************************

.. image:: https://travis-ci.org/coin-or/pulp.svg?branch=master
    :target: https://travis-ci.org/coin-or/pulp
.. image:: https://img.shields.io/pypi/v/pulp
    :target: https://pypi.org/project/PuLP/
    :alt: PyPI
.. image:: https://img.shields.io/pypi/dm/pulp
    :target: https://pypi.org/project/PuLP/
    :alt: PyPI - Downloads

PuLP is an linear and mixed integer programming modeler written in Python. With PuLP, it is simple to create MILP optimisation problems and solve them with the latest open-source (or proprietary) solvers.  PuLP can generate MPS or LP files and call solvers such as GLPK_, COIN-OR CLP/`CBC`_, CPLEX_, GUROBI_, MOSEK_, XPRESS_, CHOCO_, MIPCL_, HiGHS_, SCIP_/FSCIP_.

The documentation for PuLP can be `found here <https://coin-or.github.io/pulp/>`_.

PuLP is part of the `COIN-OR project <https://www.coin-or.org/>`_. 

Installation
================

PuLP requires Python 3.7 or newer.

The easiest way to install PuLP is with ``pip``. If ``pip`` is available on your system, type::

     python -m pip install pulp

Otherwise follow the download instructions on the `PyPi page <https://pypi.python.org/pypi/PuLP>`_.


Quickstart 
===============

Use ``LpVariable`` to create new variables. To create a variable x with 0  ≤  x  ≤  3::

     from pulp import *
     x = LpVariable("x", 0, 3)

To create a binary variable, y, with values either 0 or 1::

     y = LpVariable("y", cat="Binary")

Use ``LpProblem`` to create new problems. Create a problem called "myProblem" like so::

     prob = LpProblem("myProblem", LpMinimize)

Combine variables in order to create expressions and constraints, and then add them to the problem.::

     prob += x + y <= 2

An expression is a constraint without a right-hand side (RHS) sense (one of ``=``, ``<=`` or ``>=``). If you add an expression to a problem, it will become the objective::

     prob += -4*x + y

To solve the problem  with the default included solver::

     status = prob.solve()

If you want to try another solver to solve the problem::

     status = prob.solve(GLPK(msg = 0))

Display the status of the solution::

     LpStatus[status]
     > 'Optimal'

You can get the value of the variables using ``value``. ex::

     value(x)
     > 2.0


Essential Classes
------------------


* ``LpProblem`` -- Container class for a Linear or Integer programming problem
* ``LpVariable`` -- Variables that are added into constraints in the LP problem
* ``LpConstraint`` -- Constraints of the general form

      a1x1 + a2x2 + ... + anxn (<=, =, >=) b

* ``LpConstraintVar`` -- A special type of constraint for constructing column of the model in column-wise modelling

Useful Functions
------------------

* ``value()`` -- Finds the value of a variable or expression
* ``lpSum()`` -- Given a list of the form [a1*x1, a2*x2, ..., an*xn] will construct a linear expression to be used as a constraint or variable
* ``lpDot()`` -- Given two lists of the form [a1, a2, ..., an] and [x1, x2, ..., xn] will construct a linear expression to be used as a constraint or variable

More Examples
================

Several tutorial are given in `documentation <https://coin-or.github.io/pulp/CaseStudies/index.html>`_ and pure code examples are available in `examples/ directory <https://github.com/coin-or/pulp/tree/master/examples>`_ .

The examples use the default solver (CBC). To use other solvers they must be available (installed and accessible). For more information on how to do that, see the `guide on configuring solvers <https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html>`_.


For Developers 
================


If you want to install the latest version from GitHub you can run::

    python -m pip install -U git+https://github.com/coin-or/pulp


On Linux and MacOS systems, you must run the tests to make the default solver executable::

     sudo pulptest




Building the documentation
--------------------------

The PuLP documentation is built with `Sphinx <https://www.sphinx-doc.org>`_.  We recommended using a
`virtual environment <https://docs.python.org/3/library/venv.html>`_ to build the documentation locally.

To build, run the following in a terminal window, in the PuLP root directory

::

    cd pulp
    python -m pip install -r requirements-dev.txt
    cd doc
    make html

A folder named html will be created inside the ``build/`` directory.
The home page for the documentation is ``doc/build/html/index.html`` which can be opened in a browser.

Contributing to PuLP
-----------------------
Instructions for making your first contribution to PuLP are given `here <https://coin-or.github.io/pulp/develop/contribute.html>`_.

**Comments, bug reports, patches and suggestions are very welcome!**

* Comments and suggestions: https://github.com/coin-or/pulp/discussions
* Bug reports: https://github.com/coin-or/pulp/issues
* Patches: https://github.com/coin-or/pulp/pulls

Copyright and License 
=======================
PuLP is distributed under an MIT license. 

     Copyright J.S. Roy, 2003-2005
     Copyright Stuart A. Mitchell
     See the LICENSE file for copyright information.

.. _Python: http://www.python.org/

.. _GLPK: http://www.gnu.org/software/glpk/glpk.html
.. _CBC: https://github.com/coin-or/Cbc
.. _CPLEX: http://www.cplex.com/
.. _GUROBI: http://www.gurobi.com/
.. _MOSEK: https://www.mosek.com/
.. _XPRESS: https://www.fico.com/es/products/fico-xpress-solver
.. _CHOCO: https://choco-solver.org/
.. _MIPCL: http://mipcl-cpp.appspot.com/
.. _SCIP: https://www.scipopt.org/
.. _HiGHS: https://highs.dev
.. _FSCIP: https://ug.zib.de

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/coin-or/pulp",
    "name": "PuLP",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "Optimization, Linear Programming, Operations Research",
    "author": "J.S. Roy and S.A. Mitchell and F. Peschiera",
    "author_email": "pulp@stuartmitchell.com",
    "download_url": "https://files.pythonhosted.org/packages/5b/49/3a9857ac419b48130e2591c9db6e03deee80e9fdd8e9fb0618ea02f41860/pulp-3.0.1.tar.gz",
    "platform": null,
    "description": "pulp\n**************************\n\n.. image:: https://travis-ci.org/coin-or/pulp.svg?branch=master\n    :target: https://travis-ci.org/coin-or/pulp\n.. image:: https://img.shields.io/pypi/v/pulp\n    :target: https://pypi.org/project/PuLP/\n    :alt: PyPI\n.. image:: https://img.shields.io/pypi/dm/pulp\n    :target: https://pypi.org/project/PuLP/\n    :alt: PyPI - Downloads\n\nPuLP is an linear and mixed integer programming modeler written in Python. With PuLP, it is simple to create MILP optimisation problems and solve them with the latest open-source (or proprietary) solvers.  PuLP can generate MPS or LP files and call solvers such as GLPK_, COIN-OR CLP/`CBC`_, CPLEX_, GUROBI_, MOSEK_, XPRESS_, CHOCO_, MIPCL_, HiGHS_, SCIP_/FSCIP_.\n\nThe documentation for PuLP can be `found here <https://coin-or.github.io/pulp/>`_.\n\nPuLP is part of the `COIN-OR project <https://www.coin-or.org/>`_. \n\nInstallation\n================\n\nPuLP requires Python 3.7 or newer.\n\nThe easiest way to install PuLP is with ``pip``. If ``pip`` is available on your system, type::\n\n     python -m pip install pulp\n\nOtherwise follow the download instructions on the `PyPi page <https://pypi.python.org/pypi/PuLP>`_.\n\n\nQuickstart \n===============\n\nUse ``LpVariable`` to create new variables. To create a variable x with 0  \u2264  x  \u2264  3::\n\n     from pulp import *\n     x = LpVariable(\"x\", 0, 3)\n\nTo create a binary variable, y, with values either 0 or 1::\n\n     y = LpVariable(\"y\", cat=\"Binary\")\n\nUse ``LpProblem`` to create new problems. Create a problem called \"myProblem\" like so::\n\n     prob = LpProblem(\"myProblem\", LpMinimize)\n\nCombine variables in order to create expressions and constraints, and then add them to the problem.::\n\n     prob += x + y <= 2\n\nAn expression is a constraint without a right-hand side (RHS) sense (one of ``=``, ``<=`` or ``>=``). If you add an expression to a problem, it will become the objective::\n\n     prob += -4*x + y\n\nTo solve the problem  with the default included solver::\n\n     status = prob.solve()\n\nIf you want to try another solver to solve the problem::\n\n     status = prob.solve(GLPK(msg = 0))\n\nDisplay the status of the solution::\n\n     LpStatus[status]\n     > 'Optimal'\n\nYou can get the value of the variables using ``value``. ex::\n\n     value(x)\n     > 2.0\n\n\nEssential Classes\n------------------\n\n\n* ``LpProblem`` -- Container class for a Linear or Integer programming problem\n* ``LpVariable`` -- Variables that are added into constraints in the LP problem\n* ``LpConstraint`` -- Constraints of the general form\n\n      a1x1 + a2x2 + ... + anxn (<=, =, >=) b\n\n* ``LpConstraintVar`` -- A special type of constraint for constructing column of the model in column-wise modelling\n\nUseful Functions\n------------------\n\n* ``value()`` -- Finds the value of a variable or expression\n* ``lpSum()`` -- Given a list of the form [a1*x1, a2*x2, ..., an*xn] will construct a linear expression to be used as a constraint or variable\n* ``lpDot()`` -- Given two lists of the form [a1, a2, ..., an] and [x1, x2, ..., xn] will construct a linear expression to be used as a constraint or variable\n\nMore Examples\n================\n\nSeveral tutorial are given in `documentation <https://coin-or.github.io/pulp/CaseStudies/index.html>`_ and pure code examples are available in `examples/ directory <https://github.com/coin-or/pulp/tree/master/examples>`_ .\n\nThe examples use the default solver (CBC). To use other solvers they must be available (installed and accessible). For more information on how to do that, see the `guide on configuring solvers <https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html>`_.\n\n\nFor Developers \n================\n\n\nIf you want to install the latest version from GitHub you can run::\n\n    python -m pip install -U git+https://github.com/coin-or/pulp\n\n\nOn Linux and MacOS systems, you must run the tests to make the default solver executable::\n\n     sudo pulptest\n\n\n\n\nBuilding the documentation\n--------------------------\n\nThe PuLP documentation is built with `Sphinx <https://www.sphinx-doc.org>`_.  We recommended using a\n`virtual environment <https://docs.python.org/3/library/venv.html>`_ to build the documentation locally.\n\nTo build, run the following in a terminal window, in the PuLP root directory\n\n::\n\n    cd pulp\n    python -m pip install -r requirements-dev.txt\n    cd doc\n    make html\n\nA folder named html will be created inside the ``build/`` directory.\nThe home page for the documentation is ``doc/build/html/index.html`` which can be opened in a browser.\n\nContributing to PuLP\n-----------------------\nInstructions for making your first contribution to PuLP are given `here <https://coin-or.github.io/pulp/develop/contribute.html>`_.\n\n**Comments, bug reports, patches and suggestions are very welcome!**\n\n* Comments and suggestions: https://github.com/coin-or/pulp/discussions\n* Bug reports: https://github.com/coin-or/pulp/issues\n* Patches: https://github.com/coin-or/pulp/pulls\n\nCopyright and License \n=======================\nPuLP is distributed under an MIT license. \n\n     Copyright J.S. Roy, 2003-2005\n     Copyright Stuart A. Mitchell\n     See the LICENSE file for copyright information.\n\n.. _Python: http://www.python.org/\n\n.. _GLPK: http://www.gnu.org/software/glpk/glpk.html\n.. _CBC: https://github.com/coin-or/Cbc\n.. _CPLEX: http://www.cplex.com/\n.. _GUROBI: http://www.gurobi.com/\n.. _MOSEK: https://www.mosek.com/\n.. _XPRESS: https://www.fico.com/es/products/fico-xpress-solver\n.. _CHOCO: https://choco-solver.org/\n.. _MIPCL: http://mipcl-cpp.appspot.com/\n.. _SCIP: https://www.scipopt.org/\n.. _HiGHS: https://highs.dev\n.. _FSCIP: https://ug.zib.de\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PuLP is an LP modeler written in python. PuLP can generate MPS or LP files and call GLPK, COIN CLP/CBC, CPLEX, and GUROBI to solve linear problems.",
    "version": "3.0.1",
    "project_urls": {
        "Homepage": "https://github.com/coin-or/pulp"
    },
    "split_keywords": [
        "optimization",
        " linear programming",
        " operations research"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3ec2a9cac7ac2d51a94a80b53c07df51b9306afee810286a460571477168debc",
                "md5": "d0c43754cf5fa9e18d3a3985a2cb7602",
                "sha256": "ee5c3aa431fb786d108a7fae4561334337aaee005c16ecadcf4201b96fd8df01"
            },
            "downloads": -1,
            "filename": "PuLP-3.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d0c43754cf5fa9e18d3a3985a2cb7602",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17689346,
            "upload_time": "2025-02-20T11:39:35",
            "upload_time_iso_8601": "2025-02-20T11:39:35.165015Z",
            "url": "https://files.pythonhosted.org/packages/3e/c2/a9cac7ac2d51a94a80b53c07df51b9306afee810286a460571477168debc/PuLP-3.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5b493a9857ac419b48130e2591c9db6e03deee80e9fdd8e9fb0618ea02f41860",
                "md5": "139aaa0707d6ab5046dc78146f47f983",
                "sha256": "5e367830f544a954a3920f5ae28bd45955197b85b3bcd7a367b1bc3c932a11c4"
            },
            "downloads": -1,
            "filename": "pulp-3.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "139aaa0707d6ab5046dc78146f47f983",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 17618607,
            "upload_time": "2025-02-20T11:39:39",
            "upload_time_iso_8601": "2025-02-20T11:39:39.666527Z",
            "url": "https://files.pythonhosted.org/packages/5b/49/3a9857ac419b48130e2591c9db6e03deee80e9fdd8e9fb0618ea02f41860/pulp-3.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-20 11:39:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "coin-or",
    "github_project": "pulp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pulp"
}
        
Elapsed time: 0.56551s