pulp

A python Linear Programming API

https://github.com/coin-or/pulp

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    3 of 99 committers (3.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.0%) to scientific vocabulary

Keywords

constraints mip pulp python solver

Keywords from Contributors

mathematical-programming mesh distributed closember profiles sequences standardization genomics interactive embedded
Last synced: 6 months ago · JSON representation

Repository

A python Linear Programming API

Basic Info
Statistics
  • Stars: 2,314
  • Watchers: 69
  • Forks: 414
  • Open Issues: 89
  • Releases: 13
Topics
constraints mip pulp python solver
Created almost 11 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing Funding License Authors

README.rst

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 `_.

PuLP is part of the `COIN-OR project `_. 

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 `_.

Installing solvers
----------------------

PuLP can use a variety of solvers. The default solver is the COIN-OR CBC solver, which is included with PuLP. If you want to use other solvers, PuLP offers a quick way to install most solvers via their pypi package (some require a commercial license for running or for running large models)::

    python -m pip install pulp[gurobi]
    python -m pip install pulp[cplex]
    python -m pip install pulp[xpress]
    python -m pip install pulp[scip]
    python -m pip install pulp[highs]
    python -m pip install pulp[copt]
    python -m pip install pulp[mosek]
    python -m pip install pulp[cylp]


If you want to install all open source solvers (scip, highs, cylp), you can use the shortcut::
    python -m pip install pulp[open_py]

For more information on how to install solvers, see the `guide on configuring solvers `_.

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 `_ and pure code examples are available in `examples/ directory `_ .

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 `_.


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 `_.  We recommended using a
`virtual environment `_ 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 `_.

**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

Owner

  • Name: COIN-OR Foundation
  • Login: coin-or
  • Kind: organization
  • Email: info@coin-or.org
  • Location: United States of America

Computational Infrastructure for Operations Research.

GitHub Events

Total
  • Create event: 17
  • Release event: 1
  • Issues event: 47
  • Watch event: 220
  • Delete event: 6
  • Issue comment event: 217
  • Push event: 89
  • Pull request review comment event: 67
  • Pull request event: 92
  • Pull request review event: 63
  • Fork event: 29
Last Year
  • Create event: 17
  • Release event: 1
  • Issues event: 47
  • Watch event: 220
  • Delete event: 6
  • Issue comment event: 217
  • Push event: 89
  • Pull request review comment event: 67
  • Pull request event: 92
  • Pull request review event: 63
  • Fork event: 29

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 411
  • Total Committers: 99
  • Avg Commits per committer: 4.152
  • Development Distribution Score (DDS): 0.706
Past Year
  • Commits: 50
  • Committers: 18
  • Avg Commits per committer: 2.778
  • Development Distribution Score (DDS): 0.7
Top Committers
Name Email Commits
Franco Peschiera p****p@g****m 121
Stuart Mitchell s****u@s****m 86
Stuart Mitchell hg@s****m 32
Matthew Bradbury M****y 11
Christophe-Marie Duquesne c****e@g****m 10
Frederick Robinson f****n@f****m 8
Ryan J. O'Neil r****l@g****m 7
Ewout ter Hoeven E****n@s****l 6
Antony Phillips a****s@g****m 5
tgmath t****t@g****m 5
Guillermo González-Santander de la Cruz g****z@b****s 4
Will Usher w****r@k****e 4
Rachel 3****o 4
Daniel Junglas 5****s 4
Utkarsh Detha u****a@g****m 3
dependabot[bot] 4****] 3
sudermn n****n@b****m 3
Christian Wassermann c****n@w****e 2
Michael Behrisch o****s@b****e 2
fjc f****f@g****m 2
William Pettersson w****m@e****e 2
Thiago Jobson t****n 2
Maciej m****j@w****m 2
Oleh Prypin o****h@p****n 2
Sam Mathew s****t 2
David GG 3****y 2
Fang Yu Hsueh 3****A 2
Toby Davies t****s@b****m 2
pchtsp f****a@g****m 2
smit023 s****3@g****r 2
and 69 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 150
  • Total pull requests: 205
  • Average time to close issues: 8 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 120
  • Total pull request authors: 63
  • Average comments per issue: 2.57
  • Average comments per pull request: 2.02
  • Merged pull requests: 138
  • Bot issues: 0
  • Bot pull requests: 5
Past Year
  • Issues: 27
  • Pull requests: 93
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 9 days
  • Issue authors: 23
  • Pull request authors: 21
  • Average comments per issue: 3.44
  • Average comments per pull request: 1.39
  • Merged pull requests: 60
  • Bot issues: 0
  • Bot pull requests: 3
Top Authors
Issue Authors
  • davidggphy (5)
  • simon-b (4)
  • tle4336 (3)
  • WPettersson (3)
  • yurivict (3)
  • torressa (2)
  • s-u-m-a-n-t-h (2)
  • christiansegercrantz (2)
  • musicinmybrain (2)
  • pchtsp (2)
  • dbokal (2)
  • zxt5 (2)
  • GoogleCodeExporter (2)
  • vladimirvalenta (2)
  • kaijing-zhang (2)
Pull Request Authors
  • pchtsp (39)
  • MBradbury (29)
  • frrad (17)
  • G-Carneiro (7)
  • aphi (7)
  • EwoutH (6)
  • Iroy30 (5)
  • dependabot[bot] (5)
  • WPettersson (4)
  • ggsdc (4)
  • pepeleduin (4)
  • djunglas (4)
  • jebob (3)
  • rutger-van-beek-cqm (3)
  • davidggphy (3)
Top Labels
Issue Labels
Type-Defect (2) Priority-Medium (2) auto-migrated (2) good first issue (2) help wanted (1) enhancement (1) docs (1)
Pull Request Labels
dependencies (5) github_actions (3)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 2,854,167 last-month
  • Total docker downloads: 128
  • Total dependent packages: 124
    (may contain duplicates)
  • Total dependent repositories: 689
    (may contain duplicates)
  • Total versions: 59
  • Total maintainers: 4
pypi.org: pulp

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.

  • Versions: 49
  • Dependent Packages: 115
  • Dependent Repositories: 639
  • Downloads: 2,854,167 Last month
  • Docker Downloads: 128
Rankings
Dependent packages count: 0.2%
Downloads: 0.4%
Dependent repos count: 0.5%
Average: 1.5%
Stargazers count: 1.7%
Forks count: 2.7%
Docker downloads count: 3.8%
Maintainers (3)
Last synced: 6 months ago
conda-forge.org: pulp
  • Versions: 8
  • Dependent Packages: 8
  • Dependent Repositories: 50
Rankings
Dependent repos count: 5.1%
Dependent packages count: 7.1%
Average: 7.8%
Forks count: 9.2%
Stargazers count: 9.9%
Last synced: 7 months ago
spack.io: py-pulp

PuLP is an LP modeler written in Python. PuLP can generate MPS or LP files and call GLPK, COIN-OR CLP/CBC, CPLEX, GUROBI, MOSEK, XPRESS, CHOCO, MIPCL, SCIP to solve linear problems.

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Forks count: 5.2%
Stargazers count: 5.8%
Average: 9.8%
Dependent packages count: 28.1%
Maintainers (1)
Last synced: 6 months ago
anaconda.org: pulp

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.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 42.3%
Average: 44.4%
Dependent repos count: 46.5%
Last synced: 6 months ago

Dependencies

.github/workflows/build_docs.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • ad-m/github-push-action master composite
.github/workflows/publish-to-test-pypi.yml actions
  • actions/checkout master composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/pythonpackage.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite