Hubbry Logo
PyomoPyomoMain
Open search
Pyomo
Community hub
Pyomo
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Pyomo
Pyomo
from Wikipedia
Pyomo
Designed byGabriel Hackebeil
William E. Hart
Carl Laird
Bethany Nicholson
John Siirola
Jean-Paul Watson
David Woodruff
First appeared2008; 17 years ago (2008)
Stable release
6.8.3 / November 18, 2024; 11 months ago (2024-11-18)
OSCross-platform: Linux, Mac OS X and Windows
LicenseBSD license
Filename extensions.py
Websitewww.pyomo.org
Influenced by
Python, AMPL, General Algebraic Modeling System

Pyomo is a collection of Python software packages for formulating optimization models.[1][2]

Pyomo was developed by William Hart and Jean-Paul Watson at Sandia National Laboratories and David Woodruff at University of California, Davis. Significant extensions to Pyomo were developed by Bethany Nicholson and John Siirola at Sandia National Laboratories, Carl Laird at Purdue University, and Gabriel Hackebeil. Pyomo is an open-source project that is freely available, and it is licensed with the BSD license. Pyomo is developed as part of the COIN-OR project. Pyomo is a popular open-source software package that is used by a variety of government agencies and academic institutions.

Features

[edit]

Pyomo allows users to formulate optimization problems in Python in a manner that is similar to the notation commonly used in mathematical optimization. Pyomo supports an object-oriented style of formulating optimization models, which are defined with a variety of modeling components: sets, scalar and multidimensional parameters, decision variables, objectives, constraints, equations, disjunctions and more. Optimization models can be initialized with python data, and external data sources can be defined using spreadsheets, databases, various formats of text files. Pyomo supports both abstract models, which are defined without data, and concrete models, which are defined with data. In both cases, Pyomo allows for the separation of model and data.

Pyomo supports dozens of solvers, both open source and commercial, including many solvers supported by AMPL, PICO, CBC, CPLEX, IPOPT, and GLPK. Pyomo can either invoke the solver directly or asynchronously with a solver manager. Solver managers support remote, asynchronous execution of solvers, which supports parallel execution of Pyomo scripts. Solver interaction is performed with a variety of solver interfaces, depending on the solver being used. A very generic solver interface is supported with AMPL's nl (format).

[edit]

The following software packages integrate Pyomo as a library to support optimization modeling and analysis:

  • SolverStudio lets you use Excel to edit, save and solve optimisation models built using a variety of modeling languages, including Pyomo.[3] Pyomo is bundled with the SolverStudio software.
  • TEMOA (Tools for Energy Model Optimization and Assessment) is an open source modeling framework for conducting energy system analysis.[4] The core component of TEMOA is an energy economy optimization model. This model is formulated and optimized using Pyomo.
  • MinPower is an open source toolkit for students and researchers in power systems. It is designed to make working with standard power system models simple and intuitive.[5] MinPower uses Pyomo to formulate and optimize these power system models.
  • linopy project, offering similar functionality to Pyomo.[6]

See also

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
Pyomo is an open-source, Python-based optimization modeling language designed for formulating, solving, and analyzing mathematical optimization models in a flexible, extensible environment. Developed initially by researchers at Sandia National Laboratories as part of the Coopr software library, it was first released in 2008 under a BSD license to provide an alternative to proprietary modeling languages like AMPL and GAMS, leveraging Python's syntax and libraries for enhanced portability and integration. Pyomo supports abstract and concrete model definitions, allowing users to define sparse sets, parameters, variables, objectives, and constraints through Python classes, which can then be solved using a variety of commercial and open-source solvers such as CBC, GLPK, Gurobi, and CPLEX. Key features of Pyomo include its capability to handle diverse problem classes, such as (LP), (QP), (NLP), mixed-integer nonlinear programming (MINLP), , bilevel programming, and models involving differential-algebraic equations or equilibrium constraints. This versatility enables applications in fields like energy systems, logistics, , and engineering design, where complex real-world optimization problems require iterative analysis, sensitivity testing, and scripting. Rebranded from Coopr to Pyomo in 2015 and transitioned to in 2016 for community-driven development, it has grown steadily with contributions from over 100 developers and is now part of the project, fostering tools like PySP for multistage . Pyomo's design emphasizes , automated model instantiation from data files (e.g., in AMPL .dat format), and integration with Python ecosystems like and Pandas for data handling and visualization.

