Written and maintained by CASRAI Editorial Board
Published
On this page
Pyomo is an open-source Python language for expressing optimization models as variables, objectives and constraints. It builds a mathematical problem for a separate solver. For research, the useful distinction is between the equations you specify, the data you supply and the solver result you can actually justify.
Definition and scope
The Pyomo project describes a modelling environment embedded in Python: a researcher can define symbolic problems, construct particular instances and analyse them through commercial or open-source solvers. Its published capabilities include linear, quadratic and nonlinear programming, mixed-integer models, stochastic programming, generalized disjunctive programming and differential algebraic equations. Those are supported modelling categories, not a promise that one solver handles every formulation.
An algebraic model makes the decision explicit. Variables represent quantities whose values are sought; constraints express admissible relationships; an objective defines what to minimize or maximize. Data and assumptions determine the particular problem. Keeping those roles separate makes a model easier to inspect than a result reported only as a final number.
Within chemical engineering research, this distinction connects a physical description to a computational question. A balance equation describes a relationship; an optimization model additionally identifies which quantities may change and what outcome is being sought. Pyomo supplies the modelling vocabulary. The physical interpretation and the adequacy of the equations remain responsibilities of the research team.
How Pyomo works in practice
Model structure, data and decision variables
The official Simple Models documentation demonstrates ConcreteModel and AbstractModel. A concrete model constructs components using data available during construction. An abstract model describes a structure that can be instantiated with data. The documentation emphasizes that both approaches can support flexible behaviour; this is a distinction in construction, rather than a ranking of scientific quality.
Its basic vocabulary includes Set for indexes, Param for model data, Var for decision quantities, Objective for the expression to optimize and Constraint for restrictions. Indexed components express repeated relationships without writing each equation separately. For example, an index can distinguish streams or experimental conditions while one rule generates the corresponding constraints.
The Variables reference distinguishes a domain, bounds and initial values. Bounds specify lower and upper limits, while the domain identifies the allowed set of values. An initial value supplies a starting point, which the documentation highlights as particularly important for nonlinear models. These inputs communicate different assumptions and should be described separately in a research record.
Installation and the solver boundary
The project’s installation page provides pip and conda commands:
pip install pyomo
conda install -c conda-forge pyomo
These are alternative installation routes. The same page explicitly states that Pyomo includes no standalone optimization solvers; a local analysis generally needs a separately installed solver. It also identifies Pyomo’s BSD licence. Installing the modelling package and arranging access to a compatible solver are therefore separate environment tasks.
A successful Python import demonstrates availability of the modelling package. It does not demonstrate that the selected solver executable exists or that the mathematical formulation is appropriate for that solver. The Solver Recipes documentation shows how to supply an executable path when the solver cannot be found through the usual path lookup.
Worked example: a two-feed balance
This is an illustrative composite with invented, dimensionless inputs, not a measured laboratory dataset or an operating recommendation. Suppose two nonnegative feed quantities, A and B, must sum to 10. Their hypothetical contributions to a quality balance are 0.2 and 0.8 per unit. The combined contribution must be at least 5. Define an arbitrary objective score of 3A + 5B and minimize it.
The example adapts the documented concrete-model pattern while using different equations. The complete formulation contains a total balance, a quality restriction and nonnegative variable domains:
import pyomo.environ as pyo
model = pyo.ConcreteModel()
model.A = pyo.Var(domain=pyo.NonNegativeReals)
model.B = pyo.Var(domain=pyo.NonNegativeReals)
model.total = pyo.Constraint(expr=model.A + model.B == 10)
model.quality = pyo.Constraint(expr=0.2 * model.A + 0.8 * model.B >= 5)
model.score = pyo.Objective(
expr=3 * model.A + 5 * model.B,
sense=pyo.minimize,
)
The arithmetic provides an independent check. Substituting A = 10 − B into the quality constraint gives 2 + 0.6B ≥ 5, so B ≥ 5. Nonnegativity of A also requires B ≤ 10. The objective becomes 30 + 2B, which increases as B increases. Thus the minimum occurs at B = 5 and A = 5, with an objective score of 40. Both the total balance and the quality constraint are satisfied exactly.
Now imagine a second hypothetical scenario that limits B to 4. At B = 4, the total balance forces A = 6 and the quality contribution is only 4.4. Because the contribution increases with B along the total balance, no smaller B can meet the threshold either. The changed model is infeasible. A previous result of A = 5, B = 5 would violate the new bound, even if those values remained visible in a notebook.
The balance also gives a simple sensitivity check: replacing the quality threshold of 5 by q requires B ≥ (q − 2)/0.6, together with 0 ≤ B ≤ 10. A threshold greater than 8 is impossible under these assumptions. This is a property of the illustrative equations, not a general feed specification.
This small example separates three checks: whether the equations express the intended assumptions, whether the returned values satisfy those equations and whether the objective is minimized. A solver result can be compared with the hand calculation here because the problem is deliberately small. The same arithmetic does not establish the accuracy of a real process model with additional physics.
Checking a solve before loading values
With GLPK installed and available, this continuation uses the documented Solver Recipes pattern. It requests a result without automatically loading a solution, then loads values only after the expected status and termination condition:
from pyomo.opt import SolverStatus, TerminationCondition
solver = pyo.SolverFactory("glpk")
results = solver.solve(model, load_solutions=False, tee=True)
if (
results.solver.status == SolverStatus.ok
and results.solver.termination_condition == TerminationCondition.optimal
):
model.solutions.load_from(results)
print(pyo.value(model.A), pyo.value(model.B))
print(pyo.value(model.score))
else:
print(results.solver)
The first code block constructs the problem; the second calls an external solver. The guard deliberately avoids presenting values as the expected optimum when that condition is absent. The documentation’s tee=True option displays solver output for troubleshooting. The hand-derived values above are a mathematical check, rather than a benchmark for solver performance.
Types and related concepts
Pyomo is the modelling layer, while linear programming, nonlinear programming and mixed-integer programming describe mathematical problem classes. Changing a variable domain or an equation can change the class of the resulting problem. The mixed integer programming guide develops the distinction between continuous quantities and discrete decisions; declaring a model in Python does not remove that distinction.
Dynamic optimization adds another layer. The official pyomo.DAE documentation introduces ContinuousSet, DerivativeVar and Integral for continuous domains, derivatives and integrals. Differential equations use those components alongside ordinary variables and constraints. The extension includes transformations that discretize a differential algebraic model into an algebraic one, as well as simulation and initialization utilities.
The documentation states that every ContinuousSet must be discretized before the current implementation can solve such a model. Consequently, reporting only the differential equations leaves out part of the computational formulation. The discretization also belongs in the research record. This is a documented modelling requirement, rather than a reason to assume any particular grid is adequate.
The data table below combines the component references and solver documentation into a map of what each object represents. It distinguishes model inputs, decision quantities and solve evidence; it is a reference table, not a ranking of alternative software packages.
Where Pyomo matters for process research
The IDAES Concepts documentation provides a concrete connection to process systems research. Its Core Modeling Framework extends Pyomo’s hierarchical blocks into process unit and thermophysical property models and a framework for constructing flowsheets. A flowsheet represents connected unit operations; the documentation distinguishes unit models, property packages and reaction packages.
IDAES describes unit models through material, energy and momentum balances coupled to performance equations. It lists steady-state and dynamic simulation and optimization, data reconciliation, parameter estimation, uncertainty quantification and conceptual design among the uses of its process models. These are documented applications of an environment built on Pyomo, rather than capabilities supplied by an empty Pyomo model alone.
For a laboratory team connecting observations to a process model, that separation clarifies what must be shared: the measurements, the selected property and reaction descriptions, the equations and the computational settings. This is an editorial implication of the documented architecture. A numerical optimum is conditional on those modelling choices; it does not itself establish that a representation matches the experimental system.
Common misunderstandings
An initial value is not a fixed decision. The model-manipulation documentation shows that fixing a variable changes its fixed state. Merely assigning a value does not communicate the same restriction. If a quantity must stay at a measured setting, a research script should express that intention explicitly rather than rely on a starting value.
A parameter is not automatically editable between scenarios. Pyomo’s manipulation guide explains that parameters intended for later updates must be declared mutable. Its examples change an instantiated model and solve it again. With an abstract model, the working object is the concrete instance, so changing the abstract description and changing the solved instance should not be confused.
A completed solver call is not the whole result. Solver Recipes distinguishes solver status and termination condition and demonstrates handling an infeasible outcome separately. Its options discussion also explains that solver-specific settings are passed through to the selected solver. A parameter name accepted in a Python dictionary is not evidence that every solver recognizes the same option.
A research handoff checklist
The following editorial checklist follows the documented separation of model construction, changing data and solver results. It is intended to support computational reproducibility, rather than certify a model’s scientific validity:
- State the mathematical question. Identify the objective, variable domains, constraints and physical interpretation. Include assumptions that restrict the feasible set.
- Preserve the instance data. Keep the data used to construct the model and identify later changes to mutable parameters, bounds or fixed variables.
- Record the software environment. Name Pyomo and the separately used solver, including their versions, so the modelling layer and numerical engine are distinguishable.
- Keep solve evidence. Retain solver output, status, termination condition and the options supplied. Associate those records with the particular data instance.
- Document transformations. For a DAE model, include the discretization used to create the algebraic problem; for a process framework, identify the unit, property and reaction models.
For the illustrative balance, a useful handoff would contain the two equations, nonnegativity assumptions, objective coefficients and the solver record, together with the arithmetic check. The scenario limiting B to 4 should have its own infeasibility outcome. Keeping those outcomes separate prevents a previously loaded value from being mistaken for a solution to a different problem.
Sources
- Pyomo project: About Pyomo. Checked 2026-11-14.
- Pyomo project: Download and installation. Checked 2026-11-14.
- Pyomo documentation: Simple Models. Checked 2026-11-14.
- Pyomo documentation: Variables. Checked 2026-11-14.
- Pyomo documentation: Manipulating Pyomo Models. Checked 2026-11-14.
- Pyomo documentation: Solver Recipes. Checked 2026-11-14.
- Pyomo documentation: Dynamic Optimization with pyomo.DAE. Checked 2026-11-14.
- IDAES documentation: Concepts. Checked 2026-11-14.
Data: Pyomo model components and solve evidence
Original cross-document reference compiled from the Pyomo component, model manipulation, solver and DAE documentation and the IDAES Concepts documentation. Each row identifies the documented role and a distinct modelling or result-handling detail, with its source URL. This is a qualitative reference, not experimental performance data.
| Component or artifact | Documented role | Modelling or result-handling detail | Source URL |
|---|---|---|---|
| ConcreteModel | Construct a concrete model with available data | The documented direct expr pattern builds objective and constraint expressions. | https://pyomo.readthedocs.io/en/stable/getting_started/pyomo_overview/simple_examples.html |
| AbstractModel | Describe a structure to instantiate with data | Operate on the concrete instance when changing data and solving again. | https://pyomo.readthedocs.io/en/stable/howto/manipulating.html |
| Param | Represent model data | Declare mutable=True when later scenario updates are intended. | https://pyomo.readthedocs.io/en/stable/howto/manipulating.html |
| Var | Represent decision quantities | Domain, bounds and initial values are separate declarations. | https://pyomo.readthedocs.io/en/stable/explanation/modeling/math_programming/variables.html |
| Objective | Declare the objective expression | Minimization is the default; maximization uses sense=pyo.maximize. | https://pyomo.readthedocs.io/en/stable/getting_started/pyomo_overview/simple_examples.html |
| Constraint | Declare an admissibility relationship | Indexed constraints generate a relationship for each index. | https://pyomo.readthedocs.io/en/stable/getting_started/pyomo_overview/simple_examples.html |
| Solver results | Report status and termination condition | Use load_solutions=False to check termination before loading a solution. | https://pyomo.readthedocs.io/en/stable/howto/solver_recipes.html |
| ContinuousSet and DerivativeVar | Represent continuous domains and derivatives | Discretize every ContinuousSet before solving the model. | https://pyomo.readthedocs.io/en/stable/explanation/modeling/dae.html |
| IDAES Core Modeling Framework | Extend Pyomo hierarchical blocks for process models | Distinguish unit models, thermophysical property packages and reaction packages. | https://idaes-pse.readthedocs.io/en/stable/explanations/concepts.html |
Sources
- Pyomo: Simple Models (accessed 2026-11-14)
- Pyomo: Variables (accessed 2026-11-14)
- Pyomo: Manipulating Pyomo Models (accessed 2026-11-14)
- Pyomo: Solver Recipes (accessed 2026-11-14)
- Pyomo: Dynamic Optimization with pyomo.DAE (accessed 2026-11-14)
- IDAES: Concepts (accessed 2026-11-14)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







