Skip to content

Commit a87930e

Browse files
authored
Merge branch 'main' into parmest-doe-bugfixes
2 parents 1395812 + 18def95 commit a87930e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2128
-962
lines changed

.github/workflows/release_wheel_creation.yml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,8 @@ jobs:
5959

6060
steps:
6161
- uses: actions/checkout@v4
62-
- name: Create pyproject.toml
63-
run: |
64-
# Per the cibuildwheel documentation, you can technically use
65-
# CIBW_BEFORE_BUILD to do these steps; however, as of the newest
66-
# version (2.21.3) this feature does not work. This is a hack
67-
# to make cibuildwheel recognize our pre-build requirements
68-
echo -e '[build-system]\n\nrequires = [ "setuptools", "wheel", "cython", "pybind11" ]' > $GITHUB_WORKSPACE/pyproject.toml
69-
cat $GITHUB_WORKSPACE/pyproject.toml
70-
ls -la $GITHUB_WORKSPACE
7162
- name: Build wheels
72-
uses: pypa/cibuildwheel@v2.21.3
63+
uses: pypa/cibuildwheel@main
7364
with:
7465
output-dir: dist
7566
env:
@@ -118,17 +109,8 @@ jobs:
118109
uses: docker/setup-qemu-action@v3
119110
with:
120111
platforms: all
121-
- name: Create pyproject.toml
122-
run: |
123-
# Per the cibuildwheel documentation, you can technically use
124-
# CIBW_BEFORE_BUILD to do these steps; however, as of the newest
125-
# version (2.21.3) this feature does not work. This is a hack
126-
# to make cibuildwheel recognize our pre-build requirements
127-
echo -e '[build-system]\n\nrequires = [ "setuptools", "wheel", "cython", "pybind11" ]' > $GITHUB_WORKSPACE/pyproject.toml
128-
cat $GITHUB_WORKSPACE/pyproject.toml
129-
ls -la $GITHUB_WORKSPACE
130112
- name: Build wheels
131-
uses: pypa/cibuildwheel@v2.21.3
113+
uses: pypa/cibuildwheel@main
132114
with:
133115
output-dir: dist
134116
env:
@@ -158,10 +140,11 @@ jobs:
158140
- name: Install dependencies
159141
run: |
160142
python -m pip install --upgrade pip
161-
pip install twine wheel setuptools pybind11
143+
pip install build twine wheel setuptools pybind11
162144
- name: Build pure python wheel
163145
run: |
164-
python setup.py --without-cython sdist --format=gztar bdist_wheel
146+
export PYOMO_SETUP_ARGS=--without-cython
147+
python -m build --wheel --outdir dist --config-setting="--build-option=--without-cython"
165148
- name: Upload artifact
166149
uses: actions/upload-artifact@v4
167150
with:
@@ -189,10 +172,11 @@ jobs:
189172
- name: Install dependencies
190173
run: |
191174
python -m pip install --upgrade pip
192-
pip install twine wheel setuptools pybind11
175+
pip install build twine wheel 'setuptools>=65' pybind11
193176
- name: Build generic tarball
194177
run: |
195-
python setup.py --without-cython sdist --format=gztar
178+
export PYOMO_SETUP_ARGS=--without-cython
179+
python -m build --sdist --outdir dist --config-setting="--build-option=--without-cython"
196180
- name: Upload artifact
197181
uses: actions/upload-artifact@v4
198182
with:

