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, and OR-Tools CP-SAT (via the CPSAT API).
The documentation for PuLP can be found here.
PuLP is part of the COIN-OR project.
Note
Upgrading from PuLP 3.x? PuLP 4.0 has breaking changes: variables are
created with prob.add_variable(...), prob.constraints() returns a list,
and prob.solve() returns an LpSolveStats object instead of a status
code. See the guide to migrate from PuLP 3.x to 4.0
(source: doc/source/guides/how_to_migrate_to_v4.rst).
Important
CBC is not shipped inside the PuLP package. Older releases bundled a CBC
binary and exposed it as PULP_CBC_CMD; that API and the bundled solver are
removed. To solve models with CBC through PuLP you should:
- install PuLP with the optional CBC extra:
python -m pip install pulp[cbc](this installs the cbcbox wheel, which provides a CBC executable PuLP can find automatically), or - install a CBC build yourself and ensure the
cbc(orcbc.exeon Windows) executable is on yourPATH,
then use the COIN_CMD solver (or call prob.solve() with no arguments
when CBC is available; otherwise install another solver such as GLPK or pass
an explicit solver). Without CBC or another available solver, the default
solve path will raise PulpError: No solver available.
PuLP requires Python 3.12 or newer.
Recommended: install with CBC support:
python -m pip install pulp[cbc]
Plain python -m pip install pulp installs only the modeler; you must then
supply your own CBC on PATH or another solver.
Otherwise follow the download instructions on the PyPi page.
PuLP can use a variety of solvers. When CBC is available (via pulp[cbc] or
cbc on PATH), COIN_CMD is the usual open-source MIP/LP choice and is
selected as the default ahead of GLPK. PuLP can also install other solvers via
optional PyPI extras (some require a commercial license for running or for large models):