Skip to content

Commit

Permalink
Merge branch 'main' into fix-nested-everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
emma58 authored Feb 21, 2024
2 parents 192d9dd + 5bfa298 commit bad123d
Show file tree
Hide file tree
Showing 106 changed files with 3,239 additions and 1,504 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/release_wheel_creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,27 @@ jobs:
name: Build wheels (${{ matrix.wheel-version }}) on ${{ matrix.os }} for native and cross-compiled architecture
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
arch: [all]
wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*']

include:
- wheel-version: 'cp38*'
TARGET: 'py38'
- wheel-version: 'cp39*'
TARGET: 'py39'
- wheel-version: 'cp310*'
TARGET: 'py310'
- wheel-version: 'cp311*'
TARGET: 'py311'
- wheel-version: 'cp312*'
TARGET: 'py312'
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected].2
uses: pypa/[email protected].5
with:
output-dir: dist
env:
Expand All @@ -43,8 +56,9 @@ jobs:
CIBW_CONFIG_SETTINGS: '--global-option="--with-cython --with-distributable-extensions"'
- uses: actions/upload-artifact@v4
with:
name: native_wheels
name: native_wheels-${{ matrix.os }}-${{ matrix.TARGET }}
path: dist/*.whl
overwrite: true

alternative_wheels:
name: Build wheels (${{ matrix.wheel-version }}) on ${{ matrix.os }} for aarch64
Expand All @@ -54,6 +68,18 @@ jobs:
os: [ubuntu-22.04]
arch: [all]
wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*']

include:
- wheel-version: 'cp38*'
TARGET: 'py38'
- wheel-version: 'cp39*'
TARGET: 'py39'
- wheel-version: 'cp310*'
TARGET: 'py310'
- wheel-version: 'cp311*'
TARGET: 'py311'
- wheel-version: 'cp312*'
TARGET: 'py312'
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
Expand All @@ -62,7 +88,7 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/[email protected].2
uses: pypa/[email protected].5
with:
output-dir: dist
env:
Expand All @@ -74,8 +100,9 @@ jobs:
CIBW_CONFIG_SETTINGS: '--global-option="--with-cython --with-distributable-extensions"'
- uses: actions/upload-artifact@v4
with:
name: alt_wheels
name: alt_wheels-${{ matrix.os }}-${{ matrix.TARGET }}
path: dist/*.whl
overwrite: true

generictarball:
name: ${{ matrix.TARGET }}
Expand Down Expand Up @@ -106,4 +133,5 @@ jobs:
with:
name: generictarball
path: dist
overwrite: true

25 changes: 23 additions & 2 deletions doc/OnlineDocs/advanced_topics/flattener/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ The ``pyomo.dae.flatten`` module aims to address this use case by providing
utilities to generate all components indexed, explicitly or implicitly, by
user-provided sets.

**When we say "flatten a model," we mean "generate all components in the model,
preserving all user-specified indexing sets."**
**When we say "flatten a model," we mean "recursively generate all components in
the model," where a component can be indexed only by user-specified indexing
sets (or is not indexed at all)**.

Data structures
---------------
Expand All @@ -42,3 +43,23 @@ Slices are necessary as they can encode "implicit indexing" -- where a
component is contained in an indexed block. It is natural to return references
to these slices, so they may be accessed and manipulated like any other
component.

Citation
--------
If you use the ``pyomo.dae.flatten`` module in your research, we would appreciate
you citing the following paper, which gives more detail about the motivation for
and examples of using this functinoality.

.. code-block:: bibtex
@article{parker2023mpc,
title = {Model predictive control simulations with block-hierarchical differential-algebraic process models},
journal = {Journal of Process Control},
volume = {132},
pages = {103113},
year = {2023},
issn = {0959-1524},
doi = {https://doi.org/10.1016/j.jprocont.2023.103113},
url = {https://www.sciencedirect.com/science/article/pii/S0959152423002007},
author = {Robert B. Parker and Bethany L. Nicholson and John D. Siirola and Lorenz T. Biegler},
}
10 changes: 10 additions & 0 deletions doc/OnlineDocs/contributed_packages/mpc/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _mpc_api:

API Reference
=============

.. toctree::
data.rst
conversion.rst
interface.rst
modeling.rst
5 changes: 5 additions & 0 deletions doc/OnlineDocs/contributed_packages/mpc/conversion.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Data Conversion
===============

.. automodule:: pyomo.contrib.mpc.data.convert
:members:
17 changes: 17 additions & 0 deletions doc/OnlineDocs/contributed_packages/mpc/data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Data Structures
===============

.. automodule:: pyomo.contrib.mpc.data.get_cuid
:members:

.. automodule:: pyomo.contrib.mpc.data.dynamic_data_base
:members:

.. automodule:: pyomo.contrib.mpc.data.scalar_data
:members:

.. automodule:: pyomo.contrib.mpc.data.series_data
:members:

.. automodule:: pyomo.contrib.mpc.data.interval_data
:members:
22 changes: 21 additions & 1 deletion doc/OnlineDocs/contributed_packages/mpc/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MPC
===

This package contains data structures and utilities for dynamic optimization
Pyomo MPC contains data structures and utilities for dynamic optimization
and rolling horizon applications, e.g. model predictive control.

.. toctree::
Expand All @@ -10,3 +10,23 @@ and rolling horizon applications, e.g. model predictive control.
overview.rst
examples.rst
faq.rst
api.rst

Citation
--------

If you use Pyomo MPC in your research, please cite the following paper:

.. code-block:: bibtex
@article{parker2023mpc,
title = {Model predictive control simulations with block-hierarchical differential-algebraic process models},
journal = {Journal of Process Control},
volume = {132},
pages = {103113},
year = {2023},
issn = {0959-1524},
doi = {https://doi.org/10.1016/j.jprocont.2023.103113},
url = {https://www.sciencedirect.com/science/article/pii/S0959152423002007},
author = {Robert B. Parker and Bethany L. Nicholson and John D. Siirola and Lorenz T. Biegler},
}
8 changes: 8 additions & 0 deletions doc/OnlineDocs/contributed_packages/mpc/interface.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Interfaces
==========

.. automodule:: pyomo.contrib.mpc.interfaces.model_interface
:members:

.. automodule:: pyomo.contrib.mpc.interfaces.var_linker
:members:
11 changes: 11 additions & 0 deletions doc/OnlineDocs/contributed_packages/mpc/modeling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Modeling Components
===================

.. automodule:: pyomo.contrib.mpc.modeling.constraints
:members:

.. automodule:: pyomo.contrib.mpc.modeling.cost_expressions
:members:

.. automodule:: pyomo.contrib.mpc.modeling.terminal
:members:
51 changes: 50 additions & 1 deletion doc/OnlineDocs/contributed_packages/pyros.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ PyROS Solver Interface

Otherwise, the solution returned is certified to only be robust feasible.


PyROS Uncertainty Sets
-----------------------------
Uncertainty sets are represented by subclasses of
Expand Down Expand Up @@ -518,7 +519,7 @@ correspond to first-stage degrees of freedom.

>>> # === Designate which variables correspond to first-stage
>>> # and second-stage degrees of freedom ===
>>> first_stage_variables =[
>>> first_stage_variables = [
... m.x1, m.x2, m.x3, m.x4, m.x5, m.x6,
... m.x19, m.x20, m.x21, m.x22, m.x23, m.x24, m.x31,
... ]
Expand Down Expand Up @@ -657,6 +658,54 @@ For this example, we notice a ~25% decrease in the final objective
value when switching from a static decision rule (no second-stage recourse)
to an affine decision rule.


Specifying Arguments Indirectly Through ``options``
"""""""""""""""""""""""""""""""""""""""""""""""""""
Like other Pyomo solver interface methods,
:meth:`~pyomo.contrib.pyros.PyROS.solve`
provides support for specifying options indirectly by passing
a keyword argument ``options``, whose value must be a :class:`dict`
mapping names of arguments to :meth:`~pyomo.contrib.pyros.PyROS.solve`
to their desired values.
For example, the ``solve()`` statement in the
:ref:`two-stage problem snippet <example-two-stg>`
could have been equivalently written as:

.. doctest::
:skipif: not (baron.available() and baron.license_is_valid())

>>> results_2 = pyros_solver.solve(
... model=m,
... first_stage_variables=first_stage_variables,
... second_stage_variables=second_stage_variables,
... uncertain_params=uncertain_parameters,
... uncertainty_set=box_uncertainty_set,
... local_solver=local_solver,
... global_solver=global_solver,
... options={
... "objective_focus": pyros.ObjectiveType.worst_case,
... "solve_master_globally": True,
... "decision_rule_order": 1,
... },
... )
==============================================================================
PyROS: The Pyomo Robust Optimization Solver.
...
------------------------------------------------------------------------------
Robust optimal solution identified.
------------------------------------------------------------------------------
...
------------------------------------------------------------------------------
All done. Exiting PyROS.
==============================================================================

In the event an argument is passed directly
by position or keyword, *and* indirectly through ``options``,
an appropriate warning is issued,
and the value passed directly takes precedence over the value
passed through ``options``.


The Price of Robustness
""""""""""""""""""""""""
In conjunction with standard Python control flow tools,
Expand Down
2 changes: 2 additions & 0 deletions doc/OnlineDocs/library_reference/common/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Domain validators
NonPositiveFloat
NonNegativeFloat
In
IsInstance
InEnum
ListOf
Module
Expand Down Expand Up @@ -75,6 +76,7 @@ Domain validators
.. autofunction:: NonPositiveFloat
.. autofunction:: NonNegativeFloat
.. autoclass:: In
.. autoclass:: IsInstance
.. autoclass:: InEnum
.. autoclass:: ListOf
.. autoclass:: Module
Expand Down
2 changes: 0 additions & 2 deletions pyomo/common/_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
Management of Pyomo commands
"""

__all__ = ['pyomo_command', 'get_pyomo_commands']

import logging

logger = logging.getLogger('pyomo.common')
Expand Down
2 changes: 1 addition & 1 deletion pyomo/common/autoslots.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _deepcopy_tuple(obj, memo, _id):
unchanged = False
if unchanged:
# Python does not duplicate "unchanged" tuples (i.e. allows the
# original objecct to be returned from deepcopy()). We will
# original object to be returned from deepcopy()). We will
# preserve that behavior here.
#
# It also appears to be faster *not* to cache the fact that this
Expand Down
2 changes: 1 addition & 1 deletion pyomo/common/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
from collections import UserDict

from .orderedset import OrderedDict, OrderedSet
from .component_map import ComponentMap
from .component_map import ComponentMap, DefaultComponentMap
from .component_set import ComponentSet
from .bunch import Bunch
Loading

0 comments on commit bad123d

Please sign in to comment.