Overview

Definition and Purpose

Pyomo is a Python-based open-source software package that supports a diverse set of optimization capabilities for formulating, solving, and analyzing optimization models. It serves as a collection of Python packages designed to enable users to define symbolic optimization problems directly within Python code, facilitating the modeling of structured optimization applications across various domains such as linear, nonlinear, and mixed-integer programming. This approach allows for the creation of model instances and their subsequent solving using both commercial and open-source solvers, promoting flexibility in handling complex decision-making scenarios. The primary purpose of Pyomo is to empower users with iterative scripting and analysis tools embedded in Python, enabling the development and refinement of optimization models through high-level abstractions and programmatic control. By supporting symbolic problem definition, Pyomo facilitates and exploration of optimization problems, making it particularly suited for applications requiring repeated model adjustments or sensitivity analyses in fields like , , and . A key benefit of Pyomo lies in its seamless integration with the broader Python ecosystem, which provides access to extensive libraries for manipulation, numerical , visualization, and , thereby streamlining end-to-end optimization workflows. This embedding in Python enhances productivity by allowing users to combine optimization tasks with other computational tasks without needing to switch languages . Pyomo is released under the BSD license, which imposes minimal restrictions on its use in both academic and commercial contexts, and it is maintained as part of the (Computational Infrastructure for ) project.

Development History

Pyomo originated in the late 2000s from research efforts at ' Center for Computing Research, where it was initially developed as the core modeling component of the Coopr software library. The project was spearheaded by primary designers William E. Hart, Jean-Paul Watson, and Carl D. Laird, who aimed to create a flexible, Python-based tool for optimization modeling. Pyomo was first released in 2008, with the first public description appearing in 2009, building on Python's scripting capabilities to enable symbolic problem formulation and integration with existing solvers. Key milestones in Pyomo's evolution include its early integration into the open-source initiative, which provided infrastructure for solver interfaces and community collaboration starting around 2010. A seminal 2011 publication formalized Pyomo's design as an algebraic modeling language, emphasizing its extensibility for complex problems. The project underwent a significant rebranding in 2015 with the release of Pyomo 4.0, shifting the umbrella Coopr name to focus solely on Pyomo as the primary package. Development transitioned to in mid-2016, enhancing accessibility and version control. Subsequent major versions marked further advancements: Pyomo 5.x, released in 2016, improved support for through better expression handling and solver integrations. Pyomo 6.x followed in 2021, delivering performance optimizations, streamlined architecture, and exclusive compatibility with Python 3 by deprecating Python 2 support. These updates were driven by the need to evolve Pyomo from a standalone library into a deeply embedded Python tool, enabling scripting for advanced applications such as via extensions like PySP. Ongoing development continues under the foundation by a growing of contributors. As of November 2025, the latest version is 6.9.5, featuring support for newer Python versions (3.10–3.14), enhanced solver interfaces, and ongoing contributions from a of over 100 developers.

Core Features

Modeling Paradigms

Pyomo provides two primary modeling paradigms for defining optimization problems: abstract models and concrete models. These approaches offer flexibility in how models are constructed and parameterized, allowing users to choose based on the problem's scale, data availability, and reuse requirements. Abstract models enable the symbolic definition of optimization problems without specifying numerical data at the time of model creation. In this paradigm, sets, parameters, variables, objectives, and constraints are declared using symbolic expressions, with data supplied later through mechanisms like data files or portals. This separation facilitates parameterization, where the model structure remains fixed while data varies, making it ideal for generating multiple instances from a single template. For example, an abstract model can represent a transportation problem with generic sets for origins and destinations, loaded with specific values for different scenarios. In contrast, concrete models involve direct instantiation of all components with numerical data during the model's definition. Parameters, variables, and other elements are assigned specific values inline, resulting in a fully specified instance ready for immediate solving. This approach suits one-off analyses or data-driven problems where the input is fixed and available upfront, such as prototyping a small linear program with hardcoded coefficients. Concrete models are particularly accessible for users familiar with Python scripting, as they integrate seamlessly with Python data structures like lists or arrays. The choice between paradigms depends on the application's needs. Abstract models excel in for large-scale optimizations or scenario-based analyses, where reusing a symbolic framework across varied datasets reduces redundancy and supports efficient scripting for parametric studies. Concrete models, however, offer simplicity for and exploratory work, avoiding the overhead of . While both can achieve similar flexibility—such as loading external data into concrete models or hardcoding into abstract ones—the abstract approach aligns more closely with traditional algebraic modeling languages, whereas concrete models leverage Python's dynamic nature. Pyomo models, particularly concrete instances, support persistence through export to standardized formats like LP (for linear programs) and NL (for nonlinear problems), enhancing compatibility with external solvers. These files are generated automatically via solver interfaces during the solving process, allowing models to be shared, debugged, or warm-started without relying on Python execution. For instance, an LP file captures the matrix representation of a , while an NL file handles nonlinear expressions in AMPL format. This capability ensures interoperability in distributed or legacy solver environments.

Supported Optimization Types

Pyomo supports (LP), a class of optimization problems characterized by continuous decision variables, linear objective functions, and linear constraints. The of an LP problem that Pyomo can model is to minimize cTx\mathbf{c}^T \mathbf{x} subject to Ax=bA \mathbf{x} = \mathbf{b} and x0\mathbf{x} \geq \mathbf{0}, where c\mathbf{c} is the vector of objective coefficients, x\mathbf{x} is the vector of decision variables, AA is the constraint matrix, and b\mathbf{b} is the right-hand-side vector. This formulation assumes equality constraints, which can be derived from inequality forms by introducing slack variables; for instance, an inequality AxbA \mathbf{x} \leq \mathbf{b} becomes Ax+s=bA \mathbf{x} + \mathbf{s} = \mathbf{b} with s0\mathbf{s} \geq \mathbf{0}. As an illustrative example, consider minimizing 3x1+4x23x_1 + 4x_2 subject to 2x1+x2=42x_1 + x_2 = 4, x1+3x2=6x_1 + 3x_2 = 6, and x1,x20x_1, x_2 \geq 0, where the A=(2113)A = \begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix}, b=(46)\mathbf{b} = \begin{pmatrix} 4 \\ 6 \end{pmatrix}, and c=(34)\mathbf{c} = \begin{pmatrix} 3 \\ 4 \end{pmatrix}. Building on LP, Pyomo enables mixed-integer (MILP), which incorporates discrete decisions through or binary variables alongside continuous ones, while maintaining linearity in the objective and constraints. This allows modeling combinatorial aspects, such as scheduling or facility location, where certain variables must take whole-number values. MILP problems retain the linear structure of LP but extend the variable domain to include , solvable via branch-and-bound methods interfaced through Pyomo. For nonlinear problems, Pyomo supports (NLP), accommodating quadratic objectives and constraints as well as general nonlinear functions, which arise in applications like or . (QP) is a specific subclass of NLP featuring quadratic terms in the objective or constraints, often convex and solvable efficiently. This capability includes handling nonconvexities, though convergence depends on the interfaced solver. Pyomo's expression system facilitates defining these nonlinear terms symbolically. Pyomo also supports mixed-integer nonlinear programming (MINLP), which combines discrete integer variables with nonlinear functions, enabling the modeling of complex hybrid problems. Pyomo further extends to advanced optimization types via specialized extensions. Stochastic programming, which addresses uncertainty through scenario-based formulations, is supported by the PySP extension for multistage and two-stage problems. Disjunctive programming models logical conditions and disjunctions using the Generalized Disjunctive Programming extension, useful for problems with conditional constraints. , involving hierarchical with an outer problem optimizing over solutions to an inner problem, is handled through dedicated bilevel modeling components. Additionally, differential-algebraic equations (DAEs) are integrated via the Pyomo.DAE extension, enabling dynamic optimization of systems with time-dependent ordinary and algebraic differential equations.

Components and Architecture

Key Modeling Objects

Pyomo's key modeling objects form the foundational elements for constructing optimization models, enabling users to define symbolic representations of mathematical programs in Python. These objects include sets for indexing, parameters for fixed data, variables for decision elements, expressions for intermediate computations, constraints for restrictions, and objectives for optimization goals. All such objects inherit from the base Component class, which provides a common interface for extensibility and integration within Pyomo's object-oriented framework. Sets serve as index sets to structure multidimensional arrays of other components, such as variables or parameters, facilitating the modeling of problems with multiple dimensions or categories. They are declared using the Set or RangeSet classes, with options to initialize from iterables like or functions. For instance, a simple can be defined as model.S = Set(initialize=[1, 2, 3]), while a range set might be model.R = RangeSet(1, 10). Additional options include specifying dimensionality (dimen=2 for tuple-based members) or restricting membership (within=NonNegativeIntegers). Sets can also be indexed by other sets, creating hierarchical structures like model.E = Set(model.A). Parameters represent fixed, symbolic data values used throughout the model, such as coefficients or constants, and are declared via the Param class, which supports indexing by sets. Declaration typically involves an initialize option for values, which can be a constant, , or function; for example, model.p = Param(initialize=5) for a scalar or model.c = Param(model.S, initialize={1: 10, 2: 20, 3: 30}) for an indexed array. Parameters can be made mutable to allow post-instantiation changes (mutable=True), include validation callbacks (validate), or restrict domains (within=NonNegativeReals). If no initialization is provided, a default value can be set. Variables are the decision elements of the model, representing unknowns to be optimized, and are declared using the Var class, inheriting from Component. They support domains like continuous reals (Reals or NonNegativeReals), integers (Integers or PositiveIntegers), or binary values (Binary or [Boolean](/page/Boolean)), along with bounds specified as a tuple or function. Indices are provided via sets, enabling array-like structures; a basic example is model.x = Var(domain=NonNegativeReals), while an indexed continuous variable is model.x = Var(model.S, domain=NonNegativeReals, bounds=(0, None)). Initial values can be set via initialize, and bounds imply domain restrictions in many cases, such as Binary enforcing 0-1 limits. Expressions provide a mechanism for defining and storing intermediate symbolic computations that can be reused in objectives or constraints, declared as the Expression component, which behaves similarly to a mutable Param but accepts Pyomo expressions. They are particularly useful for nonlinear or shared terms; for example, model.e = Expression(model.S, rule=lambda m, i: m.x[i] * i) creates an indexed expression. Values can be set or modified directly, such as instance.e[1].value = instance.x**2, and they integrate seamlessly with solvers supporting nonlinear expressions. Constraints enforce restrictions on variables through equality (==) or inequality (<=, >=) expressions, supporting both linear and nonlinear forms, and are declared using the Constraint class. They can be scalar or indexed by sets, with expressions generated via Python rule functions; a linear inequality example is model.con = Constraint(rule=lambda m: sum(m.x[i] for i in m.S) <= m.b), where m.b is a parameter. For bounds-style declarations, a 3-tuple (lower, expression, upper) is used, such as (2, model.y, None) for model.y >= 2. Indexed constraints iterate over sets or their Cartesian products, ensuring feasibility across model instances. Objectives define the function to minimize or maximize, declared via the Objective class, which supports single or multiple instances (though only one is active per solve). The expression is provided through a rule function, with a default sense of minimization that can be overridden (sense=maximize); for example, model.obj = Objective(expr=sum(model.c[i] * model.x[i] for i in model.S), sense=minimize). Expressions can incorporate parameters, variables, and even other expressions, enabling complex linear or nonlinear goals like summation(model.p, model.x) + model.y.

