Pyomo, short for Python Optimization Modeling Objects, was created in 2008 by William E. Hart and the COIN-OR project team. Pyomo is a Python-based, open-source modeling language for formulating and solving optimization problems, including linear, nonlinear, and mixed-integer programming. It is widely used in operations research, energy systems, supply chain planning, and industrial optimization. Developers can access Pyomo via the official repository: Pyomo Official Downloads, which provides Python packages, solver interfaces, documentation, and examples for Windows, macOS, and Linux platforms.
Pyomo exists to bring declarative modeling and optimization directly into the Python ecosystem. Its design philosophy emphasizes readability, solver-independence, and integration with Python’s rich libraries. By allowing modelers to define variables, parameters, constraints, and objectives using Python syntax, Pyomo solves the problem of bridging high-level mathematical modeling with programmatic flexibility, enabling researchers and engineers to create, test, and execute optimization models efficiently.
Pyomo: Variables and Parameters
Pyomo uses Python objects to define variables and parameters for decision-making and input data.
from pyomo.environ import ConcreteModel, Var, Param, NonNegativeReals, SolverFactory, summation
model = ConcreteModel()
model.I = [1, 2, 3]
model.a = Param(model.I, initialize={1: 5, 2: 10, 3: 8})
model.x = Var(model.I, domain=NonNegativeReals)
model.z = Var()
model.obj = summation(model.a, model.x)
SolverFactory('glpk').solve(model)Variables represent quantities to optimize, while parameters define constants. This integration with Python provides flexibility and clarity, conceptually similar to AMPL and GAMS.
Pyomo: Constraints and Objective Functions
Pyomo allows explicit definition of constraints and objectives using Python functions and expressions.
def supply_limit_rule(model):
return sum(model.x[i] for i in model.I) <= 20
model.supply_limit = Constraint(rule=supply_limit_rule)
def objective_rule(model):
return sum(model.a[i] * model.x[i] for i in model.I)
model.obj = Objective(rule=objective_rule, sense=maximize)Constraints enforce problem requirements, and objectives define what to optimize. The declarative approach separates model description from solver execution, conceptually similar to AMPL and GAMS.
Pyomo: Solver Integration
Pyomo interfaces with numerous solvers such as GLPK, CPLEX, Gurobi, and IPOPT for executing optimization tasks.
from pyomo.opt import SolverFactory
SolverFactory('glpk').solve(model)This separation allows the same model to be executed with different solvers, providing flexibility and robustness, similar to solver-independent modeling in AMPL and GAMS.
Pyomo: Sets, Loops, and Data Structures
Pyomo supports iteration over sets, indexed variables, and dictionaries to handle complex problem structures.
for i in model.I:
model.x[i].value = 0 # Initialize variables
data = {1: 50, 2: 60, 3: 40} # Example parameter mappingThis structure allows scalable modeling and flexible manipulation of inputs, conceptually similar to set-based operations in AMPL and GAMS.
Pyomo is used extensively in operations research, energy planning, transportation, industrial optimization, and academic research. Its tight integration with Python, flexible solver support, and declarative modeling syntax make it suitable for both experimentation and large-scale applications. When used alongside AMPL, GAMS, and MATLAB, Pyomo provides a robust, programmatically flexible, and efficient environment for building, solving, and analyzing complex optimization problems.