Skip to content

Commit

Permalink
Merge pull request Pyomo#3453 from mrmundt/new-typos
Browse files Browse the repository at this point in the history
New year infrastructure / CI fixes
  • Loading branch information
mrmundt authored Jan 14, 2025
2 parents 83767d3 + 7d67333 commit b2cb3ae
Show file tree
Hide file tree
Showing 17 changed files with 227 additions and 151 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release_wheel_creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
arch: [all]
wheel-version: ['cp39*', 'cp310*', 'cp311*', 'cp312*', 'cp313*']

Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
os: [ubuntu-latest]
arch: [all]
wheel-version: ['cp39*', 'cp310*', 'cp311*', 'cp312*', 'cp313*']

Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
# have support for OSX.
- name: Set up UI testing infrastructure
if: ${{ matrix.TARGET != 'osx' }}
uses: pyvista/setup-headless-display-action@v2
uses: pyvista/setup-headless-display-action@v3
with:
qt: true
pyvista: false
Expand Down Expand Up @@ -428,13 +428,18 @@ jobs:
mkdir -p "$DOWNLOAD_DIR"
echo "TPL_DIR=$TPL_DIR" >> $GITHUB_ENV
echo "DOWNLOAD_DIR=$DOWNLOAD_DIR" >> $GITHUB_ENV
# Create a new PYOMO_PATH variable so we can ensure that we are actually
# getting the right PATH at the end
echo "PYOMO_PATH=$PATH" >> $GITHUB_ENV
- name: Install Ipopt
if: ${{ ! matrix.slim }}
run: |
IPOPT_DIR=$TPL_DIR/ipopt
echo "$IPOPT_DIR" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IPOPT_DIR" >> $GITHUB_ENV
NEW_PYOMO_PATH="$IPOPT_DIR:$PYOMO_PATH"
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
mkdir -p $IPOPT_DIR
IPOPT_TAR=${DOWNLOAD_DIR}/ipopt.tar.gz
if test ! -e $IPOPT_TAR; then
Expand Down Expand Up @@ -511,7 +516,9 @@ jobs:
- name: Install GAMS Python bindings
if: ${{ ! matrix.slim }}
run: |
GAMS_DIR="${env:TPL_DIR}/gams"
GAMS_DIR="$TPL_DIR/gams"
NEW_PYOMO_PATH="$GAMS_DIR:$PYOMO_PATH"
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
py_ver=$($PYTHON_EXE -c 'import sys;v="_%s%s" % sys.version_info[:2] \
;print(v if v != "_27" else "")')
if test -e $GAMS_DIR/apifiles/Python/api$py_ver; then
Expand All @@ -528,6 +535,17 @@ jobs:
$BARON_DIR = "${env:TPL_DIR}/baron"
echo "$BARON_DIR" | `
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$CURRENT_PYOMO_PATH="${env:PYOMO_PATH}"
# Prepend BARON_DIR with appropriate path separator
if ( "${{matrix.TARGET}}" -eq "win" ) {
$PATH_SEPARATOR = ";"
} else {
$PATH_SEPARATOR = ":"
}
$NEW_PYOMO_PATH = "$BARON_DIR$PATH_SEPARATOR$CURRENT_PYOMO_PATH"
echo "New PYOMO_PATH: $NEW_PYOMO_PATH"
echo "PYOMO_PATH=$NEW_PYOMO_PATH" | `
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$URL = "https://minlp-downloads.nyc3.cdn.digitaloceanspaces.com/xecs/baron/current/"
if ( "${{matrix.TARGET}}" -eq "win" ) {
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
Expand Down Expand Up @@ -562,6 +580,8 @@ jobs:
run: |
GJH_DIR="$TPL_DIR/gjh"
echo "${GJH_DIR}" >> $GITHUB_PATH
NEW_PYOMO_PATH="$GJH_DIR:$PYOMO_PATH"
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
INSTALL_DIR="${DOWNLOAD_DIR}/gjh"
if test ! -e "$INSTALL_DIR/bin"; then
mkdir -p "$INSTALL_DIR"
Expand Down Expand Up @@ -637,6 +657,11 @@ jobs:
- name: Report pyomo plugin information
run: |
# MRM / Jan 9, 2025: We update the PATH manually to make sure we
# capture all of our changes. This is necessary because of an
# issue with how the PATH rearranges on Windows.
# Issue: https://github.com/actions/runner-images/issues/11328
export PATH=$PYOMO_PATH
echo "$PATH"
pyomo help --solvers || exit 1
pyomo help --transformations || exit 1
Expand All @@ -645,6 +670,7 @@ jobs:
- name: Run Pyomo tests
if: matrix.mpi == 0
run: |
export PATH=$PYOMO_PATH
$PYTHON_EXE -m pytest -v \
-W ignore::Warning ${{matrix.category}} \
pyomo `pwd`/pyomo-model-libraries \
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
PACKAGES: pyutilib

- os: ubuntu-latest
python: pypy-3.9
python: 'pypy-3.10'
skip_doctest: 1
TARGET: linux
PYENV: pip
Expand Down Expand Up @@ -266,7 +266,7 @@ jobs:
# have support for OSX.
- name: Set up UI testing infrastructure
if: ${{ matrix.TARGET != 'osx' }}
uses: pyvista/setup-headless-display-action@v2
uses: pyvista/setup-headless-display-action@v3
with:
qt: true
pyvista: false
Expand Down Expand Up @@ -460,13 +460,18 @@ jobs:
mkdir -p "$DOWNLOAD_DIR"
echo "TPL_DIR=$TPL_DIR" >> $GITHUB_ENV
echo "DOWNLOAD_DIR=$DOWNLOAD_DIR" >> $GITHUB_ENV
# Create a new PYOMO_PATH variable so we can ensure that we are actually
# getting the right PATH at the end
echo "PYOMO_PATH=$PATH" >> $GITHUB_ENV
- name: Install Ipopt
if: ${{ ! matrix.slim }}
run: |
IPOPT_DIR=$TPL_DIR/ipopt
echo "$IPOPT_DIR" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IPOPT_DIR" >> $GITHUB_ENV
NEW_PYOMO_PATH="$IPOPT_DIR:$PYOMO_PATH"
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
mkdir -p $IPOPT_DIR
IPOPT_TAR=${DOWNLOAD_DIR}/ipopt.tar.gz
if test ! -e $IPOPT_TAR; then
Expand Down Expand Up @@ -543,7 +548,9 @@ jobs:
- name: Install GAMS Python bindings
if: ${{ ! matrix.slim }}
run: |
GAMS_DIR="${env:TPL_DIR}/gams"
GAMS_DIR="$TPL_DIR/gams"
NEW_PYOMO_PATH="$GAMS_DIR:$PYOMO_PATH"
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
py_ver=$($PYTHON_EXE -c 'import sys;v="_%s%s" % sys.version_info[:2] \
;print(v if v != "_27" else "")')
if test -e $GAMS_DIR/apifiles/Python/api$py_ver; then
Expand All @@ -560,6 +567,17 @@ jobs:
$BARON_DIR = "${env:TPL_DIR}/baron"
echo "$BARON_DIR" | `
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$CURRENT_PYOMO_PATH="${env:PYOMO_PATH}"
# Prepend BARON_DIR with appropriate path separator
if ( "${{matrix.TARGET}}" -eq "win" ) {
$PATH_SEPARATOR = ";"
} else {
$PATH_SEPARATOR = ":"
}
$NEW_PYOMO_PATH = "$BARON_DIR$PATH_SEPARATOR$CURRENT_PYOMO_PATH"
echo "New PYOMO_PATH: $NEW_PYOMO_PATH"
echo "PYOMO_PATH=$NEW_PYOMO_PATH" | `
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$URL = "https://minlp-downloads.nyc3.cdn.digitaloceanspaces.com/xecs/baron/current/"
if ( "${{matrix.TARGET}}" -eq "win" ) {
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
Expand Down Expand Up @@ -594,6 +612,8 @@ jobs:
run: |
GJH_DIR="$TPL_DIR/gjh"
echo "${GJH_DIR}" >> $GITHUB_PATH
NEW_PYOMO_PATH="$GJH_DIR:$PYOMO_PATH"
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
INSTALL_DIR="${DOWNLOAD_DIR}/gjh"
if test ! -e "$INSTALL_DIR/bin"; then
mkdir -p "$INSTALL_DIR"
Expand Down Expand Up @@ -670,6 +690,11 @@ jobs:
- name: Report pyomo plugin information
run: |
# MRM / Jan 9, 2025: We update the PATH manually to make sure we
# capture all of our changes. This is necessary because of an
# issue with how the PATH rearranges on Windows.
# Issue: https://github.com/actions/runner-images/issues/11328
export PATH=$PYOMO_PATH
echo "$PATH"
pyomo help --solvers || exit 1
pyomo help --transformations || exit 1
Expand All @@ -678,6 +703,7 @@ jobs:
- name: Run Pyomo tests
if: matrix.mpi == 0
run: |
export PATH=$PYOMO_PATH
$PYTHON_EXE -m pytest -v \
-W ignore::Warning ${{matrix.category}} \
pyomo `pwd`/pyomo-model-libraries \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Pyomo is available under the BSD License - see the
Pyomo is currently tested with the following Python implementations:

* CPython: 3.9, 3.10, 3.11, 3.12, 3.13
* PyPy: 3.9
* PyPy: 3.10

_Testing and support policy_:

Expand Down
2 changes: 1 addition & 1 deletion doc/OnlineDocs/explanation/analysis/doe/doe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Pyomo.DoE

**Pyomo.DoE** (Pyomo Design of Experiments) is a Python library for model-based design of experiments using science-based models.

Pyomo.DoE was developed by **Jialu Wang** and **Alexander W. Dowling** at the University of Notre Dame as part of the `Carbon Capture Simulation for Industry Impact (CCSI2) <https://www.acceleratecarboncapture.org/>`_.
Pyomo.DoE was developed by **Jialu Wang** and **Alexander W. Dowling** at the University of Notre Dame as part of the `Carbon Capture Simulation for Industry Impact (CCSI2) <https://github.com/CCSI-Toolset/>`_.
project, funded through the U.S. Department Of Energy Office of Fossil Energy.

If you use Pyomo.DoE, please cite:
Expand Down
16 changes: 14 additions & 2 deletions doc/OnlineDocs/explanation/analysis/sensitivity_toolbox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ And finally we call sIPOPT or k_aug:
>>> m_sipopt = sensitivity_calculation('sipopt', m, [m.eta1, m.eta2], [m.perturbed_eta1, m.perturbed_eta2], tee=False)
>>> m_kaug_dsdp = sensitivity_calculation('k_aug', m, [m.eta1, m.eta2], [m.perturbed_eta1, m.perturbed_eta2], tee=False)

.. testcode:: python
:skipif: not sipopt_available or not k_aug_available or not dot_sens_available
:hide:

# The x3 result can come back -0.000 depending on the platform or
# solver version; map it so that tests don't fail.
for _m in (m, m_sipopt, m_kaug_dsdp):
if f'{_m.x3():.3f}' == '-0.000':
_m.x3 = 0.
if f'{m_sipopt.sens_sol_state_1[m_sipopt.x3]:.3f}' == '-0.000':
m_sipopt.sens_sol_state_1[m_sipopt.x3] = 0.

The first argument specifies the method, either 'sipopt' or 'k_aug'. The second argument is the Pyomo model. The third argument is a list of the original parameters. The fourth argument is a list of the perturbed parameters. It's important that these two lists are the same length and in the same order.

First, we can inspect the initial point:
Expand Down Expand Up @@ -138,7 +150,7 @@ Note that k_aug does not save the solution with the original parameter values. F
x2 = 0.667

>>> print("x3 = %0.3f" % x3)
x3 = -0.000
x3 = 0.000

# *k_aug*
# New parameter values:
Expand All @@ -162,7 +174,7 @@ Note that k_aug does not save the solution with the original parameter values. F
x2 = 0.667

>>> print("x3 = %0.3f" % x3)
x3 = -0.000
x3 = 0.000


Installing sIPOPT and k_aug
Expand Down
6 changes: 5 additions & 1 deletion pyomo/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,11 @@ def __call__(
assert default is NOTSET
else:
fields += ('domain',)
kwds['default'] = self.value() if default is NOTSET else default
if default is NOTSET:
default = self.value()
if default is NOTSET:
default = None
kwds['default'] = default
assert implicit is NOTSET
assert implicit_domain is NOTSET
for field in fields:
Expand Down
6 changes: 3 additions & 3 deletions pyomo/contrib/doe/doe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ def compute_FIM_full_factorial(
}
)

succeses = 0
successes = 0
failures = 0
total_points = np.prod(
np.array([len(v) for k, v in design_ranges_enum.items()])
Expand All @@ -1477,14 +1477,14 @@ def compute_FIM_full_factorial(

# Compute FIM with given options
try:
curr_point = succeses + failures + 1
curr_point = successes + failures + 1

# Logging information for each run
self.logger.info("This is run %s out of %s.", curr_point, total_points)

# Attempt the FIM computation
self.compute_FIM(model=model, method=method)
succeses += 1
successes += 1

# iteration time
iter_t = iter_timer.toc(msg=None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import pyomo.common.unittest as unittest
import pyomo.environ as pyo
import os
from pyomo.common.tempfiles import TempfileManager

from pyomo.contrib.pynumero.dependencies import (
numpy as np,
Expand Down Expand Up @@ -219,24 +219,25 @@ def test_model1_with_scaling(self):
m.scaling_factor[m.d] = 3.0 # scale the inequality constraint
m.scaling_factor[m.x[1]] = 4.0 # scale one of the x variables

cynlp = CyIpoptNLP(PyomoNLP(m))
options = {
'nlp_scaling_method': 'user-scaling',
'output_file': '_cyipopt-scaling.log',
'file_print_level': 10,
'max_iter': 0,
}
solver = CyIpoptSolver(cynlp, options=options)
x, info = solver.solve()

with open('_cyipopt-scaling.log', 'r') as fd:
solver_trace = fd.read()
cynlp.close()
os.remove('_cyipopt-scaling.log')

# check for the following strings in the log and then delete the log
with TempfileManager.new_context() as temp:
cynlp = CyIpoptNLP(PyomoNLP(m))
logfile = temp.create_tempfile('_cyipopt-scaling.log')
options = {
'nlp_scaling_method': 'user-scaling',
'output_file': logfile,
'file_print_level': 10,
'max_iter': 0,
}
solver = CyIpoptSolver(cynlp, options=options)
x, info = solver.solve()
cynlp.close()

with open(logfile, 'r') as fd:
solver_trace = fd.read()

# check for the following strings in the log
self.assertIn('nlp_scaling_method = user-scaling', solver_trace)
self.assertIn('output_file = _cyipopt-scaling.log', solver_trace)
self.assertIn(f"output_file = {logfile}", solver_trace)
self.assertIn('objective scaling factor = 1e-06', solver_trace)
self.assertIn('x scaling provided', solver_trace)
self.assertIn('c scaling provided', solver_trace)
Expand Down
Loading

0 comments on commit b2cb3ae

Please sign in to comment.