Solver Interfaces

Pyomo provides interfaces to a wide range of optimization solvers, enabling users to solve models defined in the framework using both open-source and commercial software. These interfaces allow Pyomo to translate abstract or concrete models into formats compatible with the solvers, execute the optimization, and retrieve results back into the Python environment. The design emphasizes flexibility, supporting direct API calls for performance-critical applications and file-based persistence for broader compatibility, particularly with solvers that use the AMPL Nonlinear (.nl) format or GAMS-style inputs. Among open-source solvers, Pyomo supports GLPK for linear and mixed-integer linear programming, CBC for mixed-integer programming, IPOPT (via cyipopt) for nonlinear optimization, HiGHS for linear and mixed-integer linear problems, SCIP for mixed-integer nonlinear programming, and others like PyMUMPS for sparse linear systems. Commercial solvers integrated include Gurobi for mixed-integer linear and quadratic programming, CPLEX for linear and mixed-integer linear optimization, KNITRO for nonlinear problems, XPRESS for linear and mixed-integer linear models, and BARON for global optimization of nonlinear problems. Users can list available solvers via the command pyomo help --solvers, and installation typically occurs separately through pip or conda, as Pyomo does not bundle solvers. The solving process begins with model creation, either as a ConcreteModel directly or by instantiating an AbstractModel with data (e.g., instance = model.create_instance(data)). A solver is then instantiated using the SolverFactory class, such as opt = pyo.SolverFactory('glpk'), where the argument specifies the solver name. The solve method is invoked on the solver object, passing the model or instance (e.g., results = opt.solve(model)), which handles model if needed, solver execution, and solution import. For file-based interfaces, Pyomo optionally persists the model to disk (e.g., as an .nl file) before invoking the solver executable. Solver-specific options can be configured to customize the optimization, such as setting a with opt.options['timelimit'] = 60 or a mixed-integer programming gap tolerance via opt.options['mipgap'] = 0.01. These options are passed either directly to the solver object before calling solve or as a in the solve method (e.g., opt.solve(model, options={'timelimit': 60})). For parallel or distributed solving, Pyomo's SolverManager class facilitates execution across multiple processes or machines, often leveraging MPI via the mpi4py library; for instance, manager = pyo.SolverManagerFactory('mpi') coordinates jobs like job_id = manager.queue(model, opt=opt). After solving, results are accessible through the returned SolverResults object or directly on the model. The solver status is checked via results.solver.status (e.g., 'ok') and termination condition like results.solver.termination_condition (e.g., pyo.TerminationCondition.optimal or pyo.TerminationCondition.infeasible). Variable values are retrieved using pyo.value(model.var), objective values with pyo.value(model.obj), and dual variables (where supported) by importing suffixes (e.g., model.dual = pyo.Suffix(direction=pyo.Suffix.IMPORT) before solving, then pyo.value(model.dual[constraint])). Solutions can be loaded into the model with model.solutions.load_from(results) if not done automatically. The overall workflow proceeds as: model definition and population → optional persistence to file (e.g., .nl for AMPL-compatible solvers) → solver invocation and execution → results import and analysis. This pipeline supports both scripted Python workflows and command-line usage, such as pyomo solve my_model.py --solver=glpk, ensuring seamless integration with external solvers.

Usage and Examples

Basic Linear Programming Example

