Skip to content

Commit

Permalink
Merge branch 'main' into pyomonlp-scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
blnicho authored Jul 30, 2024
2 parents 946a42d + f46da7f commit 3a083c3
Show file tree
Hide file tree
Showing 61 changed files with 3,565 additions and 705 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ jobs:
$BARON_DIR = "${env:TPL_DIR}/baron"
echo "$BARON_DIR" | `
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$URL = "https://www.minlp.com/downloads/xecs/baron/current/"
$URL = "https://minlp.com/downloads/xecs/baron/current/"
if ( "${{matrix.TARGET}}" -eq "win" ) {
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
$URL += "baron-win64.exe"
Expand Down Expand Up @@ -855,9 +855,6 @@ jobs:
token: ${{ secrets.PYOMO_CODECOV_TOKEN }}
name: ${{ matrix.TARGET }}
flags: ${{ matrix.TARGET }}
# downgrading after v0.7.0 broke tokenless upload
# see codecov/codecov-action#1487
version: v0.6.0
fail_ci_if_error: true

- name: Upload other coverage reports
Expand All @@ -870,7 +867,4 @@ jobs:
token: ${{ secrets.PYOMO_CODECOV_TOKEN }}
name: ${{ matrix.TARGET }}/other
flags: ${{ matrix.TARGET }},other
# downgrading after v0.7.0 broke tokenless upload
# see codecov/codecov-action#1487
version: v0.6.0
fail_ci_if_error: true
13 changes: 4 additions & 9 deletions .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ jobs:
verbose: true
# How many times to retry a failed request (defaults to 1)
retry_count: 3
# Exclude Jenkins because it's behind a firewall; ignore RTD because
# a magically-generated string is triggering a failure
# Exclude:
# - Jenkins because it's behind a firewall
# - RTD because a magically-generated string triggers failures
exclude_urls: https://pyomo-jenkins.sandia.gov/,https://pyomo.readthedocs.io/en/%s/errors.html


Expand Down Expand Up @@ -561,7 +562,7 @@ jobs:
$BARON_DIR = "${env:TPL_DIR}/baron"
echo "$BARON_DIR" | `
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$URL = "https://www.minlp.com/downloads/xecs/baron/current/"
$URL = "https://minlp.com/downloads/xecs/baron/current/"
if ( "${{matrix.TARGET}}" -eq "win" ) {
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
$URL += "baron-win64.exe"
Expand Down Expand Up @@ -899,9 +900,6 @@ jobs:
token: ${{ secrets.PYOMO_CODECOV_TOKEN }}
name: ${{ matrix.TARGET }}
flags: ${{ matrix.TARGET }}
# downgrading after v0.7.0 broke tokenless upload
# see codecov/codecov-action#1487
version: v0.6.0
fail_ci_if_error: true

- name: Upload other coverage reports
Expand All @@ -914,7 +912,4 @@ jobs:
token: ${{ secrets.PYOMO_CODECOV_TOKEN }}
name: ${{ matrix.TARGET }}/other
flags: ${{ matrix.TARGET }},other
# downgrading after v0.7.0 broke tokenless upload
# see codecov/codecov-action#1487
version: v0.6.0
fail_ci_if_error: true
4 changes: 4 additions & 0 deletions .github/workflows/typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ caf = "caf"
WRONLY = "WRONLY"
# Ignore the name Hax
Hax = "Hax"
# Ignore dout (short for dual output in SAS solvers)
dout = "dout"
# Big Sur
Sur = "Sur"
# contrib package named mis and the acronym whence the name comes
Expand Down Expand Up @@ -67,4 +69,6 @@ RO = "RO"
EOF = "EOF"
# Ignore lst as shorthand for list
lst = "lst"
# Abbreviation of gamma (used in stochpdegas1_automatic.py)
gam = "gam"
# AS NEEDED: Add More Words Below
50 changes: 37 additions & 13 deletions .jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
#
# CODECOV_TOKEN: the token to use when uploading results to codecov.io
#
# CODECOV_ARGS: additional arguments to pass to the codecov uploader
# (e.g., to support SSL certificates)
# CODECOV_SOURCE_BRANCH: passed to the 'codecov-cli' command; branch of Pyomo
# (e.g., to enable correct codecov uploads)
#
# CODECOV_REPO_OWNER: passed to the 'codecov-cli' command; owner of repo
# (e.g., to enable correct codecov uploads)
#
# DISABLE_COVERAGE: if nonempty, then coverage analysis is disabled
#
Expand Down Expand Up @@ -202,22 +205,43 @@ if test -z "$MODE" -o "$MODE" == test; then
# Note, that the PWD should still be $WORKSPACE/pyomo
#
coverage combine || exit 1
coverage report -i
coverage report -i || exit 1
coverage xml -i || exit 1
export OS=`uname`
if test -z "$CODECOV_TOKEN"; then
coverage xml
else
CODECOV_JOB_NAME=`echo ${JOB_NAME} | sed -r 's/^(.*autotest_)?Pyomo_([^\/]+).*/\2/'`.$BUILD_NUMBER.$python
if test -z "$PYOMO_SOURCE_SHA"; then
PYOMO_SOURCE_SHA=$GIT_COMMIT
fi
if test -n "$CODECOV_TOKEN" -a -n "$PYOMO_SOURCE_SHA"; then
CODECOV_JOB_NAME=$(echo ${JOB_NAME} \
| sed -r 's/^(.*autotest_)?Pyomo_([^\/]+).*/\2/').$BUILD_NUMBER.$python
if test -z "$CODECOV_REPO_OWNER"; then
if test -n "$PYOMO_SOURCE_REPO"; then
CODECOV_REPO_OWNER=$(echo "$PYOMO_SOURCE_REPO" | cut -d '/' -f 4)
elif test -n "$GIT_URL"; then
CODECOV_REPO_OWNER=$(echo "$GIT_URL" | cut -d '/' -f 4)
else
CODECOV_REPO_OWNER=""
fi
fi
if test -z "$CODECOV_SOURCE_BRANCH"; then
CODECOV_SOURCE_BRANCH=$(git branch -av --contains "$PYOMO_SOURCE_SHA" \
| grep "${PYOMO_SOURCE_SHA:0:7}" | grep "/origin/" \
| cut -d '/' -f 3 | cut -d' ' -f 1)
if test -z "$CODECOV_SOURCE_BRANCH"; then
CODECOV_SOURCE_BRANCH=main
fi
fi
i=0
while /bin/true; do
i=$[$i+1]
echo "Uploading coverage to codecov (attempt $i)"
codecov -X gcovcodecov -X gcov -X s3 --no-color \
-t $CODECOV_TOKEN --root `pwd` -e OS,python \
--name $CODECOV_JOB_NAME $CODECOV_ARGS \
| tee .cover.upload
if test $? == 0 -a `grep -i error .cover.upload \
| grep -v branch= | wc -l` -eq 0; then
codecovcli -v upload-process --sha $PYOMO_SOURCE_SHA \
--fail-on-error --git-service github --token $CODECOV_TOKEN \
--slug pyomo/pyomo --file coverage.xml --disable-search \
--name $CODECOV_JOB_NAME \
--branch $CODECOV_REPO_OWNER:$CODECOV_SOURCE_BRANCH \
--env OS,python --network-root-folder `pwd` --plugin noop
if test $? == 0; then
break
elif test $i -ge 4; then
exit 1
Expand Down
28 changes: 15 additions & 13 deletions .codecov.yml → codecov.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
codecov:
notify:
# GHA: 5, Jenkins: 11
# Accurate as of July 3, 2024
# Potential to change when Python versions change
after_n_builds: 16
wait_for_ci: true
coverage:
range: "50...100"
range:
- 50.0
- 100.0
status:
patch:
default:
# Force patches to be covered at the level of the codebase
threshold: 0.0
project:
default:
# Allow overall coverage to drop to avoid failures due to code
# cleanup or CI unavailability/lag
threshold: 5%
patch:
default:
# Force patches to be covered at the level of the codebase
threshold: 0%
# ci:
# - !ci.appveyor.com
codecov:
notify:
# GHA: 4, Jenkins: 8
after_n_builds: 12 # all
wait_for_ci: yes
threshold: 5.0
6 changes: 3 additions & 3 deletions doc/OnlineDocs/contributed_packages/gdpopt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ An example that includes the modeling approach may be found below.
Variables:
x : Size=1, Index=None
Key : Lower : Value : Upper : Fixed : Stale : Domain
None : -1.2 : 0.0 : 2 : False : False : Reals
None : -1.2 : 0 : 2 : False : False : Reals
y : Size=1, Index=None
Key : Lower : Value : Upper : Fixed : Stale : Domain
None : -10 : 1.0 : 10 : False : False : Reals
None : -10 : 1 : 10 : False : False : Reals
<BLANKLINE>
Objectives:
objective : Size=1, Index=None, Active=True
Expand All @@ -106,7 +106,7 @@ An example that includes the modeling approach may be found below.
Constraints:
c : Size=1
Key : Lower : Body : Upper
None : 1.0 : 1.0 : 1.0
None : 1.0 : 1 : 1.0

.. note::

Expand Down
3 changes: 3 additions & 0 deletions examples/pyomo/tutorials/set.dat
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ set S[5] := 2 3;

set T[2] := 1 3;
set T[5] := 2 3;

set X[2] := 1;
set X[5] := 2 3;
8 changes: 6 additions & 2 deletions examples/pyomo/tutorials/set.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
23 Set Declarations
24 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {1, 2, 3}
Expand Down Expand Up @@ -89,5 +89,9 @@
2 : 1 : Any : 5 : {1, 3, 5, 7, 9}
3 : 1 : Any : 5 : {1, 4, 7, 10, 13}
4 : 1 : Any : 5 : {1, 5, 9, 13, 17}
X : Size=2, Index=B, Ordered=Insertion
Key : Dimen : Domain : Size : Members
2 : 1 : S[2] : 1 : {1,}
5 : 1 : S[5] : 2 : {2, 3}

23 Declarations: A B C D E F G H Hsub I J K K_2 L M N O P R S T U V
24 Declarations: A B C D E F G H Hsub I J K K_2 L M N O P R S X T U V
7 changes: 7 additions & 0 deletions examples/pyomo/tutorials/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ def P_init(model, i, j):
#
model.S = Set(model.B, within=model.A)

#
# Validation of a set array can also be linked to another set array. If so, the
# elements under each index must also be found under the corresponding index in
# the validation set array:
#
model.X = Set(model.B, within=model.S)


#
# Validation of set arrays can also be performed with the _validate_ option.
Expand Down
2 changes: 1 addition & 1 deletion pyomo/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ class will still create ``c`` instances that only have the single
:py:meth:`generate_documentation()`. The simplest is
:py:meth:`display()`, which prints out the current values of the
configuration object (and if it is a container type, all of it's
children). :py:meth:`generate_yaml_template` is simular to
children). :py:meth:`generate_yaml_template` is similar to
:py:meth:`display`, but also includes the description fields as
formatted comments.
Expand Down
2 changes: 1 addition & 1 deletion pyomo/common/tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_and_or(self):
_and_or = avail0 & avail1 | avail2
self.assertTrue(_and_or)

