Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/pyomo/pyomo into incidence-…
Browse files Browse the repository at this point in the history
…amplrepn
  • Loading branch information
Robbybp committed Jan 22, 2024
2 parents f279fed + 74f18cf commit 3196e8d
Show file tree
Hide file tree
Showing 323 changed files with 3,239 additions and 2,768 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ jobs:
python: 3.9
TARGET: win
PYENV: conda
PACKAGES: glpk
PACKAGES: glpk pytest-qt

- os: ubuntu-latest
python: '3.11'
other: /conda
skip_doctest: 1
TARGET: linux
PYENV: conda
PACKAGES:
PACKAGES: pytest-qt

- os: ubuntu-latest
python: 3.9
Expand Down Expand Up @@ -213,6 +213,15 @@ jobs:
auto-update-conda: false
python-version: ${{ matrix.python }}

# This is necessary for qt (UI) tests; the package utilized here does not
# have support for OSX.
- name: Set up UI testing infrastructure
if: ${{ matrix.TARGET != 'osx' }}
uses: pyvista/setup-headless-display-action@v2
with:
qt: true
pyvista: false

# GitHub actions is very fragile when it comes to setting up various
# Python interpreters, expecially the setup-miniconda interface.
# Per the setup-miniconda documentation, it is important to always
Expand Down Expand Up @@ -309,7 +318,7 @@ jobs:
fi
# HACK: Remove problem packages on conda+Linux
if test "${{matrix.TARGET}}" == linux; then
EXCLUDE="casadi numdifftools pint $EXCLUDE"
EXCLUDE="casadi numdifftools $EXCLUDE"
fi
EXCLUDE=`echo "$EXCLUDE" | xargs`
if test -n "$EXCLUDE"; then
Expand Down Expand Up @@ -346,10 +355,11 @@ jobs:
| sed -r 's/\s+/ /g' | cut -d\ -f3) || echo ""
if test -n "$_BUILDS"; then
_ISPY=$(echo "$_BUILDS" | grep "^py") \
|| echo "No python build detected"
_PYOK=$(echo "$_BUILDS" | grep "^$PYVER") \
|| echo "No python build matching $PYVER detected"
|| echo "INFO: No python build detected."
_PYOK=$(echo "$_BUILDS" | grep -E "^($PYVER|pyh)") \
|| echo "INFO: No python build matching $PYVER detected."
if test -z "$_ISPY" -o -n "$_PYOK"; then
echo ""
echo "... INSTALLING $PKG"
conda install -y "$PKG" || _BUILDS=""
fi
Expand All @@ -358,18 +368,6 @@ jobs:
echo "WARNING: $PKG is not available"
fi
done
# TODO: This is a hack to stop test_qt.py from running until we
# can better troubleshoot why it fails on GHA
for QTPACKAGE in qt pyqt; do
# Because conda is insane, removing packages can cause
# unrelated packages to be updated (breaking version
# specifications specified previously, e.g., in
# setup.py). There doesn't appear to be a good
# workaround, so we will just force-remove (recognizing
# that it may break other conda cruft).
conda remove --force-remove $QTPACKAGE \
|| echo "$QTPACKAGE not in this environment"
done
fi
# Re-try Pyomo (optional) dependencies with pip
if test -n "$PYPI_DEPENDENCIES"; then
Expand Down Expand Up @@ -623,7 +621,7 @@ jobs:
$PYTHON_EXE -m pytest -v \
-W ignore::Warning ${{matrix.category}} \
pyomo `pwd`/pyomo-model-libraries \
`pwd`/examples/pyomobook --junitxml="TEST-pyomo.xml"
`pwd`/examples `pwd`/doc --junitxml="TEST-pyomo.xml"
- name: Run Pyomo MPI tests
if: matrix.mpi != 0
Expand Down
36 changes: 17 additions & 19 deletions .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ jobs:
- os: windows-latest
TARGET: win
PYENV: conda
PACKAGES: glpk
PACKAGES: glpk pytest-qt

- os: ubuntu-latest
python: '3.11'
other: /conda
skip_doctest: 1
TARGET: linux
PYENV: conda
PACKAGES:
PACKAGES: pytest-qt

- os: ubuntu-latest
python: 3.9
Expand Down Expand Up @@ -243,6 +243,15 @@ jobs:
auto-update-conda: false
python-version: ${{ matrix.python }}

# This is necessary for qt (UI) tests; the package utilized here does not
# have support for OSX.
- name: Set up UI testing infrastructure
if: ${{ matrix.TARGET != 'osx' }}
uses: pyvista/setup-headless-display-action@v2
with:
qt: true
pyvista: false