To illustrate the core usage of Pyomo for , consider the classic diet problem, which seeks to minimize the cost of a daily diet while satisfying minimum and maximum nutritional requirements for calories, protein, and , as well as a total volume constraint. The problem involves three foods: steak (cost $10 per unit, volume 1 unit, providing 180 calories, 40g protein, 0mg ), apples (cost $2 per unit, volume 1 unit, 65 calories, 1g protein, 30mg ), and (cost $1 per unit, volume 1 unit, 143 calories, 5g protein, 0mg ). The decision variables represent the continuous amount (in units) of each food purchased, which must be non-negative. The objective is to minimize total cost, subject to: minimum nutrients (2000 calories, 56g protein, 300mg ), maximum nutrients (4000 calories, 168g protein, 2000mg ), and total volume ≤ 400 units. This is a standard toy example used in Pyomo tutorials. Pyomo supports this formulation through an abstract model, where the structure is defined in Python and data is loaded separately (e.g., from a .dat file). The following steps outline the process. First, import Pyomo and create an abstract model instance:

python

import pyomo.environ as pyo model = pyo.AbstractModel()

import pyomo.environ as pyo model = pyo.AbstractModel()

Define the sets, parameters, variables, objective, and constraints symbolically. The sets include foods and ; parameters capture costs, volumes, nutrient amounts, and bounds; the variable is the amount of each food:

python

# Sets model.foods = pyo.Set() model.nutrients = pyo.Set() # Parameters model.cost = pyo.Param(model.foods, within=pyo.Reals) model.volume = pyo.Param(model.foods, within=pyo.PositiveReals) model.amount = pyo.Param(model.foods, model.nutrients, within=pyo.Reals) model.min_nutr = pyo.Param(model.nutrients, within=pyo.Reals) model.max_nutr = pyo.Param(model.nutrients, within=pyo.Reals) model.max_vol = pyo.Param(within=pyo.Reals) # Variables model.x = pyo.Var(model.foods, within=pyo.NonNegativeReals) # Objective: minimize total cost def obj_rule(model): return sum(model.cost[f] * model.x[f] for f in model.foods) model.obj = pyo.Objective(rule=obj_rule, sense=pyo.minimize) # Constraints def vol_rule(model): return sum(model.volume[f] * model.x[f] for f in model.foods) <= model.max_vol model.volume_constraint = pyo.Constraint(rule=vol_rule) def nutr_rule(model, n): return sum(model.amount[f, n] * model.x[f] for f in model.foods) >= model.min_nutr[n], \ sum(model.amount[f, n] * model.x[f] for f in model.foods) <= model.max_nutr[n] model.nutr_constraints = pyo.Constraint(model.nutrients, rule=nutr_rule)

# Sets model.foods = pyo.Set() model.nutrients = pyo.Set() # Parameters model.cost = pyo.Param(model.foods, within=pyo.Reals) model.volume = pyo.Param(model.foods, within=pyo.PositiveReals) model.amount = pyo.Param(model.foods, model.nutrients, within=pyo.Reals) model.min_nutr = pyo.Param(model.nutrients, within=pyo.Reals) model.max_nutr = pyo.Param(model.nutrients, within=pyo.Reals) model.max_vol = pyo.Param(within=pyo.Reals) # Variables model.x = pyo.Var(model.foods, within=pyo.NonNegativeReals) # Objective: minimize total cost def obj_rule(model): return sum(model.cost[f] * model.x[f] for f in model.foods) model.obj = pyo.Objective(rule=obj_rule, sense=pyo.minimize) # Constraints def vol_rule(model): return sum(model.volume[f] * model.x[f] for f in model.foods) <= model.max_vol model.volume_constraint = pyo.Constraint(rule=vol_rule) def nutr_rule(model, n): return sum(model.amount[f, n] * model.x[f] for f in model.foods) >= model.min_nutr[n], \ sum(model.amount[f, n] * model.x[f] for f in model.foods) <= model.max_nutr[n] model.nutr_constraints = pyo.Constraint(model.nutrients, rule=nutr_rule)

