Skip to content

Commit dcd9500

Browse files
authored
Merge branch 'main' into sas-available
2 parents 24ec6bc + b2cb3ae commit dcd9500

File tree

22 files changed

+398
-166
lines changed

22 files changed

+398
-166
lines changed

.github/workflows/release_wheel_creation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: true
2929
matrix:
30-
os: [ubuntu-22.04, windows-latest, macos-latest]
30+
os: [ubuntu-latest, windows-latest, macos-latest]
3131
arch: [all]
3232
wheel-version: ['cp39*', 'cp310*', 'cp311*', 'cp312*', 'cp313*']
3333

@@ -91,7 +91,7 @@ jobs:
9191
runs-on: ${{ matrix.os }}
9292
strategy:
9393
matrix:
94-
os: [ubuntu-22.04]
94+
os: [ubuntu-latest]
9595
arch: [all]
9696
wheel-version: ['cp39*', 'cp310*', 'cp311*', 'cp312*', 'cp313*']
9797

.github/workflows/test_branches.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ jobs:
234234
# have support for OSX.
235235
- name: Set up UI testing infrastructure
236236
if: ${{ matrix.TARGET != 'osx' }}
237-
uses: pyvista/setup-headless-display-action@v2
237+
uses: pyvista/setup-headless-display-action@v3
238238
with:
239239
qt: true
240240
pyvista: false
@@ -428,13 +428,18 @@ jobs:
428428
mkdir -p "$DOWNLOAD_DIR"
429429
echo "TPL_DIR=$TPL_DIR" >> $GITHUB_ENV
430430
echo "DOWNLOAD_DIR=$DOWNLOAD_DIR" >> $GITHUB_ENV
431+
# Create a new PYOMO_PATH variable so we can ensure that we are actually
432+
# getting the right PATH at the end
433+
echo "PYOMO_PATH=$PATH" >> $GITHUB_ENV
431434
432435
- name: Install Ipopt
433436
if: ${{ ! matrix.slim }}
434437
run: |
435438
IPOPT_DIR=$TPL_DIR/ipopt
436439
echo "$IPOPT_DIR" >> $GITHUB_PATH
437440
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IPOPT_DIR" >> $GITHUB_ENV
441+
NEW_PYOMO_PATH="$IPOPT_DIR:$PYOMO_PATH"
442+
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
438443
mkdir -p $IPOPT_DIR
439444
IPOPT_TAR=${DOWNLOAD_DIR}/ipopt.tar.gz
440445
if test ! -e $IPOPT_TAR; then
@@ -511,7 +516,9 @@ jobs:
511516
- name: Install GAMS Python bindings
512517
if: ${{ ! matrix.slim }}
513518
run: |
514-
GAMS_DIR="${env:TPL_DIR}/gams"
519+
GAMS_DIR="$TPL_DIR/gams"
520+
NEW_PYOMO_PATH="$GAMS_DIR:$PYOMO_PATH"
521+
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
515522
py_ver=$($PYTHON_EXE -c 'import sys;v="_%s%s" % sys.version_info[:2] \
516523
;print(v if v != "_27" else "")')
517524
if test -e $GAMS_DIR/apifiles/Python/api$py_ver; then
@@ -528,6 +535,17 @@ jobs:
528535
$BARON_DIR = "${env:TPL_DIR}/baron"
529536
echo "$BARON_DIR" | `
530537
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
538+
$CURRENT_PYOMO_PATH="${env:PYOMO_PATH}"
539+
# Prepend BARON_DIR with appropriate path separator
540+
if ( "${{matrix.TARGET}}" -eq "win" ) {
541+
$PATH_SEPARATOR = ";"
542+
} else {
543+
$PATH_SEPARATOR = ":"
544+
}
545+
$NEW_PYOMO_PATH = "$BARON_DIR$PATH_SEPARATOR$CURRENT_PYOMO_PATH"
546+
echo "New PYOMO_PATH: $NEW_PYOMO_PATH"
547+
echo "PYOMO_PATH=$NEW_PYOMO_PATH" | `
548+
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
531549
$URL = "https://minlp-downloads.nyc3.cdn.digitaloceanspaces.com/xecs/baron/current/"
532550
if ( "${{matrix.TARGET}}" -eq "win" ) {
533551
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
@@ -562,6 +580,8 @@ jobs:
562580
run: |
563581
GJH_DIR="$TPL_DIR/gjh"
564582
echo "${GJH_DIR}" >> $GITHUB_PATH
583+
NEW_PYOMO_PATH="$GJH_DIR:$PYOMO_PATH"
584+
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
565585
INSTALL_DIR="${DOWNLOAD_DIR}/gjh"
566586
if test ! -e "$INSTALL_DIR/bin"; then
567587
mkdir -p "$INSTALL_DIR"
@@ -637,6 +657,11 @@ jobs:
637657
638658
- name: Report pyomo plugin information
639659
run: |
660+
# MRM / Jan 9, 2025: We update the PATH manually to make sure we
661+
# capture all of our changes. This is necessary because of an
662+
# issue with how the PATH rearranges on Windows.
663+
# Issue: https://github.com/actions/runner-images/issues/11328
664+
export PATH=$PYOMO_PATH
640665
echo "$PATH"
641666
pyomo help --solvers || exit 1
642667
pyomo help --transformations || exit 1
@@ -645,6 +670,7 @@ jobs:
645670
- name: Run Pyomo tests
646671
if: matrix.mpi == 0
647672
run: |
673+
export PATH=$PYOMO_PATH
648674
$PYTHON_EXE -m pytest -v \
649675
-W ignore::Warning ${{matrix.category}} \
650676
pyomo `pwd`/pyomo-model-libraries \

.github/workflows/test_pr_and_main.yml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
PACKAGES: pyutilib
153153

154154
- os: ubuntu-latest
155-
python: pypy-3.9
155+
python: 'pypy-3.10'
156156
skip_doctest: 1
157157
TARGET: linux
158158
PYENV: pip
@@ -266,7 +266,7 @@ jobs:
266266
# have support for OSX.
267267
- name: Set up UI testing infrastructure
268268
if: ${{ matrix.TARGET != 'osx' }}
269-
uses: pyvista/setup-headless-display-action@v2
269+
uses: pyvista/setup-headless-display-action@v3
270270
with:
271271
qt: true
272272
pyvista: false
@@ -460,13 +460,18 @@ jobs:
460460
mkdir -p "$DOWNLOAD_DIR"
461461
echo "TPL_DIR=$TPL_DIR" >> $GITHUB_ENV
462462
echo "DOWNLOAD_DIR=$DOWNLOAD_DIR" >> $GITHUB_ENV
463+
# Create a new PYOMO_PATH variable so we can ensure that we are actually
464+
# getting the right PATH at the end
465+
echo "PYOMO_PATH=$PATH" >> $GITHUB_ENV
463466
464467
- name: Install Ipopt
465468
if: ${{ ! matrix.slim }}
466469
run: |
467470
IPOPT_DIR=$TPL_DIR/ipopt
468471
echo "$IPOPT_DIR" >> $GITHUB_PATH
469472
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IPOPT_DIR" >> $GITHUB_ENV
473+
NEW_PYOMO_PATH="$IPOPT_DIR:$PYOMO_PATH"
474+
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
470475
mkdir -p $IPOPT_DIR
471476
IPOPT_TAR=${DOWNLOAD_DIR}/ipopt.tar.gz
472477
if test ! -e $IPOPT_TAR; then
@@ -543,7 +548,9 @@ jobs:
543548
- name: Install GAMS Python bindings
544549
if: ${{ ! matrix.slim }}
545550
run: |
546-
GAMS_DIR="${env:TPL_DIR}/gams"
551+
GAMS_DIR="$TPL_DIR/gams"
552+
NEW_PYOMO_PATH="$GAMS_DIR:$PYOMO_PATH"
553+
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
547554
py_ver=$($PYTHON_EXE -c 'import sys;v="_%s%s" % sys.version_info[:2] \
548555
;print(v if v != "_27" else "")')
549556
if test -e $GAMS_DIR/apifiles/Python/api$py_ver; then
@@ -560,6 +567,17 @@ jobs:
560567
$BARON_DIR = "${env:TPL_DIR}/baron"
561568
echo "$BARON_DIR" | `
562569
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
570+
$CURRENT_PYOMO_PATH="${env:PYOMO_PATH}"
571+
# Prepend BARON_DIR with appropriate path separator
572+
if ( "${{matrix.TARGET}}" -eq "win" ) {
573+
$PATH_SEPARATOR = ";"
574+
} else {
575+
$PATH_SEPARATOR = ":"
576+
}
577+
$NEW_PYOMO_PATH = "$BARON_DIR$PATH_SEPARATOR$CURRENT_PYOMO_PATH"
578+
echo "New PYOMO_PATH: $NEW_PYOMO_PATH"
579+
echo "PYOMO_PATH=$NEW_PYOMO_PATH" | `
580+
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
563581
$URL = "https://minlp-downloads.nyc3.cdn.digitaloceanspaces.com/xecs/baron/current/"
564582
if ( "${{matrix.TARGET}}" -eq "win" ) {
565583
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
@@ -594,6 +612,8 @@ jobs:
594612
run: |
595613
GJH_DIR="$TPL_DIR/gjh"
596614
echo "${GJH_DIR}" >> $GITHUB_PATH
615+
NEW_PYOMO_PATH="$GJH_DIR:$PYOMO_PATH"
616+
echo "PYOMO_PATH=$NEW_PYOMO_PATH" >> $GITHUB_ENV
597617
INSTALL_DIR="${DOWNLOAD_DIR}/gjh"
598618
if test ! -e "$INSTALL_DIR/bin"; then
599619
mkdir -p "$INSTALL_DIR"
@@ -670,6 +690,11 @@ jobs:
670690
671691
- name: Report pyomo plugin information
672692
run: |
693+
# MRM / Jan 9, 2025: We update the PATH manually to make sure we
694+
# capture all of our changes. This is necessary because of an
695+
# issue with how the PATH rearranges on Windows.
696+
# Issue: https://github.com/actions/runner-images/issues/11328
697+
export PATH=$PYOMO_PATH
673698
echo "$PATH"
674699
pyomo help --solvers || exit 1
675700
pyomo help --transformations || exit 1
@@ -678,6 +703,7 @@ jobs:
678703
- name: Run Pyomo tests
679704
if: matrix.mpi == 0
680705
run: |
706+
export PATH=$PYOMO_PATH
681707
$PYTHON_EXE -m pytest -v \
682708
-W ignore::Warning ${{matrix.category}} \
683709
pyomo `pwd`/pyomo-model-libraries \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Pyomo is available under the BSD License - see the
5353
Pyomo is currently tested with the following Python implementations:
5454

5555
* CPython: 3.9, 3.10, 3.11, 3.12, 3.13
56-
* PyPy: 3.9
56+
* PyPy: 3.10
5757

5858
_Testing and support policy_:
5959

doc/OnlineDocs/explanation/analysis/doe/doe.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Pyomo.DoE
33

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

6-
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/>`_.
6+
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/>`_.
77
project, funded through the U.S. Department Of Energy Office of Fossil Energy.
88

99
If you use Pyomo.DoE, please cite:

doc/OnlineDocs/explanation/analysis/sensitivity_toolbox.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ And finally we call sIPOPT or k_aug:
6767
>>> m_sipopt = sensitivity_calculation('sipopt', m, [m.eta1, m.eta2], [m.perturbed_eta1, m.perturbed_eta2], tee=False)
6868
>>> m_kaug_dsdp = sensitivity_calculation('k_aug', m, [m.eta1, m.eta2], [m.perturbed_eta1, m.perturbed_eta2], tee=False)
6969

70+
.. testcode:: python
71+
:skipif: not sipopt_available or not k_aug_available or not dot_sens_available
72+
:hide:
73+
74+
# The x3 result can come back -0.000 depending on the platform or
75+
# solver version; map it so that tests don't fail.
76+
for _m in (m, m_sipopt, m_kaug_dsdp):
77+
if f'{_m.x3():.3f}' == '-0.000':
78+
_m.x3 = 0.
79+
if f'{m_sipopt.sens_sol_state_1[m_sipopt.x3]:.3f}' == '-0.000':
80+
m_sipopt.sens_sol_state_1[m_sipopt.x3] = 0.
81+
7082
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.
7183

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

140152
>>> print("x3 = %0.3f" % x3)
141-
x3 = -0.000
153+
x3 = 0.000
142154

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

164176
>>> print("x3 = %0.3f" % x3)
165-
x3 = -0.000
177+
x3 = 0.000
166178

167179

168180
Installing sIPOPT and k_aug

doc/OnlineDocs/explanation/solvers/pyros.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,8 @@ Observe that the log contains the following information:
935935
:linenos:
936936
937937
==============================================================================
938-
PyROS: The Pyomo Robust Optimization Solver, v1.3.0.
939-
Pyomo version: 6.8.1
938+
PyROS: The Pyomo Robust Optimization Solver, v1.3.1.
939+
Pyomo version: 6.9.0
940940
Commit hash: unknown
941941
Invoked at UTC 2024-11-01T00:00:00.000000
942942

pyomo/common/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,11 @@ def __call__(
18401840
assert default is NOTSET
18411841
else:
18421842
fields += ('domain',)
1843-
kwds['default'] = self.value() if default is NOTSET else default
1843+
if default is NOTSET:
1844+
default = self.value()
1845+
if default is NOTSET:
1846+
default = None
1847+
kwds['default'] = default
18441848
assert implicit is NOTSET
18451849
assert implicit_domain is NOTSET
18461850
for field in fields:

pyomo/contrib/doe/doe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ def compute_FIM_full_factorial(
14581458
}
14591459
)
14601460

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

14781478
# Compute FIM with given options
14791479
try:
1480-
curr_point = succeses + failures + 1
1480+
curr_point = successes + failures + 1
14811481

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

14851485
# Attempt the FIM computation
14861486
self.compute_FIM(model=model, method=method)
1487-
succeses += 1
1487+
successes += 1
14881488

14891489
# iteration time
14901490
iter_t = iter_timer.toc(msg=None)

pyomo/contrib/pynumero/algorithms/solvers/tests/test_cyipopt_solver.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import pyomo.common.unittest as unittest
1313
import pyomo.environ as pyo
14-
import os
14+
from pyomo.common.tempfiles import TempfileManager
1515

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

222-
cynlp = CyIpoptNLP(PyomoNLP(m))
223-
options = {
224-
'nlp_scaling_method': 'user-scaling',
225-
'output_file': '_cyipopt-scaling.log',
226-
'file_print_level': 10,
227-
'max_iter': 0,
228-
}
229-
solver = CyIpoptSolver(cynlp, options=options)
230-
x, info = solver.solve()
231-
232-
with open('_cyipopt-scaling.log', 'r') as fd:
233-
solver_trace = fd.read()
234-
cynlp.close()
235-
os.remove('_cyipopt-scaling.log')
236-
237-
# check for the following strings in the log and then delete the log
222+
with TempfileManager.new_context() as temp:
223+
cynlp = CyIpoptNLP(PyomoNLP(m))
224+
logfile = temp.create_tempfile('_cyipopt-scaling.log')
225+
options = {
226+
'nlp_scaling_method': 'user-scaling',
227+
'output_file': logfile,
228+
'file_print_level': 10,
229+
'max_iter': 0,
230+
}
231+
solver = CyIpoptSolver(cynlp, options=options)
232+
x, info = solver.solve()
233+
cynlp.close()
234+
235+
with open(logfile, 'r') as fd:
236+
solver_trace = fd.read()
237+
238+
# check for the following strings in the log
238239
self.assertIn('nlp_scaling_method = user-scaling', solver_trace)
239-
self.assertIn('output_file = _cyipopt-scaling.log', solver_trace)
240+
self.assertIn(f"output_file = {logfile}", solver_trace)
240241
self.assertIn('objective scaling factor = 1e-06', solver_trace)
241242
self.assertIn('x scaling provided', solver_trace)
242243
self.assertIn('c scaling provided', solver_trace)

0 commit comments

Comments
 (0)