# GitHub actions is very fragile when it comes to setting up various
# Python interpreters, expecially the setup-miniconda interface.
# Per the setup-miniconda documentation, it is important to always
Expand Down Expand Up @@ -339,7 +348,7 @@ jobs:
fi
# HACK: Remove problem packages on conda+Linux
if test "${{matrix.TARGET}}" == linux; then
EXCLUDE="casadi numdifftools pint $EXCLUDE"
EXCLUDE="casadi numdifftools $EXCLUDE"
fi
EXCLUDE=`echo "$EXCLUDE" | xargs`
if test -n "$EXCLUDE"; then
Expand Down Expand Up @@ -376,10 +385,11 @@ jobs:
| sed -r 's/\s+/ /g' | cut -d\ -f3) || echo ""
if test -n "$_BUILDS"; then
_ISPY=$(echo "$_BUILDS" | grep "^py") \
|| echo "No python build detected"
_PYOK=$(echo "$_BUILDS" | grep "^$PYVER") \
|| echo "No python build matching $PYVER detected"
|| echo "INFO: No python build detected."
_PYOK=$(echo "$_BUILDS" | grep -E "^($PYVER|pyh)") \
|| echo "INFO: No python build matching $PYVER detected."
if test -z "$_ISPY" -o -n "$_PYOK"; then
echo ""
echo "... INSTALLING $PKG"
conda install -y "$PKG" || _BUILDS=""
fi
Expand All @@ -388,18 +398,6 @@ jobs:
echo "WARNING: $PKG is not available"
fi
done
# TODO: This is a hack to stop test_qt.py from running until we
# can better troubleshoot why it fails on GHA
for QTPACKAGE in qt pyqt; do
# Because conda is insane, removing packages can cause
# unrelated packages to be updated (breaking version
# specifications specified previously, e.g., in
# setup.py). There doesn't appear to be a good
# workaround, so we will just force-remove (recognizing
# that it may break other conda cruft).
conda remove --force-remove $QTPACKAGE \
|| echo "$QTPACKAGE not in this environment"
done
fi
# Re-try Pyomo (optional) dependencies with pip
if test -n "$PYPI_DEPENDENCIES"; then
Expand Down Expand Up @@ -653,7 +651,7 @@ jobs:
$PYTHON_EXE -m pytest -v \
-W ignore::Warning ${{matrix.category}} \
pyomo `pwd`/pyomo-model-libraries \
`pwd`/examples/pyomobook --junitxml="TEST-pyomo.xml"
`pwd`/examples `pwd`/doc --junitxml="TEST-pyomo.xml"
- name: Run Pyomo MPI tests
if: matrix.mpi != 0
Expand Down
2 changes: 1 addition & 1 deletion .jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if test -z "$WORKSPACE"; then
export WORKSPACE=`pwd`
fi
if test -z "$TEST_SUITES"; then
export TEST_SUITES="${WORKSPACE}/pyomo/pyomo ${WORKSPACE}/pyomo-model-libraries ${WORKSPACE}/pyomo/examples/pyomobook"
export TEST_SUITES="${WORKSPACE}/pyomo/pyomo ${WORKSPACE}/pyomo-model-libraries ${WORKSPACE}/pyomo/examples ${WORKSPACE}/pyomo/doc"
fi
if test -z "$SLIM"; then
export VENV_SYSTEM_PACKAGES='--system-site-packages'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ version, we will remove testing for that Python version.

### Tutorials and Examples