Populate the model with data using a .dat file (diet.dat), which specifies the sets (foods: steak, apple, ; nutrients: calories, protein, vc), parameters (e.g., cost.=10, amount.apple.vc=30, min_nutr.calories=2000, max_vol=400), and is loaded via Pyomo's DataPortal:

python

data = pyo.DataPortal() data.load(filename='diet.dat') instance = model.create_instance(data)

data = pyo.DataPortal() data.load(filename='diet.dat') instance = model.create_instance(data)

Solve the model using a linear programming solver like GLPK (assuming it is installed and available via Pyomo):

python

solver = pyo.SolverFactory('glpk') results = solver.solve(instance, tee=True)

solver = pyo.SolverFactory('glpk') results = solver.solve(instance, tee=True)

Interpret the output by printing variable values and the objective. The optimal solution yields a minimum of approximately $29.44, achieved by 0 units of , 10 units of apples, and 9.44 units of , satisfying all constraints (e.g., calories ≈ 2000, protein = 57.2g, = 300mg, volume ≈ 19.44 units).

Advanced Modeling Techniques

Pyomo supports advanced modeling techniques for handling , dynamics, and hierarchical decision-making in optimization problems. One key extension is PySP, which facilitates by allowing users to define scenario-based models that capture stage-wise decisions and recourse actions under . In PySP, a program is expressed through a deterministic base model and a , where uncertain parameters evolve across stages, enabling the formulation of multi-stage problems like two-stage linear programs with recourse. This approach decomposes the problem into scenario subproblems, which can be solved using decomposition algorithms such as progressive hedging or , integrated seamlessly with Pyomo's solver interfaces. For nonlinear and dynamic systems, Pyomo incorporates the Pyomo.DAE extension to model differential-algebraic equations (DAEs) within optimization frameworks. Pyomo.DAE enables the representation of continuous-time dynamics by declaring differential variables, their derivatives, and algebraic constraints, supporting both finite-difference and orthogonal discretization methods to convert DAEs into algebraic forms suitable for nonlinear solvers. This is particularly useful for dynamic optimization problems, such as in chemical processes, where time-dependent variables and differential equations are discretized automatically during model transformation. Pyomo addresses through extensions, though the original pyomo.bilevel package is now deprecated (as of Pyomo 6.8+). Current support is available via the PAO (Python Package for Adversarial Optimization) package, which handles multi-level optimization by allowing nested models where an upper-level problem optimizes over the solutions of a lower-level subproblem, using techniques like reformulation into single-level equivalents or meta-solvers for local and . For robust optimization under uncertainty, the PyROS solver handles nonconvex two-stage adjustable robust problems by reformulating them via duality and , providing guarantees on worst-case performance without enumerating all scenarios. These capabilities enable nested decision structures and uncertainty handling in applications like design and systems planning. Pyomo also supports via PySP. For a two-stage problem, the process involves defining an abstract reference model in Python (e.g., ReferenceModel.py) with first- and second-stage variables, then specifying the scenario tree in a .dat file (ScenarioStructure.dat) with nodes and probabilities, and providing scenario-specific data files for uncertain parameters like demand. The model is then instantiated and solved using PySP tools like progressive hedging (runph). For details, see the PySP documentation. Despite these advances, advanced modeling in Pyomo faces challenges, particularly for large-scale programs with numerous scenarios, where computational demands grow exponentially due to the curse of dimensionality in scenario trees. To address this, approximation methods like sample average approximation (SAA) reduce the problem by sampling a subset of scenarios, trading optimality for tractability while providing statistical guarantees on solution quality. Parallel decomposition in PySP further mitigates these issues by distributing subproblem solves across processors.

Applications and Extensions

Real-World Applications

Pyomo has been extensively applied in the sector for optimizing power systems, including unit commitment models that schedule generation units to minimize operational costs while meeting demand and incorporating integration. For instance, in unit commitment problems, Pyomo formulates mixed-integer linear programs to handle on/off decisions for generators, startup/shutdown costs, and constraints like ramp rates and reserve requirements, enabling efficient scheduling in systems with variable renewable sources such as and solar. A multi-objective two-stage unit commitment model using Pyomo has been developed to balance economic dispatch, emissions reduction, and reliability in wind-integrated power grids, demonstrating improved Pareto-optimal solutions for real-world grid operations. For instance, the National Renewable Energy Laboratory (NREL) employs Pyomo in its power system optimization tools such as EGRET. Similarly, tools like Dispa-SET, developed by the European Commission's , use Pyomo for unit commitment and dispatch in European grids, focusing on flexibility and balancing with high renewable penetration. These applications highlight Pyomo's role in transitioning to systems by optimizing hybrid renewable setups. In , Pyomo supports optimization of inventory management, vehicle routing, and facility location problems through flexible algebraic modeling. The warehouse location problem, a classic case, uses Pyomo to minimize transportation costs by selecting optimal sites from candidate locations while satisfying demand constraints, often solved via with data imported from external sources like Excel files. For multi-period lot-sizing, Pyomo models over time horizons to balance fixed setup costs, holding costs, and shortage penalties, yielding strategies that reduce overall expenses in dynamic environments. These formulations allow for scalable solutions in large networks, as seen in transportation network optimizations that route goods across multiple nodes to achieve cost-effective distribution. Research applications of Pyomo extend to stochastic modeling for complex policy analysis, such as climate policy evaluation through energy system optimizations under uncertainty. Using extensions like PySP, Pyomo constructs scenario trees for two-stage stochastic programs that assess renewable integration policies, quantifying trade-offs in cost, emissions, and reliability for long-term climate goals. Pyomo's integration with Python facilitates hybrid models combining optimization with data science tools, enabling seamless incorporation of machine learning forecasts for demand or weather variability in these analyses. This Python-native approach enhances accessibility for interdisciplinary research in operations research, engineering, and economics. Pyomo's impact is evident in its widespread citation across publications, with over 1,000 scholarly works referencing its use in real-world optimization since 2011, spanning for scheduling, for process design, and for . The third edition of the Pyomo book provides foundational examples, such as reactor design in and sustainable harvesting models, illustrating practical implementations that have influenced industry adoption. Pyomo offers several official extensions that enhance its capabilities for specialized optimization problems. PySP (Python Stochastic Programming) is an extension for formulating and solving models, supporting scenario-based approaches and integration with scenario trees for handling uncertainty in optimization. Pyomo.DAE provides support for dynamic optimization by incorporating differential algebraic equations (DAEs) into models, enabling the simulation and optimization of time-dependent systems such as chemical processes. MIPLearn extends Pyomo by integrating techniques to accelerate the solving of mixed-integer programming (MIP) problems, using methods like for bounding and cutting planes. In comparison to other modeling languages, Pyomo embeds optimization modeling within Python, contrasting with domain-specific languages like AMPL and GAMS, which offer proprietary syntax but require separate environments and often incur licensing costs. Lighter alternatives such as PuLP and JuMP provide simpler interfaces for linear and mixed-integer programming; PuLP is Python-based and suited for quick prototyping, while JuMP leverages Julia's speed for larger-scale models but lacks Pyomo's breadth in nonlinear and global optimization support. Pyomo integrates seamlessly with the Python ecosystem, allowing data import and manipulation via for handling tabular inputs in model parameters, visualization of results using for plotting solution variables and sensitivities, and parallel computation through MPI via packages like mpi4py for distributed solving of large-scale problems. The Pyomo community contributes third-party plugins and models hosted on , particularly for domain-specific applications such as systems modeling with tools like openMASTER for sustainable and OSeMOSYS implementations for long-term , as well as finance-related optimizations in portfolio and risk assessment. As an open-source tool, Pyomo provides greater flexibility for customization and extension compared to commercial tools like and GAMS, which prioritize optimized performance and solver integration but limit modifications to licensed features.

References

Add your contribution
Related Hubs
User Avatar
No comments yet.