PuLP


NamePuLP JSON
Version 3.2.2 PyPI version JSON
download
home_pageNone
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-07-29 11:42:04
maintainerNone
docs_urlNone
authorJ.S. Roy
requires_python>=3.9
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.9 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

::

    python3 -m pip install --upgrade pip
    pip install --group=dev .
    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": null,
    "name": "PuLP",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Franco Peschiera <pchtsp@gmail.com>",
    "keywords": "Optimization, Linear Programming, Operations Research",
    "author": "J.S. Roy",
    "author_email": "\"S.A. Mitchell\" <pulp@stuartmitchell.com>, Franco Peschiera <pchtsp@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b2/4f/11cfa283228b5f259bcfc913f731f7c6f68748d26711594e14cf2cb5e39a/pulp-3.2.2.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.9 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    python3 -m pip install --upgrade pip\n    pip install --group=dev .\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.2.2",
    "project_urls": {
        "download": "https://github.com/coin-or/pulp/archive/master.zip",
        "source": "https://github.com/coin-or/pulp"
    },
    "split_keywords": [
        "optimization",
        " linear programming",
        " operations research"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "158da6a9d58c929a869f7f1b99b3d37b3f14ef63e2826eef581416338d686c3f",
                "md5": "65ab6923a192a50fd5bc4845ebcd3b26",
                "sha256": "d3ca5ff11a28b3e7b2508a992d7e51f3533471d89305f0560b5fe3b6cc821043"
            },
            "downloads": -1,
            "filename": "pulp-3.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "65ab6923a192a50fd5bc4845ebcd3b26",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 16385354,
            "upload_time": "2025-07-29T11:42:01",
            "upload_time_iso_8601": "2025-07-29T11:42:01.829455Z",
            "url": "https://files.pythonhosted.org/packages/15/8d/a6a9d58c929a869f7f1b99b3d37b3f14ef63e2826eef581416338d686c3f/pulp-3.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b24f11cfa283228b5f259bcfc913f731f7c6f68748d26711594e14cf2cb5e39a",
                "md5": "96dae389c0e3db16bb251d9e8f9e5158",
                "sha256": "389a6ff1dc34ec4b093f34f7a9fa3553743ff0ea99b2a423e9f0dd16940f63d2"
            },
            "downloads": -1,
            "filename": "pulp-3.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "96dae389c0e3db16bb251d9e8f9e5158",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 16299367,
            "upload_time": "2025-07-29T11:42:04",
            "upload_time_iso_8601": "2025-07-29T11:42:04.109301Z",
            "url": "https://files.pythonhosted.org/packages/b2/4f/11cfa283228b5f259bcfc913f731f7c6f68748d26711594e14cf2cb5e39a/pulp-3.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-29 11:42:04",
    "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.50266s