* [Pyomo Workshop Slides](https://software.sandia.gov/downloads/pub/pyomo/Pyomo-Workshop-Summer-2018.pdf)
* [Pyomo Workshop Slides](https://github.com/Pyomo/pyomo-tutorials/blob/main/Pyomo-Workshop-December-2023.pdf)
* [Prof. Jeffrey Kantor's Pyomo Cookbook](https://jckantor.github.io/ND-Pyomo-Cookbook/)
* [Pyomo Gallery](https://github.com/Pyomo/PyomoGallery)

Expand Down
2 changes: 1 addition & 1 deletion doc/OnlineDocs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ clean clean_tests:
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "Removing *.spy, *.out"
@find . -name \*.spy -delete
@find tests -name \*.out -delete
@find src -name \*.out -delete
8 changes: 5 additions & 3 deletions doc/OnlineDocs/advanced_topics/linearexpression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ LinearExpression
================

Significant speed
improvements can be obtained using the ``LinearExpression`` object
improvements can sometimes be obtained using the ``LinearExpression`` object
when there are long, dense, linear expressions. The arguments are

::
Expand All @@ -11,7 +11,9 @@ when there are long, dense, linear expressions. The arguments are

where the second and third arguments are lists that must be of the
same length. Here is a simple example that illustrates the
syntax. This example creates two constraints that are the same:
syntax. This example creates two constraints that are the same; in this
particular case the LinearExpression component would offer very little improvement
because Pyomo would be able to detect that `campe2` is a linear expression:

.. doctest::

Expand All @@ -38,5 +40,5 @@ syntax. This example creates two constraints that are the same:

.. warning::

The lists that are passed to ``LinearModel`` are not copied, so caution must
The lists that are passed to ``LinearExpression`` are not copied, so caution must
be exercised if they are modified after the component is constructed.
4 changes: 2 additions & 2 deletions doc/OnlineDocs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
sys.path.insert(0, os.path.abspath('../..'))

# -- Rebuild SPY files ----------------------------------------------------
sys.path.insert(0, os.path.abspath('tests'))
sys.path.insert(0, os.path.abspath('src'))
try:
print("Regenerating SPY files...")
from strip_examples import generate_spy_files

generate_spy_files(os.path.abspath('tests'))
generate_spy_files(os.path.abspath('src'))
generate_spy_files(
os.path.abspath(os.path.join('library_reference', 'kernel', 'examples'))
)
Expand Down
4 changes: 2 additions & 2 deletions doc/OnlineDocs/contributed_packages/doe/doe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ It allows users to define any number of design decisions. Heatmaps can be drawn
The function ``run_grid_search`` enumerates over the design space, each MBDoE problem accomplished by ``compute_FIM`` method.
Therefore, ``run_grid_search`` supports only two modes: ``sequential_finite`` and ``direct_kaug``.

.. literalinclude:: ../../../../pyomo/contrib/doe/examples/reactor_compute_FIM.py
.. literalinclude:: ../../../../pyomo/contrib/doe/examples/reactor_grid_search.py
:language: python
:pyobject: main

Expand All @@ -284,7 +284,7 @@ Pyomo.DoE accomplishes gradient-based optimization with the ``stochastic_program

This function solves twice: It solves the square version of the MBDoE problem first, and then unfixes the design variables as degree of freedoms and solves again. In this way the optimization problem can be well initialized.

.. literalinclude:: ../../../../pyomo/contrib/doe/examples/reactor_compute_FIM.py
.. literalinclude:: ../../../../pyomo/contrib/doe/examples/reactor_optimize_doe.py
:language: python
:pyobject: main

Expand Down
3 changes: 3 additions & 0 deletions doc/OnlineDocs/contributed_packages/gdpopt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ To use the GDPopt-LBB solver, define your Pyomo GDP model as usual:
>>> m.djn = Disjunction(expr=[m.y1, m.y2])

Invoke the GDPopt-LBB solver

>>> results = SolverFactory('gdpopt.lbb').solve(m)
WARNING: 09/06/22: The GDPopt LBB algorithm currently has known issues. Please
use the results with caution and report any bugs!

>>> print(results) # doctest: +SKIP
>>> print(results.solver.status)
Expand Down
43 changes: 20 additions & 23 deletions doc/OnlineDocs/contributed_packages/pyros.rst
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,11 @@ For this example, we obtain the following price of robustness results:
+==========================================+==============================+=============================+
| 0.00 | 35,837,659.18 | 0.00 % |
+------------------------------------------+------------------------------+-----------------------------+
| 0.10 | 36,135,191.59 | 0.82 % |
| 0.10 | 36,135,182.66 | 0.83 % |
+------------------------------------------+------------------------------+-----------------------------+
| 0.20 | 36,437,979.81 | 1.64 % |
| 0.20 | 36,437,979.81 | 1.68 % |
+------------------------------------------+------------------------------+-----------------------------+
| 0.30 | 43,478,190.92 | 17.57 % |
| 0.30 | 43,478,190.91 | 21.32 % |
+------------------------------------------+------------------------------+-----------------------------+
| 0.40 | ``robust_infeasible`` | :math:`\text{-----}` |
+------------------------------------------+------------------------------+-----------------------------+
Expand Down Expand Up @@ -854,10 +854,10 @@ Observe that the log contains the following information:
:linenos:
==============================================================================
PyROS: The Pyomo Robust Optimization Solver, v1.2.8.
PyROS: The Pyomo Robust Optimization Solver, v1.2.9.
Pyomo version: 6.7.0
Commit hash: unknown
Invoked at UTC 2023-11-03T04:27:42.954101
Invoked at UTC 2023-12-16T00:00:00.000000
Developed by: Natalie M. Isenberg (1), Jason A. F. Sherman (1),
John D. Siirola (2), Chrysanthos E. Gounaris (1)
Expand Down Expand Up @@ -914,37 +914,34 @@ Observe that the log contains the following information:
------------------------------------------------------------------------------
Itn Objective 1-Stg Shift 2-Stg Shift #CViol Max Viol Wall Time (s)
------------------------------------------------------------------------------
0 3.5838e+07 - - 5 1.8832e+04 1.555
1 3.5838e+07 2.2045e-12 2.7854e-12 7 3.7766e+04 2.991
2 3.6116e+07 1.2324e-01 3.9256e-01 8 1.3466e+06 4.881
3 3.6285e+07 5.1968e-01 4.5604e-01 6 4.8734e+03 6.908
4 3.6285e+07 2.6524e-13 1.3909e-13 1 3.5036e+01 9.176
5 3.6285e+07 2.0167e-13 5.4357e-02 6 2.9103e+00 11.457
6 3.6285e+07 2.2335e-12 1.2150e-01 5 4.1726e-01 13.868
7 3.6285e+07 2.2340e-12 1.1422e-01 0 9.3279e-10g 20.917
0 3.5838e+07 - - 5 1.8832e+04 1.741
1 3.5838e+07 3.5184e-15 3.9404e-15 10 4.2516e+06 3.766
2 3.5993e+07 1.8105e-01 7.1406e-01 13 5.2004e+06 6.288
3 3.6285e+07 5.1968e-01 7.7753e-01 4 1.7892e+04 8.247
4 3.6285e+07 9.1166e-13 1.9702e-15 0 7.1157e-10g 11.456
------------------------------------------------------------------------------
Robust optimal solution identified.
------------------------------------------------------------------------------
Timing breakdown:
Identifier ncalls cumtime percall %
-----------------------------------------------------------
main 1 20.918 20.918 100.0
main 1 11.457 11.457 100.0
------------------------------------------------------
dr_polishing 7 1.472 0.210 7.0
global_separation 47 1.239 0.026 5.9
local_separation 376 9.244 0.025 44.2
master 8 5.259 0.657 25.1
master_feasibility 7 0.486 0.069 2.3
preprocessing 1 0.403 0.403 1.9
other n/a 2.815 n/a 13.5
dr_polishing 4 0.682 0.171 6.0
global_separation 47 1.109 0.024 9.7
local_separation 235 5.810 0.025 50.7
master 5 1.353 0.271 11.8
master_feasibility 4 0.247 0.062 2.2
preprocessing 1 0.429 0.429 3.7
other n/a 1.828 n/a 16.0
======================================================
===========================================================
------------------------------------------------------------------------------
Termination stats:
Iterations : 8
Solve time (wall s) : 20.918
Iterations : 5
Solve time (wall s) : 11.457
Final objective value : 3.6285e+07
Termination condition : pyrosTerminationCondition.robust_optimal
------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions doc/OnlineDocs/developer_reference/expressions/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Expression trees can be categorized in four different ways:

These three categories are illustrated with the following example:

.. literalinclude:: ../../tests/expr/design_categories.spy
.. literalinclude:: ../../src/expr/design_categories.spy

The following table describes four different simple expressions
that consist of a single model component, and it shows how they
Expand Down Expand Up @@ -107,7 +107,7 @@ Named expressions allow for changes to an expression after it has
been constructed. For example, consider the expression ``f`` defined
with the :class:`Expression <pyomo.core.base.Expression>` component:

.. literalinclude:: ../../tests/expr/design_named_expression.spy
.. literalinclude:: ../../src/expr/design_named_expression.spy

Although ``f`` is an immutable expression, whose definition is
fixed, a sub-expressions is the named expression ``M.e``. Named
Expand Down Expand Up @@ -227,7 +227,7 @@ The :data:`linear_expression <pyomo.core.expr.linear_expression>`
object is a context manager that can be used to declare a linear sum. For
example, consider the following two loops:

.. literalinclude:: ../../tests/expr/design_cm1.spy
.. literalinclude:: ../../src/expr/design_cm1.spy

The first apparent difference in these loops is that the value of
``s`` is explicitly initialized while ``e`` is initialized when the
Expand All @@ -250,7 +250,7 @@ construct different expressions with different context declarations.
Finally, note that these context managers can be passed into the :attr:`start`
method for the :func:`quicksum <pyomo.core.util.quicksum>` function. For example:

.. literalinclude:: ../../tests/expr/design_cm2.spy
.. literalinclude:: ../../src/expr/design_cm2.spy

This sum contains terms for ``M.x[i]`` and ``M.y[i]``. The syntax
in this example is not intuitive because the sum is being stored
Expand Down
2 changes: 1 addition & 1 deletion doc/OnlineDocs/developer_reference/expressions/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ nodes contain operators. Pyomo relies on so-called magic methods
to automate the construction of symbolic expressions. For example,
consider an expression ``e`` declared as follows:

.. literalinclude:: ../../tests/expr/index_simple.spy
.. literalinclude:: ../../src/expr/index_simple.spy

Python determines that the magic method ``__mul__`` is called on
the ``M.v`` object, with the argument ``2``. This method returns
Expand Down
Loading

0 comments on commit 3196e8d

Please sign in to comment.