.github/workflows/test_branches.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,15 @@ jobs:
654654
655655
- name: Install Pyomo
656656
run: |
657+
export PYOMO_SETUP_ARGS=${{ matrix.setup_options }}
657658
echo ""
658659
echo "Clone Pyomo-model-libraries..."
659660
URL=https://github.com/Pyomo/pyomo-model-libraries.git
660661
git clone -b ${SRC_REF##*/} $URL || git clone -b main $URL
661662
echo ""
662663
echo "Install Pyomo..."
663664
echo ""
664-
$PYTHON_EXE setup.py develop ${{matrix.setup_options}}
665+
$PYTHON_EXE -m pip install -e .
665666
echo ""
666667
echo "Set custom PYOMO_CONFIG_DIR"
667668
echo ""
@@ -790,7 +791,7 @@ jobs:
790791
echo ""
791792
echo "Install Pyomo..."
792793
echo ""
793-
python setup.py develop
794+
python -m pip install -e .
794795
echo ""
795796
echo "Set custom PYOMO_CONFIG_DIR"
796797
echo ""
@@ -868,13 +869,14 @@ jobs:
868869
869870
- name: Install Pyomo
870871
run: |
872+
export PYOMO_SETUP_ARGS=${{ matrix.setup_options }}
871873
echo ""
872874
echo "Clone Pyomo-model-libraries..."
873875
git clone https://github.com/Pyomo/pyomo-model-libraries.git
874876
echo ""
875877
echo "Install Pyomo..."
876878
echo ""
877-
$PYTHON_EXE setup.py develop ${{matrix.setup_options}}
879+
$PYTHON_EXE -m pip install -e .
878880
echo ""
879881
echo "Set custom PYOMO_CONFIG_DIR"
880882
echo ""

.github/workflows/test_pr_and_main.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,14 +706,15 @@ jobs:
706706
707707
- name: Install Pyomo
708708
run: |
709+
export PYOMO_SETUP_ARGS=${{ matrix.setup_options }}
709710
echo ""
710711
echo "Clone Pyomo-model-libraries..."
711712
URL=https://github.com/Pyomo/pyomo-model-libraries.git
712713
git clone -b ${SRC_REF##*/} $URL || git clone -b main $URL
713714
echo ""
714715
echo "Install Pyomo..."
715716
echo ""
716-
$PYTHON_EXE setup.py develop ${{matrix.setup_options}}
717+
$PYTHON_EXE -m pip install -e .
717718
echo ""
718719
echo "Set custom PYOMO_CONFIG_DIR"
719720
echo ""
@@ -843,7 +844,7 @@ jobs:
843844
echo ""
844845
echo "Install Pyomo..."
845846
echo ""
846-
python setup.py develop
847+
python -m pip install -e .
847848
echo ""
848849
echo "Set custom PYOMO_CONFIG_DIR"
849850
echo ""
@@ -921,13 +922,14 @@ jobs:
921922
922923
- name: Install Pyomo
923924
run: |
925+
export PYOMO_SETUP_ARGS=${{ matrix.setup_options }}
924926
echo ""
925927
echo "Clone Pyomo-model-libraries..."
926928
git clone https://github.com/Pyomo/pyomo-model-libraries.git
927929
echo ""
928930
echo "Install Pyomo..."
929931
echo ""
930-
$PYTHON_EXE setup.py develop ${{matrix.setup_options}}
932+
$PYTHON_EXE -m pip install -e .
931933
echo ""
932934
echo "Set custom PYOMO_CONFIG_DIR"
933935
echo ""

.jenkins.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#
2929
# DISABLE_COVERAGE: if nonempty, then coverage analysis is disabled
3030
#
31-
# PYOMO_SETUP_ARGS: passed to the 'python setup.py develop' command
31+
# PYOMO_SETUP_ARGS: passed to the 'pip install' command
3232
# (e.g., to specify --with-cython)
3333
#
3434
# PYOMO_DOWNLOAD_ARGS: passed to the 'pyomo download-extensions' command
@@ -94,7 +94,7 @@ if test -z "$MODE" -o "$MODE" == setup; then
9494
echo "PyUtilib not found; skipping"
9595
fi
9696
pushd "$WORKSPACE/pyomo" || exit 1
97-
python setup.py develop $PYOMO_SETUP_ARGS || exit 1
97+
pip install -e . || exit 1
9898
popd
9999
#
100100
# DO NOT install pyomo-model-libraries

doc/OnlineDocs/explanation/experimental/solvers.rst

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,109 @@ implemented. For example, for ``ipopt``:
386386
:members:
387387
:show-inheritance:
388388
:inherited-members:
389+
390+
391+
Dual Sign Convention
392+
--------------------
393+
For all future solver interfaces, Pyomo adopts the following sign convention. Given the problem
394+
395+
.. math::
396+
397+
\begin{aligned}
398+
\min\quad & f(x) \\
399+
\text{s.t.}\quad & c_i(x) = 0 \quad \forall i \in \mathcal{E} \\
400+
& g_i(x) \le 0 \quad \forall i \in \mathcal{U} \\
401+
& h_i(x) \ge 0 \quad \forall i \in \mathcal{L}
402+
\end{aligned}
403+
404+
We define the Lagrangian as
405+
406+
.. math::
407+
408+
\begin{aligned}
409+
L(x, \lambda, \nu, \delta)
410+
&= f(x)
411+
- \sum_{i \in \mathcal{E}} \lambda_i\,c_i(x)
412+
- \sum_{i \in \mathcal{U}} \nu_i\,g_i(x)
413+
- \sum_{i \in \mathcal{L}} \delta_i\,h_i(x)
414+
\end{aligned}
415+
416+
Then, the KKT conditions are [NW99]_
417+
418+
.. math::
419+
420+
\begin{aligned}
421+
\nabla_x L(x, \lambda, \nu, \delta) &= 0 \\
422+
c(x) &= 0 \\
423+
g(x) &\le 0 \\
424+
h(x) &\ge 0 \\
425+
\nu &\le 0 \\
426+
\delta &\ge 0 \\
427+
\nu_i\,g_i(x) &= 0 \\
428+
\delta_i\,h_i(x) &= 0
429+
\end{aligned}
430+
431+
Note that this sign convention is based on the ``(lower, body, upper)``
432+
representation of constraints rather than the expression provided by a
433+
user. Users can specify constraints with variables on both the left- and
434+
right-hand sides of equalities and inequalities. However, the
435+
``(lower, body, upper)`` representation ensures that all variables
436+
appear in the ``body``, matching the form of the problem above.
437+
438+
For maximization problems of the form
439+
440+
.. math::
441+
442+
\begin{aligned}
443+
\max\quad & f(x) \\
444+
\text{s.t.}\quad & c_i(x) = 0 \quad \forall i \in \mathcal{E} \\
445+
& g_i(x) \le 0 \quad \forall i \in \mathcal{U} \\
446+
& h_i(x) \ge 0 \quad \forall i \in \mathcal{L}
447+
\end{aligned}
448+
449+
we define the Lagrangian to be the same as above:
450+
451+
.. math::
452+
453+
\begin{aligned}
454+
L(x, \lambda, \nu, \delta)
455+
&= f(x)
456+
- \sum_{i \in \mathcal{E}} \lambda_i\,c_i(x)
457+
- \sum_{i \in \mathcal{U}} \nu_i\,g_i(x)
458+
- \sum_{i \in \mathcal{L}} \delta_i\,h_i(x)
459+
\end{aligned}
460+
461+
As a result, the signs of the duals change. The KKT conditions are
462+
463+
.. math::
464+
465+
\begin{aligned}
466+
\nabla_x L(x, \lambda, \nu, \delta) &= 0 \\
467+
c(x) &= 0 \\
468+
g(x) &\le 0 \\
469+
h(x) &\ge 0 \\
470+
\nu &\ge 0 \\
471+
\delta &\le 0 \\
472+
\nu_i\,g_i(x) &= 0 \\
473+
\delta_i\,h_i(x) &= 0
474+
\end{aligned}
475+
476+
477+
Pyomo also supports "range constraints" which are inequalities with both upper
478+
and lower bounds, where the bounds are not equal. For example,
479+
480+
.. math::
481+
482+
-1 \leq x + y \leq 1
483+
484+
These are handled very similarly to variable bounds in terms of dual sign
485+
conventions. For these, at most one "side" of the inequality can be active
486+
at a time. If neither side is active, then the dual will be zero. If the dual
487+
is nonzero, then the dual corresponds to the side of the constraint that is
488+
active. The dual for the other side will be implicitly zero. When accessing
489+
duals, the keys are the constraints. As a result, there is only one key for
490+
a range constraint, even though it is really two constraints. Therefore, the
491+
dual for the inactive side will not be reported explicitly. Again, the sign
492+
convention is based on the ``(lower, body, upper)`` representation of the
493+
constraint. Therefore, the left side of this inequality belongs to
494+
:math:`\mathcal{L}` and the right side belongs to :math:`\mathcal{U}`.

doc/OnlineDocs/getting_started/installation.rst

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ packages including but not limited to: matplotlib, networkx, numpy,
5151
openpyxl, pandas, pint, pymysql, pyodbc, pyro4, scipy, sympy, and
5252
xlrd.
5353

54-
A full list of conditional dependencies can be found in Pyomo's
55-
``setup.py`` and displayed using:
54+
A full list of optional dependencies can be found in Pyomo's
55+
``pyproject.toml`` under the ``[project.optional-dependencies]`` table.
56+
They can be displayed by running:
5657

5758
::
5859

60+
# Legacy format
5961
python setup.py dependencies --extra optional
62+
# Newer format - prints as a JSON
63+
python -m pip install --dry-run --report - '.[optional]'
6064

6165
Pyomo extensions that require any of these packages will generate
6266
an error message for missing dependencies upon use.
@@ -86,16 +90,31 @@ initialized.
8690
.. note::
8791
This can only be done via ``pip`` or from source.
8892

89-
Via ``pip``:
93+
Installation via ``pip`` or from source is done the same way - using environment
94+
variables. On Linux/MacOS:
9095

9196
::
9297

93-
pip install pyomo --global-option="--with-cython"
98+
export PYOMO_SETUP_ARGS=--with-cython
99+
pip install pyomo
100+
101+
On Windows:
102+
103+
::
104+
105+
# Via command prompt
106+
set PYOMO_SETUP_ARGS=--with-cython
107+
# Via powershell
108+
$env:PYOMO_SETUP_ARGS="--with-cython"
109+
pip install pyomo
110+
94111

95112
From source (recommended for advanced users only):
96113

97114
::
98115

116+
export PYOMO_SETUP_ARGS=--with-cython
99117
git clone https://github.com/Pyomo/pyomo.git
100118
cd pyomo
101-
python setup.py install --with-cython
119+
# Use -e to install in editable mode
120+
pip install .

doc/OnlineDocs/reference/bibliography.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,6 @@ Bibliography
149149
.. [VAN10] J. P. Vielma, S. Ahmed, and G. Nemhauser. "Mixed-Integer
150150
Models for Non-separable Piecewise Linear Optimization: Unifying
151151
framework and Extensions", *Operations Research* 58(2), 303-315. 2010.
152+
153+
.. [NW99] Nocedal, Jorge, and Stephen J. Wright, eds. Numerical
154+
optimization. New York, NY: Springer New York, 1999.

examples/pyomobook/strip_examples.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ def f(file):
2121
if prefix.endswith('_strip'):
2222
return
2323

24-
with open(base + '/' + prefix + '_strip.py', 'w') as OUTPUT, open(
25-
file, 'r'
26-
) as INPUT:
24+
with (
25+
open(base + '/' + prefix + '_strip.py', 'w') as OUTPUT,
26+
open(file, 'r') as INPUT,
27+
):
2728
for line in INPUT:
2829
if line[0] == '#' and '@' in line:
2930
continue

0 commit comments

Comments
 (0)