{"id":4200,"library":"pyomo","title":"Pyomo Optimization Modeling Framework","description":"Pyomo is an open-source Python-based optimization modeling language that allows users to formulate optimization problems in a high-level, object-oriented fashion. It supports a wide range of problem types including linear, mixed-integer, nonlinear, and generalized disjunctive programming. Pyomo provides interfaces to numerous commercial and open-source solvers. It is currently at version 6.10.0 and sees frequent releases with bug fixes, performance enhancements, and new solver interfaces.","status":"active","version":"6.10.0","language":"en","source_language":"en","source_url":"https://github.com/Pyomo/pyomo","tags":["optimization","mathematical programming","modeling","solver","operations research","linear programming","nonlinear programming","mixed-integer programming"],"install":[{"cmd":"pip install pyomo","lang":"bash","label":"Basic installation"},{"cmd":"pip install pyomo[optional_dependency]","lang":"bash","label":"With optional dependencies (e.g., 'ipopt', 'scip', 'glpk_python' for specific solver integrations)"}],"dependencies":[],"imports":[{"note":"While 'from pyomo.environ import *' is often used in examples, 'import pyomo.environ as pyo' is generally preferred for clarity and to avoid polluting the global namespace, especially in larger applications.","wrong":"from pyomo.environ import *","symbol":"pyomo.environ","correct":"import pyomo.environ as pyo"},{"symbol":"ConcreteModel","correct":"model = pyo.ConcreteModel()"},{"symbol":"Var","correct":"model.x = pyo.Var(bounds=(0, 10))"},{"symbol":"Constraint","correct":"model.con = pyo.Constraint(expr=...)"},{"symbol":"Objective","correct":"model.obj = pyo.Objective(expr=..., sense=pyo.maximize)"},{"symbol":"SolverFactory","correct":"solver = pyo.SolverFactory('glpk')"}],"quickstart":{"code":"import pyomo.environ as pyo\n\n# Create a concrete model\nmodel = pyo.ConcreteModel()\n\n# Define variables\nmodel.x = pyo.Var(bounds=(0, 10), within=pyo.Reals)\nmodel.y = pyo.Var(bounds=(0, 10), within=pyo.Reals)\n\n# Define objective function: Maximize x + y\nmodel.obj = pyo.Objective(expr=model.x + model.y, sense=pyo.maximize)\n\n# Define constraints\nmodel.con1 = pyo.Constraint(expr=2*model.x + model.y <= 15)\nmodel.con2 = pyo.Constraint(expr=model.x + 3*model.y <= 20)\n\n# Solve the model (requires a solver, 'glpk' is a common choice)\n# Ensure 'glpk' or another solver is installed and accessible in your system PATH.\n# For example, on Ubuntu: 'sudo apt-get install glpk-utils'\n# On macOS: 'brew install glpk'\n# On Windows: download GLPK binaries and add to PATH.\n\ntry:\n    solver = pyo.SolverFactory('glpk')\n    results = solver.solve(model, tee=False) # tee=True shows solver output\n\n    # Check solver status and print results\n    if (results.solver.status == pyo.SolverStatus.ok) and \\\n       (results.solver.termination_condition == pyo.TerminationCondition.optimal):\n        print(f\"Optimization successful!\")\n        print(f\"Objective value: {pyo.value(model.obj)}\")\n        print(f\"x = {pyo.value(model.x)}\")\n        print(f\"y = {pyo.value(model.y)}\")\n    else:\n        print(f\"Solver did not find an optimal solution. Status: {results.solver.status}, Termination: {results.solver.termination_condition}\")\nexcept Exception as e:\n    print(f\"Error solving model: {e}\")\n    print(\"Please ensure a solver like 'glpk' is installed and configured for Pyomo.\")","lang":"python","description":"This quickstart defines and solves a simple linear programming problem using Pyomo. It demonstrates the creation of a concrete model, defining variables with bounds, an objective function, and constraints. To run this, you need a compatible solver (e.g., GLPK) installed on your system and accessible via Pyomo's SolverFactory."},"warnings":[{"fix":"Upgrade your Python environment to a version officially supported by your Pyomo release. For Pyomo 6.10.0, Python >=3.10 is required.","message":"Pyomo regularly drops support for older Python versions. Pyomo 6.10.0 removes support for Python 3.9. Pyomo 6.9.x removed support for Python 3.8.","severity":"breaking","affected_versions":"6.10.0+ (Python 3.9), 6.9.0+ (Python 3.8)"},{"fix":"Consult the Pyomo documentation for integrating specific solvers. For example, to use GLPK, install 'glpk-utils' (Linux), 'glpk' (macOS via Homebrew), or download Windows binaries and add them to your PATH.","message":"Pyomo itself does NOT include optimization solvers. You must install external solver executables (e.g., GLPK, CBC, Ipopt, Gurobi, CPLEX) on your system and ensure they are in your system's PATH, or configure Pyomo with their specific location.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review and update any code that deeply interacts with Pyomo's internal Constraint object structure. Rely on the public API where possible.","message":"Internal data storage for Constraint objects changed significantly in Pyomo 6.8.0. Code that directly accessed or manipulated internal Constraint attributes might break.","severity":"breaking","affected_versions":"6.8.0+"},{"fix":"Consider explicit, granular imports for production-grade or performance-sensitive applications, especially when `pyomo.environ` contributes to slow model initialization.","message":"While `import pyomo.environ as pyo` is convenient, for very large or performance-critical models, using direct imports from specific submodules (e.g., `from pyomo.core import ConcreteModel, Var`) can improve startup performance by avoiding the overhead of `environ`'s extensive imports.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If your project directly or indirectly relies on `ply`, ensure it is explicitly listed in your project's dependencies.","message":"The hard dependency on `ply` was removed in Pyomo 6.10.0. While not strictly a breaking change for most users, if you were implicitly relying on `ply` being installed alongside Pyomo, you might need to add it as an explicit dependency for your project.","severity":"deprecated","affected_versions":"6.10.0+"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}