Skip to main content
v2026.11,986 entries · CC-BY 4.0

Pyomo: Models, Solvers and Research Checks

Understand Pyomo models, separate solver requirements and the checks that make a chemical process optimization result reproducible.

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.

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

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.

Pyomo model components and solve evidence
Component or artifactDocumented roleModelling or result-handling detailSource URL
ConcreteModelConstruct a concrete model with available dataThe documented direct expr pattern builds objective and constraint expressions.https://pyomo.readthedocs.io/en/stable/getting_started/pyomo_overview/simple_examples.html
AbstractModelDescribe a structure to instantiate with dataOperate on the concrete instance when changing data and solving again.https://pyomo.readthedocs.io/en/stable/howto/manipulating.html
ParamRepresent model dataDeclare mutable=True when later scenario updates are intended.https://pyomo.readthedocs.io/en/stable/howto/manipulating.html
VarRepresent decision quantitiesDomain, bounds and initial values are separate declarations.https://pyomo.readthedocs.io/en/stable/explanation/modeling/math_programming/variables.html
ObjectiveDeclare the objective expressionMinimization is the default; maximization uses sense=pyo.maximize.https://pyomo.readthedocs.io/en/stable/getting_started/pyomo_overview/simple_examples.html
ConstraintDeclare an admissibility relationshipIndexed constraints generate a relationship for each index.https://pyomo.readthedocs.io/en/stable/getting_started/pyomo_overview/simple_examples.html
Solver resultsReport status and termination conditionUse load_solutions=False to check termination before loading a solution.https://pyomo.readthedocs.io/en/stable/howto/solver_recipes.html
ContinuousSet and DerivativeVarRepresent continuous domains and derivativesDiscretize every ContinuousSet before solving the model.https://pyomo.readthedocs.io/en/stable/explanation/modeling/dae.html
IDAES Core Modeling FrameworkExtend Pyomo hierarchical blocks for process modelsDistinguish unit models, thermophysical property packages and reaction packages.https://idaes-pse.readthedocs.io/en/stable/explanations/concepts.html

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about Pyomo: Models, Solvers and Research Checks

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →