{"id":2202,"library":"pulp","title":"PuLP","description":"PuLP is an LP (Linear Programming) modeler written in Python. It simplifies the creation of linear and mixed-integer programming optimization problems, allowing users to define problems using Pythonic syntax. It can generate MPS or LP files and call various open-source (like GLPK, COIN-OR CBC, HiGHS, SCIP) or proprietary (CPLEX, GUROBI, MOSEK, XPRESS) solvers to find optimal solutions. The current version is 3.3.0, and it is actively maintained with regular updates.","status":"active","version":"3.3.0","language":"en","source_language":"en","source_url":"https://github.com/coin-or/pulp","tags":["optimization","linear programming","operations research","MILP","solver"],"install":[{"cmd":"pip install pulp","lang":"bash","label":"Standard Installation"},{"cmd":"pip install pulp[open_py]","lang":"bash","label":"With Open Source Solvers (e.g., HiGHS, SCIP, CyLP)"}],"dependencies":[{"reason":"Optional dependency for using CyLP solver.","package":"cylp","optional":true},{"reason":"Optional dependency for using HiGHS solver.","package":"highspy","optional":true},{"reason":"Optional dependency for using Gurobi solver (requires separate license).","package":"gurobipy","optional":true},{"reason":"Optional dependency for using CPLEX solver (requires separate license).","package":"cplex","optional":true}],"imports":[{"symbol":"LpProblem","correct":"from pulp import LpProblem"},{"symbol":"LpVariable","correct":"from pulp import LpVariable"},{"symbol":"LpMinimize","correct":"from pulp import LpMinimize"},{"symbol":"LpMaximize","correct":"from pulp import LpMaximize"},{"symbol":"lpSum","correct":"from pulp import lpSum"},{"note":"While common in examples for brevity, importing all symbols into the global namespace can lead to name clashes in larger projects. Explicit imports are recommended for clarity and avoiding conflicts.","wrong":"from pulp import *","symbol":"*","correct":"from pulp import LpProblem, LpVariable, LpMinimize, lpSum, LpStatus, value"}],"quickstart":{"code":"from pulp import LpProblem, LpVariable, LpMinimize, lpSum, LpStatus, value\n\n# 1. Create the problem variable, specifying minimization or maximization\nprob = LpProblem(\"My Production Problem\", LpMinimize)\n\n# 2. Define decision variables\nx = LpVariable(\"Product_A\", lowBound=0, cat='Integer')\ny = LpVariable(\"Product_B\", lowBound=0, cat='Integer')\n\n# 3. Define the objective function (e.g., minimize cost)\nprob += 3 * x + 2 * y, \"Total Cost\"\n\n# 4. Define constraints\nprob += 2 * x + y >= 10, \"Minimum Production\"\nprob += x + y <= 12, \"Max Capacity\"\nprob += x >= 4, \"Min Product A\"\n\n# 5. Solve the problem\nstatus = prob.solve()\n\n# 6. Print the results\nprint(f\"Status: {LpStatus[status]}\")\nif LpStatus[status] == \"Optimal\":\n    print(f\"Optimal Total Cost: {value(prob.objective)}\")\n    print(f\"Units of Product A: {value(x)}\")\n    print(f\"Units of Product B: {value(y)}\")\nelse:\n    print(\"No optimal solution found.\")","lang":"python","description":"This quickstart demonstrates how to define and solve a simple integer linear programming problem using PuLP. It covers creating a problem, defining decision variables with bounds and categories, setting an objective function, adding constraints, and finally solving the problem to display the optimal solution and variable values."},"warnings":[{"fix":"Identify required solver; install with `pip install pulp[solver_name]` (e.g., `pip install pulp[highs]`); ensure necessary licenses are acquired for commercial solvers. Refer to PuLP documentation for solver configuration.","message":"PuLP is a modeling library and relies on external solvers to find solutions. While the COIN-OR CBC solver is included by default, other more powerful solvers (like CPLEX, Gurobi, HiGHS, SCIP) require separate installation, often via specific `pip install pulp[solver_name]` commands. Some proprietary solvers also require valid licenses.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For non-linear problems, consider alternative Python optimization libraries such as SciPy's `minimize` for general non-linear optimization or Pyomo for advanced modeling capabilities that extend beyond linearity.","message":"PuLP is designed specifically for Linear Programming (LP) and Mixed-Integer Linear Programming (MILP) problems. It cannot be used to model or solve non-linear optimization problems.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade your Python environment to Python 3.9 or a newer compatible version.","message":"PuLP requires Python 3.9 or newer. Older Python versions are not supported, and attempting to install or run PuLP with them will result in errors.","severity":"breaking","affected_versions":"<3.9"},{"fix":"After installing PuLP, run `sudo pulptest` in your terminal to ensure the default solver is executable. This command is often used to run solver tests, which implicitly checks executability.","message":"On Linux and macOS systems, the default COIN-OR CBC solver (included with PuLP) might require executable permissions to run tests or solve problems. The documentation suggests running `sudo pulptest`.","severity":"gotcha","affected_versions":"All versions on Linux/macOS"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}