# Verify operator prescedence
# Verify operator precedence
_or_and = avail0 | avail2 & avail2
self.assertTrue(_or_and)
_or_and = (avail0 | avail2) & avail2
Expand Down
35 changes: 4 additions & 31 deletions pyomo/contrib/appsi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ def add_constraints(self, cons: List[ConstraintData]):
raise ValueError(
'constraint {name} has already been added'.format(name=con.name)
)
self._active_constraints[con] = (con.lower, con.body, con.upper)
self._active_constraints[con] = con.expr
if self.use_extensions and cmodel_available:
tmp = cmodel.prep_for_repn(con.body, self._expr_types)
else:
Expand Down Expand Up @@ -1363,40 +1363,13 @@ def update(self, timer: HierarchicalTimer = None):
cons_to_remove_and_add = dict()
need_to_set_objective = False
if config.update_constraints:
cons_to_update = list()
sos_to_update = list()
for c in current_cons_dict.keys():
if c not in new_cons_set:
cons_to_update.append(c)
if c not in new_cons_set and c.expr is not self._active_constraints[c]:
cons_to_remove_and_add[c] = None
sos_to_update = []
for c in current_sos_dict.keys():
if c not in new_sos_set:
sos_to_update.append(c)
for c in cons_to_update:
lower, body, upper = self._active_constraints[c]
new_lower, new_body, new_upper = c.lower, c.body, c.upper
if new_body is not body:
cons_to_remove_and_add[c] = None
continue
if new_lower is not lower:
if (
type(new_lower) is NumericConstant
and type(lower) is NumericConstant
and new_lower.value == lower.value
):
pass
else:
cons_to_remove_and_add[c] = None
continue
if new_upper is not upper:
if (
type(new_upper) is NumericConstant
and type(upper) is NumericConstant
and new_upper.value == upper.value
):
pass
else:
cons_to_remove_and_add[c] = None
continue
self.remove_sos_constraints(sos_to_update)
self.add_sos_constraints(sos_to_update)
timer.stop('cons')
Expand Down
2 changes: 1 addition & 1 deletion pyomo/contrib/appsi/cmodel/src/fbbt_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void process_fbbt_constraints(FBBTModel *model, PyomoExprTypes &expr_types,
py::handle con_body;

for (py::handle c : cons) {
lower_body_upper = active_constraints[c];
lower_body_upper = c.attr("to_bounded_expression")();
con_lb = lower_body_upper[0];
con_body = lower_body_upper[1];
con_ub = lower_body_upper[2];
Expand Down
2 changes: 1 addition & 1 deletion pyomo/contrib/appsi/cmodel/src/lp_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void process_lp_constraints(py::list cons, py::object writer) {
py::object nonlinear_expr;
PyomoExprTypes expr_types = PyomoExprTypes();
for (py::handle c : cons) {
lower_body_upper = active_constraints[c];
lower_body_upper = c.attr("to_bounded_expression")();
cname = getSymbol(c, labeler);
repn = generate_standard_repn(
lower_body_upper[1], "compute_values"_a = false, "quadratic"_a = true);
Expand Down
2 changes: 1 addition & 1 deletion pyomo/contrib/appsi/cmodel/src/nl_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void process_nl_constraints(NLWriter *nl_writer, PyomoExprTypes &expr_types,
py::handle repn_nonlinear_expr;

for (py::handle c : cons) {
lower_body_upper = active_constraints[c];
lower_body_upper = c.attr("to_bounded_expression")();
repn = generate_standard_repn(
lower_body_upper[1], "compute_values"_a = false, "quadratic"_a = false);
_const = appsi_expr_from_pyomo_expr(repn.attr("constant"), var_map,
Expand Down
2 changes: 1 addition & 1 deletion pyomo/contrib/appsi/solvers/highs.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def _remove_constraints(self, cons: List[ConstraintData]):
indices_to_remove.append(con_ndx)
self._mutable_helpers.pop(con, None)
self._solver_model.deleteRows(
len(indices_to_remove), np.array(indices_to_remove)
len(indices_to_remove), np.sort(np.array(indices_to_remove))
)
con_ndx = 0
new_con_map = dict()
Expand Down
Loading

0 comments on commit 3a083c3

Please sign in to comment.