diff --git a/.coin-or/projDesc.xml b/.coin-or/projDesc.xml
index 1ee247e100f..d13ac8804cf 100644
--- a/.coin-or/projDesc.xml
+++ b/.coin-or/projDesc.xml
@@ -227,8 +227,8 @@ Carl D. Laird, Chair, Pyomo Management Committee, claird at andrew dot cmu dot e
Use explicit overrides to disable use of automated
version reporting.
-->
- 6.7.0
- 6.7.0
+ 6.7.3
+ 6.7.3
diff --git a/.github/workflows/release_wheel_creation.yml b/.github/workflows/release_wheel_creation.yml
index ef44806d6d4..932b0d8eea6 100644
--- a/.github/workflows/release_wheel_creation.yml
+++ b/.github/workflows/release_wheel_creation.yml
@@ -22,14 +22,27 @@ jobs:
name: Build wheels (${{ matrix.wheel-version }}) on ${{ matrix.os }} for native and cross-compiled architecture
runs-on: ${{ matrix.os }}
strategy:
+ fail-fast: true
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
arch: [all]
wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*']
+
+ include:
+ - wheel-version: 'cp38*'
+ TARGET: 'py38'
+ - wheel-version: 'cp39*'
+ TARGET: 'py39'
+ - wheel-version: 'cp310*'
+ TARGET: 'py310'
+ - wheel-version: 'cp311*'
+ TARGET: 'py311'
+ - wheel-version: 'cp312*'
+ TARGET: 'py312'
steps:
- uses: actions/checkout@v4
- name: Build wheels
- uses: pypa/cibuildwheel@v2.16.2
+ uses: pypa/cibuildwheel@v2.16.5
with:
output-dir: dist
env:
@@ -43,8 +56,9 @@ jobs:
CIBW_CONFIG_SETTINGS: '--global-option="--with-cython --with-distributable-extensions"'
- uses: actions/upload-artifact@v4
with:
- name: native_wheels
+ name: native_wheels-${{ matrix.os }}-${{ matrix.TARGET }}
path: dist/*.whl
+ overwrite: true
alternative_wheels:
name: Build wheels (${{ matrix.wheel-version }}) on ${{ matrix.os }} for aarch64
@@ -54,6 +68,18 @@ jobs:
os: [ubuntu-22.04]
arch: [all]
wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*']
+
+ include:
+ - wheel-version: 'cp38*'
+ TARGET: 'py38'
+ - wheel-version: 'cp39*'
+ TARGET: 'py39'
+ - wheel-version: 'cp310*'
+ TARGET: 'py310'
+ - wheel-version: 'cp311*'
+ TARGET: 'py311'
+ - wheel-version: 'cp312*'
+ TARGET: 'py312'
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
@@ -62,7 +88,7 @@ jobs:
with:
platforms: all
- name: Build wheels
- uses: pypa/cibuildwheel@v2.16.2
+ uses: pypa/cibuildwheel@v2.16.5
with:
output-dir: dist
env:
@@ -74,8 +100,9 @@ jobs:
CIBW_CONFIG_SETTINGS: '--global-option="--with-cython --with-distributable-extensions"'
- uses: actions/upload-artifact@v4
with:
- name: alt_wheels
+ name: alt_wheels-${{ matrix.os }}-${{ matrix.TARGET }}
path: dist/*.whl
+ overwrite: true
generictarball:
name: ${{ matrix.TARGET }}
@@ -106,4 +133,5 @@ jobs:
with:
name: generictarball
path: dist
+ overwrite: true
diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml
index e5513d25975..03894a1cb20 100644
--- a/.github/workflows/test_branches.yml
+++ b/.github/workflows/test_branches.yml
@@ -40,12 +40,27 @@ jobs:
python-version: '3.10'
- name: Black Formatting Check
run: |
- pip install black
+ # Note v24.4.1 fails due to a bug in the parser
+ pip install 'black!=24.4.1'
black . -S -C --check --diff --exclude examples/pyomobook/python-ch/BadIndent.py
- name: Spell Check
uses: crate-ci/typos@master
with:
config: ./.github/workflows/typos.toml
+ - name: URL Checker
+ uses: urlstechie/urlchecker-action@0.0.34
+ with:
+ # A comma-separated list of file types to cover in the URL checks
+ file_types: .md,.rst,.py
+ # Choose whether to include file with no URLs in the prints.
+ print_all: false
+ # More verbose summary at the end of a run
+ 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_urls: https://pyomo-jenkins.sandia.gov/,https://pyomo.readthedocs.io/en/%s/errors.html
build:
@@ -66,7 +81,7 @@ jobs:
TARGET: linux
PYENV: pip
- - os: macos-latest
+ - os: macos-13
python: '3.10'
TARGET: osx
PYENV: pip
@@ -75,7 +90,7 @@ jobs:
python: 3.9
TARGET: win
PYENV: conda
- PACKAGES: glpk pytest-qt
+ PACKAGES: glpk pytest-qt filelock
- os: ubuntu-latest
python: '3.11'
@@ -86,13 +101,13 @@ jobs:
PACKAGES: pytest-qt
- os: ubuntu-latest
- python: 3.9
+ python: '3.10'
other: /mpi
mpi: 3
skip_doctest: 1
TARGET: linux
PYENV: conda
- PACKAGES: mpi4py
+ PACKAGES: openmpi mpi4py
- os: ubuntu-latest
python: '3.10'
@@ -180,7 +195,7 @@ jobs:
# Notes:
# - install glpk
# - pyodbc needs: gcc pkg-config unixodbc freetds
- for pkg in bash pkg-config unixodbc freetds glpk; do
+ for pkg in bash pkg-config unixodbc freetds glpk ginac; do
brew list $pkg || brew install $pkg
done
@@ -192,7 +207,8 @@ jobs:
# - install glpk
# - ipopt needs: libopenblas-dev gfortran liblapack-dev
sudo apt-get -o Dir::Cache=${GITHUB_WORKSPACE}/cache/os \
- install libopenblas-dev gfortran liblapack-dev glpk-utils
+ install libopenblas-dev gfortran liblapack-dev glpk-utils \
+ libginac-dev
sudo chmod -R 777 ${GITHUB_WORKSPACE}/cache/os
- name: Update Windows
@@ -263,11 +279,12 @@ jobs:
if test -z "${{matrix.slim}}"; then
python -m pip install --cache-dir cache/pip cplex docplex \
|| echo "WARNING: CPLEX Community Edition is not available"
- python -m pip install --cache-dir cache/pip \
- -i https://pypi.gurobi.com gurobipy==10.0.3 \
+ python -m pip install --cache-dir cache/pip gurobipy==10.0.3 \
|| echo "WARNING: Gurobi is not available"
python -m pip install --cache-dir cache/pip xpress \
|| echo "WARNING: Xpress Community Edition is not available"
+ python -m pip install --cache-dir cache/pip maingopy \
+ || echo "WARNING: MAiNGO is not available"
if [[ ${{matrix.python}} == pypy* ]]; then
echo "skipping wntr for pypy"
else
@@ -333,6 +350,7 @@ jobs:
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES $PKG"
fi
done
+ echo ""
echo "*** Install Pyomo dependencies ***"
# Note: this will fail the build if any installation fails (or
# possibly if it outputs messages to stderr)
@@ -501,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"
@@ -631,7 +649,7 @@ jobs:
$PYTHON_EXE -c "from pyomo.dataportal.parse_datacmds import \
parse_data_commands; parse_data_commands(data='')"
# Note: if we are testing with openmpi, add '--oversubscribe'
- mpirun -np ${{matrix.mpi}} pytest -v \
+ mpirun -np ${{matrix.mpi}} -oversubscribe pytest -v \
--junit-xml=TEST-pyomo-mpi.xml \
-m "mpi" -W ignore::Warning \
pyomo `pwd`/pyomo-model-libraries
@@ -708,12 +726,12 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
+ os: [ubuntu-latest, macos-13, windows-latest]
include:
- os: ubuntu-latest
TARGET: linux
- - os: macos-latest
+ - os: macos-13
TARGET: osx
- os: windows-latest
TARGET: win
diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml
index c5028606c17..cc9760cbe5d 100644
--- a/.github/workflows/test_pr_and_main.yml
+++ b/.github/workflows/test_pr_and_main.yml
@@ -7,6 +7,11 @@ on:
pull_request:
branches:
- main
+ types:
+ - opened
+ - reopened
+ - synchronize
+ - ready_for_review
workflow_dispatch:
inputs:
git-ref:
@@ -34,6 +39,8 @@ jobs:
lint:
name: lint/style-and-typos
runs-on: ubuntu-latest
+ if: |
+ contains(github.event.pull_request.title, '[WIP]') != true && !github.event.pull_request.draft
steps:
- name: Checkout Pyomo source
uses: actions/checkout@v4
@@ -43,12 +50,28 @@ jobs:
python-version: '3.10'
- name: Black Formatting Check
run: |
- pip install black
+ # Note v24.4.1 fails due to a bug in the parser
+ pip install 'black!=24.4.1'
black . -S -C --check --diff --exclude examples/pyomobook/python-ch/BadIndent.py
- name: Spell Check
uses: crate-ci/typos@master
with:
config: ./.github/workflows/typos.toml
+ - name: URL Checker
+ uses: urlstechie/urlchecker-action@0.0.34
+ with:
+ # A comma-separated list of file types to cover in the URL checks
+ file_types: .md,.rst,.py
+ # Choose whether to include file with no URLs in the prints.
+ print_all: false
+ # More verbose summary at the end of a run
+ verbose: true
+ # How many times to retry a failed request (defaults to 1)
+ retry_count: 3
+ # 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
build:
@@ -59,24 +82,29 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
+ os: [ubuntu-latest, macos-13, windows-latest]
python: [ 3.8, 3.9, '3.10', '3.11', '3.12' ]
other: [""]
category: [""]
+ # win/3.8 conda builds no longer work due to environment not being able
+ # to resolve. We are skipping it now.
+ exclude:
+ - os: windows-latest
+ python: 3.8
include:
- os: ubuntu-latest
TARGET: linux
PYENV: pip
- - os: macos-latest
+ - os: macos-13
TARGET: osx
PYENV: pip
- os: windows-latest
TARGET: win
PYENV: conda
- PACKAGES: glpk pytest-qt
+ PACKAGES: glpk pytest-qt filelock
- os: ubuntu-latest
python: '3.11'
@@ -87,13 +115,13 @@ jobs:
PACKAGES: pytest-qt
- os: ubuntu-latest
- python: 3.9
+ python: '3.10'
other: /mpi
mpi: 3
skip_doctest: 1
TARGET: linux
PYENV: conda
- PACKAGES: mpi4py
+ PACKAGES: openmpi mpi4py
- os: ubuntu-latest
python: '3.11'
@@ -210,7 +238,7 @@ jobs:
# Notes:
# - install glpk
# - pyodbc needs: gcc pkg-config unixodbc freetds
- for pkg in bash pkg-config unixodbc freetds glpk; do
+ for pkg in bash pkg-config unixodbc freetds glpk ginac; do
brew list $pkg || brew install $pkg
done
@@ -222,7 +250,8 @@ jobs:
# - install glpk
# - ipopt needs: libopenblas-dev gfortran liblapack-dev
sudo apt-get -o Dir::Cache=${GITHUB_WORKSPACE}/cache/os \
- install libopenblas-dev gfortran liblapack-dev glpk-utils
+ install libopenblas-dev gfortran liblapack-dev glpk-utils \
+ libginac-dev
sudo chmod -R 777 ${GITHUB_WORKSPACE}/cache/os
- name: Update Windows
@@ -293,11 +322,12 @@ jobs:
if test -z "${{matrix.slim}}"; then
python -m pip install --cache-dir cache/pip cplex docplex \
|| echo "WARNING: CPLEX Community Edition is not available"
- python -m pip install --cache-dir cache/pip \
- -i https://pypi.gurobi.com gurobipy==10.0.3 \
+ python -m pip install --cache-dir cache/pip gurobipy==10.0.3 \
|| echo "WARNING: Gurobi is not available"
python -m pip install --cache-dir cache/pip xpress \
|| echo "WARNING: Xpress Community Edition is not available"
+ python -m pip install --cache-dir cache/pip maingopy \
+ || echo "WARNING: MAiNGO is not available"
if [[ ${{matrix.python}} == pypy* ]]; then
echo "skipping wntr for pypy"
else
@@ -363,6 +393,7 @@ jobs:
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES $PKG"
fi
done
+ echo ""
echo "*** Install Pyomo dependencies ***"
# Note: this will fail the build if any installation fails (or
# possibly if it outputs messages to stderr)
@@ -531,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"
@@ -605,7 +636,8 @@ jobs:
if: ${{ ! matrix.slim }}
shell: bash
run: |
- $PYTHON_EXE -m pip install --cache-dir cache/pip highspy \
+ echo "NOTE: temporarily pinning to highspy pre-release for testing"
+ $PYTHON_EXE -m pip install --cache-dir cache/pip "highspy>=1.7.1.dev1" \
|| echo "WARNING: highspy is not available"
- name: Set up coverage tracking
@@ -661,7 +693,7 @@ jobs:
$PYTHON_EXE -c "from pyomo.dataportal.parse_datacmds import \
parse_data_commands; parse_data_commands(data='')"
# Note: if we are testing with openmpi, add '--oversubscribe'
- mpirun -np ${{matrix.mpi}} pytest -v \
+ mpirun -np ${{matrix.mpi}} -oversubscribe pytest -v \
--junit-xml=TEST-pyomo-mpi.xml \
-m "mpi" -W ignore::Warning \
pyomo `pwd`/pyomo-model-libraries
@@ -733,18 +765,18 @@ jobs:
cover:
name: process-coverage-${{ matrix.TARGET }}
needs: build
- if: always() # run even if a build job fails
+ if: success() || failure() # run even if a build job fails, but not if cancelled
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
+ os: [ubuntu-latest, macos-13, windows-latest]
include:
- os: ubuntu-latest
TARGET: linux
- - os: macos-latest
+ - os: macos-13
TARGET: osx
- os: windows-latest
TARGET: win
diff --git a/.github/workflows/typos.toml b/.github/workflows/typos.toml
index 23f94fc8afd..80d50477ca4 100644
--- a/.github/workflows/typos.toml
+++ b/.github/workflows/typos.toml
@@ -38,6 +38,37 @@ 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
+mis = "mis"
+MIS = "MIS"
+# Ignore the shorthand ans for answer
+ans = "ans"
+# Ignore the keyword arange
+arange = "arange"
+# Ignore IIS
+IIS = "IIS"
+iis = "iis"
+# Ignore PN
+PN = "PN"
+# Ignore hd
+hd = "hd"
+# Ignore opf
+opf = "opf"
+# Ignore FRE
+FRE = "FRE"
+# Ignore MCH
+MCH = "MCH"
+# Ignore RO
+ro = "ro"
+RO = "RO"
+# Ignore EOF - end of file
+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
diff --git a/.jenkins.sh b/.jenkins.sh
index 37be6113ed9..8771427805d 100644
--- a/.jenkins.sh
+++ b/.jenkins.sh
@@ -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
#
@@ -43,9 +46,6 @@ fi
if test -z "$SLIM"; then
export VENV_SYSTEM_PACKAGES='--system-site-packages'
fi
-if test ! -z "$CATEGORY"; then
- export PY_CAT="-m $CATEGORY"
-fi
if test "$WORKSPACE" != "`pwd`"; then
echo "ERROR: pwd is not WORKSPACE"
@@ -122,10 +122,23 @@ if test -z "$MODE" -o "$MODE" == setup; then
echo "PYOMO_CONFIG_DIR=$PYOMO_CONFIG_DIR"
echo ""
+ # Call Pyomo build scripts to build TPLs that would normally be
+ # skipped by the pyomo download-extensions / build-extensions
+ # actions below
+ if [[ " $CATEGORY " == *" builders "* ]]; then
+ echo ""
+ echo "Running local build scripts..."
+ echo ""
+ set -x
+ python pyomo/contrib/simplification/build.py --build-deps || exit 1
+ set +x
+ fi
+
# Use Pyomo to download & compile binary extensions
i=0
while /bin/true; do
i=$[$i+1]
+ echo ""
echo "Downloading pyomo extensions (attempt $i)"
pyomo download-extensions $PYOMO_DOWNLOAD_ARGS
if test $? == 0; then
@@ -178,7 +191,7 @@ if test -z "$MODE" -o "$MODE" == test; then
python -m pytest -v \
-W ignore::Warning \
--junitxml="TEST-pyomo.xml" \
- $PY_CAT $TEST_SUITES $PYTEST_EXTRA_ARGS
+ -m "$CATEGORY" $TEST_SUITES $PYTEST_EXTRA_ARGS
# Combine the coverage results and upload
if test -z "$DISABLE_COVERAGE"; then
@@ -192,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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 553a4f1c3bd..8d1d1e45e3d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,173 @@ Pyomo CHANGELOG
===============
+-------------------------------------------------------------------------------
+Pyomo 6.7.3 (29 May 2024)
+-------------------------------------------------------------------------------
+
+- Core
+ - Deprecate `pyomo.core.plugins.transform.model.to_standard_form()` (#3265)
+ - Reorder definitions to avoid `NameError` in some situations (#3264)
+- Solver Interfaces
+ - NLv2: Fix linear presolver with constant defined vars/external fcns (#3276)
+- Testing
+ - Add URL checking to GHA linting job (#3259, #3261)
+ - Skip Windows Python 3.8 conda GHA job (#3269)
+- Contributed Packages
+ - DoE: Bug fixes for workshop (#3267)
+ - viewer: Update guard for pint import (#3277)
+
+-------------------------------------------------------------------------------
+Pyomo 6.7.2 (9 May 2024)
+-------------------------------------------------------------------------------
+
+- General
+ - Support config domains with either method or attribute domain_name (#3159)
+ - Automate TPL callback registrations (#3167)
+ - Fix type registrations for ExternalFunction arguments (#3168)
+ - Only modify module path and spec for deferred import modules (#3176)
+ - Add "mixed" standard form representation (#3201)
+ - Support "default" dispatchers in `ExitNodeDispatcher` (#3194)
+ - Redefine objective sense as a proper `IntEnum` (#3224)
+ - Fix division-by-0 bug in linear walker (#3246)
+- Core
+ - Allow `Var` objects in `LinearExpression.args` (#3189)
+ - Add type hints to components (#3173)
+ - Simplify expressions generated by `TemplateSumExpression` (#3196)
+ - Make component data public classes (#3221, #3253)
+ - Exploit repeated named expressions in `identify_variables` (#3190)
+- Documentation
+ - NFC: Add link to the HOMOWP companion notebooks (#3195)
+ - Update installation documentation to include Cython instructions (#3208)
+ - Add links to the Pyomo Book Springer page (#3211)
+- Solver Interfaces
+ - Fix division by zero error in linear presolve (#3161)
+ - Subprocess timeout update (#3183)
+ - Solver Refactor - Bug fixes for various components (#3181, #3214, #3228)
+ - NLv2: handle presolved independent linear subsystems (#3193)
+ - Update `LegacySolverWrapper` compatibility with the `pyomo` script (#3202)
+ - Fix mosek_direct to use putqconk instead of putqcon (#3199)
+ - Check _skip_trivial_constraints before the constraint body (#3226)
+ - Fix AMPL solver duplicate funcadd (#3206)
+ - Disable the use of universal newlines in the ipopt_v2 NL file (#3231)
+ - NLv2: fix reporting numbers of nonlinear discrete variables (#3238)
+ - Fix: Get SCIP solving time considering float number with some text (#3234)
+ - Solver Refactor - Add `gurobi_direct` implementation (#3225)
+- Testing
+ - Update TPL package list due to `contrib.solver` (#3164)
+ - Set maxDiff=None on the base TestCase class (#3171)
+ - Testing infrastructure updates (#3175)
+ - Typos update for March 2024 (#3219)
+ - Add openmpi to testing environment to resolve issue in mpi4py (#3236, #3239)
+ - Skip black 24.4.1 due to a bug in the parser (#3247)
+ - Skip tests on draft and WIP pull requests (#3223)
+ - Update GHA to grab gurobipy from PyPI (#3254)
+- GDP
+ - Use private_data for all original / transformed component mappings (#3166)
+ - Fix a bug in gdp.bigm transformation for nested GDPs (#3213)
+- Contributed Packages
+ - APPSI: cmodel: handle non-mutable params in var / constraint bounds (#3182)
+ - APPSI: Allow APPSI FBBT to handle nested named Expressions (#3185)
+ - APPSI: Add MAiNGO solver interface (#3165)
+ - CP: Add SequenceVar and other logical expressions for scheduling (#3227)
+ - DoE: Bug fixes (#3245)
+ - iis: Add minimal intractable system infeasibility diagnostics (#3172)
+ - incidence_analysis: Improve `solve_strongly_connected_components`
+ performance for models with named expressions (#3186)
+ - incidence_analysis: Add function to plot incidence graph in
+ Dulmage-Mendelsohn order (#3207)
+ - incidence_analysis: Require variables and constraints to be specified
+ separately in `IncidenceGraphInterface.remove_nodes` (#3212)
+ - latex_printer: bugfix for set operations / multidimensional sets (#3177)
+ - MindtPy: Add HiGHS support (#2971)
+ - MindtPy: Add call_before_subproblem_solve callback (#3251)
+ - Parmest: New UI using experiment lists (#3160)
+ - piecewise: Add piecewise linear transformations (#3036)
+ - preprocessing: bugfix: intersect domains in variable aggregator (#3241)
+ - PyNumero: Allow CyIpopt to solve problems without objectives (#3163)
+ - PyNumero: Work around bug in CyIpopt 1.4.0 (#3222)
+ - PyNumero: Include "inventory" in readme (#3248)
+ - PyROS: Simplify custom domain validators (#3169)
+ - PyROS: Fix iteration logging for edge case involving discrete sets (#3170)
+ - PyROS: Update solver timing system (#3198)
+ - simplification: expression simplification using GiNaC or SymPy (#3088)
+
+-------------------------------------------------------------------------------
+Pyomo 6.7.1 (21 Feb 2024)
+-------------------------------------------------------------------------------
+
+- General
+ - Add support for tuples in `ComponentMap`; add `DefaultComponentMap` (#3150)
+ - Update `Path`, `PathList`, and `IsInstance` Domain Validators (#3144)
+ - Remove usage of `__all__` (#3142)
+ - Extend Path and Type Checking Validators of `common.config` (#3140)
+ - Update Copyright Statements (#3139)
+ - Update `ExitNodeDispatcher` to better support extensibility (#3125)
+ - Create contributors data gathering script (#3117)
+ - Prevent duplicate entries in ConfigDict declaration order (#3116)
+ - Remove unnecessary `__future__` imports (#3109)
+ - Import pandas through pyomo.common.dependencies (#3102)
+ - Update links to workshop slides (#3079)
+ - Remove incorrect use of identity (is) comparisons (#3061)
+- Core
+ - Add `Block.register_private_data_initializer()` (#3153)
+ - Generalize the simple_constraint_rule decorator (#3152)
+ - Fix edge case assigning new numeric types to Var/Param with units (#3151)
+ - Add private_data to `_BlockData` (#3138)
+ - IndexComponent create implicit sets as "anonymous" sets (#3075)
+ - Add `all_different` and `count_if` to the logical expression system (#3058)
+ - Fix RangeSet.__len__ when defined by floats (#3119)
+ - Overhaul the `Suffix` component (#3072)
+ - Enforce expression immutability in `expr.args` (#3099)
+ - Improve NumPy registration when assigning numpy to Param (#3093)
+ - Track changes in PyPy behavior introduced in 7.3.14 (#3087)
+ - Remove automatic numpy import (#3077)
+ - Fix `range_difference` for Sets with nonzero anchor points (#3063)
+ - Clarify errors raised by accessing Sets by positional index (#3062)
+- Documentation
+ - Update intersphinx links, remove docs for nonfunctional code (#3155)
+ - Update MPC documentation and citation (#3148)
+ - Fix an error in the documentation for LinearExpression (#3090)
+ - Fix Pyomo.DoE documentation (#3070)
+ - Fix latex_printer documentation (#3066)
+- Solver Interfaces
+ - Preview release of new solver interfaces as pyomo.contrib.solver
+ (#3137, #3156)
+ - Make error msg more explicit wrt different interfaces (#3141)
+ - NLv2: only raise exception for empty models in the legacy API (#3135)
+ - Add `to_expr()` to AMPLRepn, fix NLWriterInfo return type (#3095)
+- Testing
+ - Update Release Wheel Builder Action (#3149)
+ - Actions Version Update: Address node.js deprecations (#3118)
+ - New Black Major Release (24.1.0) (#3108)
+ - Use scip for PyROS tests (#3104)
+ - Add missing solver dependency flags for OnlineDocs tests (#3094)
+ - Re-enable `contrib.viewer.tests.test_qt.py` (#3085)
+ - Add automated testing of OnlineDocs examples (#3080)
+ - Silence deprecation warnings emitted by Pyomo tests (#3076)
+ - Fix Python 3.12 tests (manage `pyutilib`, `distutils` dependencies) (#3065)
+- DAE
+ - Replace deprecated `numpy.math` alias with standard `math` module (#3074)
+- GDP
+ - Handle nested GDPs correctly in all the transformations (#3145)
+ - Fix bugs in nested models in gdp.hull transformation (#3143)
+ - Various bug fixes in gdp.mbigm transformation (#3073)
+ - Add GDP => MINLP Transformation (#3082)
+- Contributed Packages
+ - GDPopt: Fix lbb solve_data bug (#3133)
+ - GDPopt: Adding missing import for gdpopt.enumerate (#3105)
+ - FBBT: Extend `fbbt.ExpressionBoundsVisitor` to handle relational
+ expressions and Expr_if (#3129)
+ - incidence_analysis: Method to add an edge in IncidenceGraphInterface (#3120)
+ - incidence_analysis: Add subgraph method to IncidencegraphInterface (#3122)
+ - incidence_analysis: Add `ampl_repn` option (#3069)
+ - incidence_analysis: Update documentation (#3067)
+ - interior_point: Resolve test failure due to Mumps update (#3114)
+ - MindtPy: Various bug fixes (#3034)
+ - PyROS: Update Solver Argument Resolution and Validation Routines (#3126)
+ - PyROS: Update Subproblem Initialization Routines (#3071)
+ - PyROS: Fix DR polishing under nominal objective focus (#3060)
+
-------------------------------------------------------------------------------
Pyomo 6.7.0 (29 Nov 2023)
-------------------------------------------------------------------------------
diff --git a/LICENSE.md b/LICENSE.md
index 192d315e4b5..9fd5d9b810c 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,7 +1,7 @@
LICENSE
=======
-Copyright (c) 2008-2022 National Technology and Engineering Solutions of
+Copyright (c) 2008-2024 National Technology and Engineering Solutions of
Sandia, LLC . Under the terms of Contract DE-NA0003525 with National
Technology and Engineering Solutions of Sandia, LLC , the U.S.
Government retains certain rights in this software.
diff --git a/README.md b/README.md
index 2f8a25403c2..707f1a06c5a 100644
--- a/README.md
+++ b/README.md
@@ -71,8 +71,11 @@ version, we will remove testing for that Python version.
### Tutorials and Examples
+* [Pyomo — Optimization Modeling in Python](https://link.springer.com/book/10.1007/978-3-030-68928-5)
* [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/)
+* The [companion notebooks](https://mobook.github.io/MO-book/intro.html)
+ for *Hands-On Mathematical Optimization with Python*
* [Pyomo Gallery](https://github.com/Pyomo/PyomoGallery)
### Getting Help
@@ -83,7 +86,7 @@ To get help from the Pyomo community ask a question on one of the following:
### Developers
-Pyomo development moved to this repository in June, 2016 from
+Pyomo development moved to this repository in June 2016 from
Sandia National Laboratories. Developer discussions are hosted by
[Google Groups](https://groups.google.com/forum/#!forum/pyomo-developers).
diff --git a/RELEASE.md b/RELEASE.md
index 03baa803ac9..e42469cbad5 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -1,4 +1,4 @@
-We are pleased to announce the release of Pyomo 6.7.0.
+We are pleased to announce the release of Pyomo 6.7.3.
Pyomo is a collection of Python software packages that supports a
diverse set of optimization capabilities for formulating and analyzing
@@ -9,8 +9,15 @@ The following are highlights of the 6.7 release series:
- Added support for Python 3.12
- Removed support for Python 3.7
- New writer for converting linear models to matrix form
+ - Improved handling of nested GDPs
+ - Redesigned user API for parameter estimation
- New packages:
- - latex_printer (print Pyomo models to a LaTeX compatible format)
+ - iis: new capability for identifying minimal intractable systems
+ - latex_printer: print Pyomo models to a LaTeX compatible format
+ - contrib.solver: preview of redesigned solver interfaces
+ - simplification: simplify Pyomo expressions
+ - New solver interfaces
+ - MAiNGO: Mixed-integer nonlinear global optimization
- ...and of course numerous minor bug fixes and performance enhancements
A full list of updates and changes is available in the
diff --git a/.codecov.yml b/codecov.yml
similarity index 54%
rename from .codecov.yml
rename to codecov.yml
index 6b88f948fe1..318a907905f 100644
--- a/.codecov.yml
+++ b/codecov.yml
@@ -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
diff --git a/conftest.py b/conftest.py
index df5b0f31e59..34b366f9fd6 100644
--- a/conftest.py
+++ b/conftest.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -11,6 +11,22 @@
import pytest
+_implicit_markers = {'default'}
+_extended_implicit_markers = _implicit_markers.union({'solver'})
+
+
+def pytest_collection_modifyitems(items):
+ """
+ This method will mark any unmarked tests with the implicit marker ('default')
+
+ """
+ for item in items:
+ try:
+ next(item.iter_markers())
+ except StopIteration:
+ for marker in _implicit_markers:
+ item.add_marker(getattr(pytest.mark, marker))
+
def pytest_runtest_setup(item):
"""
@@ -32,13 +48,10 @@ def pytest_runtest_setup(item):
the default mode; but if solver tests are also marked with an explicit
category (e.g., "expensive"), we will skip them.
"""
- marker = item.iter_markers()
solvernames = [mark.args[0] for mark in item.iter_markers(name="solver")]
solveroption = item.config.getoption("--solver")
markeroption = item.config.getoption("-m")
- implicit_markers = ['default']
- extended_implicit_markers = implicit_markers + ['solver']
- item_markers = set(mark.name for mark in marker)
+ item_markers = set(mark.name for mark in item.iter_markers())
if solveroption:
if solveroption not in solvernames:
pytest.skip("SKIPPED: Test not marked {!r}".format(solveroption))
@@ -46,9 +59,9 @@ def pytest_runtest_setup(item):
elif markeroption:
return
elif item_markers:
- if not set(implicit_markers).issubset(
- item_markers
- ) and not item_markers.issubset(set(extended_implicit_markers)):
+ if not _implicit_markers.issubset(item_markers) and not item_markers.issubset(
+ _extended_implicit_markers
+ ):
pytest.skip('SKIPPED: Only running default, solver, and unmarked tests.')
diff --git a/doc/OnlineDocs/advanced_topics/flattener/index.rst b/doc/OnlineDocs/advanced_topics/flattener/index.rst
index 377de5233ec..f9dd8ea6abb 100644
--- a/doc/OnlineDocs/advanced_topics/flattener/index.rst
+++ b/doc/OnlineDocs/advanced_topics/flattener/index.rst
@@ -30,8 +30,9 @@ The ``pyomo.dae.flatten`` module aims to address this use case by providing
utilities to generate all components indexed, explicitly or implicitly, by
user-provided sets.
-**When we say "flatten a model," we mean "generate all components in the model,
-preserving all user-specified indexing sets."**
+**When we say "flatten a model," we mean "recursively generate all components in
+the model," where a component can be indexed only by user-specified indexing
+sets (or is not indexed at all)**.
Data structures
---------------
@@ -42,3 +43,23 @@ Slices are necessary as they can encode "implicit indexing" -- where a
component is contained in an indexed block. It is natural to return references
to these slices, so they may be accessed and manipulated like any other
component.
+
+Citation
+--------
+If you use the ``pyomo.dae.flatten`` module in your research, we would appreciate
+you citing the following paper, which gives more detail about the motivation for
+and examples of using this functinoality.
+
+.. code-block:: bibtex
+
+ @article{parker2023mpc,
+ title = {Model predictive control simulations with block-hierarchical differential-algebraic process models},
+ journal = {Journal of Process Control},
+ volume = {132},
+ pages = {103113},
+ year = {2023},
+ issn = {0959-1524},
+ doi = {https://doi.org/10.1016/j.jprocont.2023.103113},
+ url = {https://www.sciencedirect.com/science/article/pii/S0959152423002007},
+ author = {Robert B. Parker and Bethany L. Nicholson and John D. Siirola and Lorenz T. Biegler},
+ }
diff --git a/doc/OnlineDocs/bibliography.rst b/doc/OnlineDocs/bibliography.rst
index 6cbb96d3bfb..c12d3f81d8c 100644
--- a/doc/OnlineDocs/bibliography.rst
+++ b/doc/OnlineDocs/bibliography.rst
@@ -39,6 +39,8 @@ Bibliography
John D. Siirola, Jean-Paul Watson, and David L. Woodruff.
Pyomo - Optimization Modeling in Python, 3rd Edition.
Vol. 67. Springer, 2021.
+ doi: `10.1007/978-3-030-68928-5
+ `_
.. [PyomoJournal] William E. Hart, Jean-Paul Watson, David L. Woodruff.
"Pyomo: modeling and solving mathematical programs in
diff --git a/doc/OnlineDocs/conf.py b/doc/OnlineDocs/conf.py
index ef6510daedf..a06ccfbc9bd 100644
--- a/doc/OnlineDocs/conf.py
+++ b/doc/OnlineDocs/conf.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
@@ -46,8 +57,8 @@
'numpy': ('https://numpy.org/doc/stable/', None),
'pandas': ('https://pandas.pydata.org/docs/', None),
'scikit-learn': ('https://scikit-learn.org/stable/', None),
- 'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
- 'Sphinx': ('https://www.sphinx-doc.org/en/stable/', None),
+ 'scipy': ('https://docs.scipy.org/doc/scipy/', None),
+ 'Sphinx': ('https://www.sphinx-doc.org/en/master/', None),
}
# -- General configuration ------------------------------------------------
@@ -72,6 +83,8 @@
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx_copybutton',
+ 'enum_tools.autoenum',
+ 'sphinx.ext.autosectionlabel',
#'sphinx.ext.githubpages',
]
@@ -259,7 +272,7 @@ def check_output(self, want, got, optionflags):
yaml_available, networkx_available, matplotlib_available,
pympler_available, dill_available,
)
-pint_available = attempt_import('pint', defer_check=False)[1]
+pint_available = attempt_import('pint', defer_import=False)[1]
from pyomo.contrib.parmest.parmest import parmest_available
import pyomo.environ as _pe # (trigger all plugin registrations)
diff --git a/doc/OnlineDocs/contributed_packages/iis.rst b/doc/OnlineDocs/contributed_packages/iis.rst
index 98cb9e30771..fa97c2f8c61 100644
--- a/doc/OnlineDocs/contributed_packages/iis.rst
+++ b/doc/OnlineDocs/contributed_packages/iis.rst
@@ -1,6 +1,135 @@
+Infeasibility Diagnostics
+!!!!!!!!!!!!!!!!!!!!!!!!!
+
+There are two closely related tools for infeasibility diagnosis:
+
+ - :ref:`Infeasible Irreducible System (IIS) Tool`
+ - :ref:`Minimal Intractable System finder (MIS) Tool`
+
+The first simply provides a conduit for solvers that compute an
+infeasible irreducible system (e.g., Cplex, Gurobi, or Xpress). The
+second provides similar functionality, but uses the ``mis`` package
+contributed to Pyomo.
+
+
Infeasible Irreducible System (IIS) Tool
========================================
.. automodule:: pyomo.contrib.iis.iis
.. autofunction:: pyomo.contrib.iis.write_iis
+
+Minimal Intractable System finder (MIS) Tool
+============================================
+
+The file ``mis.py`` finds sets of actions that each, independently,
+would result in feasibility. The zero-tolerance is whatever the
+solver uses, so users may want to post-process output if it is going
+to be used for analysis. It also computes a minimal intractable system
+(which is not guaranteed to be unique). It was written by Ben Knueven
+as part of the watertap project (https://github.com/watertap-org/watertap)
+and is therefore governed by a license shown
+at the top of ``mis.py``.
+
+The algorithms come from John Chinneck's slides, see: https://www.sce.carleton.ca/faculty/chinneck/docs/CPAIOR07InfeasibilityTutorial.pdf
+
+Solver
+------
+
+At the time of this writing, you need to use IPopt even for LPs.
+
+Quick Start
+-----------
+
+The file ``trivial_mis.py`` is a tiny example listed at the bottom of
+this help file, which references a Pyomo model with the Python variable
+`m` and has these lines:
+
+.. code-block:: python
+
+ from pyomo.contrib.mis import compute_infeasibility_explanation
+ ipopt = pyo.SolverFactory("ipopt")
+ compute_infeasibility_explanation(m, solver=ipopt)
+
+.. Note::
+ This is done instead of solving the problem.
+
+.. Note::
+ IDAES users can pass ``get_solver()`` imported from ``ideas.core.solvers``
+ as the solver.
+
+Interpreting the Output
+-----------------------
+
+Assuming the dependencies are installed, running ``trivial_mis.py``
+(shown below) will
+produce a lot of warnings from IPopt and then meaningful output (using a logger).
+
+Repair Options
+^^^^^^^^^^^^^^
+
+This output for the trivial example shows three independent ways that the model could be rendered feasible:
+
+
+.. code-block:: text
+
+ Model Trivial Quad may be infeasible. A feasible solution was found with only the following variable bounds relaxed:
+ ub of var x[1] by 4.464126126706818e-05
+ lb of var x[2] by 0.9999553410114216
+ Another feasible solution was found with only the following variable bounds relaxed:
+ lb of var x[1] by 0.7071067726864677
+ ub of var x[2] by 0.41421355687130673
+ ub of var y by 0.7071067651855212
+ Another feasible solution was found with only the following inequality constraints, equality constraints, and/or variable bounds relaxed:
+ constraint: c by 0.9999999861866736
+
+
+Minimal Intractable System (MIS)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This output shows a minimal intractable system:
+
+
+.. code-block:: text
+
+ Computed Minimal Intractable System (MIS)!
+ Constraints / bounds in MIS:
+ lb of var x[2]
+ lb of var x[1]
+ constraint: c
+
+Constraints / bounds in guards for stability
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This part of the report is for nonlinear programs (NLPs).
+
+When we’re trying to reduce the constraint set, for an NLP there may be constraints that when missing cause the solver
+to fail in some catastrophic fashion. In this implementation this is interpreted as failing to get a `results`
+object back from the call to `solve`. In these cases we keep the constraint in the problem but it’s in the
+set of “guard” constraints – we can’t really be sure they’re a source of infeasibility or not,
+just that “bad things” happen when they’re not included.
+
+Perhaps ideally we would put a constraint in the “guard” set if IPopt failed to converge, and only put it in the
+MIS if IPopt converged to a point of local infeasibility. However, right now the code generally makes the
+assumption that if IPopt fails to converge the subproblem is infeasible, though obviously that is far from the truth.
+Hence for difficult NLPs even the “Phase 1” may “fail” – in that when finished the subproblem containing just the
+constraints in the elastic filter may be feasible -- because IPopt failed to converge and we assumed that meant the
+subproblem was not feasible.
+
+Dealing with NLPs is far from clean, but that doesn’t mean the tool can’t return useful results even when its assumptions are not satisfied.
+
+trivial_mis.py
+--------------
+
+.. code-block:: python
+
+ import pyomo.environ as pyo
+ m = pyo.ConcreteModel("Trivial Quad")
+ m.x = pyo.Var([1,2], bounds=(0,1))
+ m.y = pyo.Var(bounds=(0, 1))
+ m.c = pyo.Constraint(expr=m.x[1] * m.x[2] == -1)
+ m.d = pyo.Constraint(expr=m.x[1] + m.y >= 1)
+
+ from pyomo.contrib.mis import compute_infeasibility_explanation
+ ipopt = pyo.SolverFactory("ipopt")
+ compute_infeasibility_explanation(m, solver=ipopt)
diff --git a/doc/OnlineDocs/contributed_packages/mpc/api.rst b/doc/OnlineDocs/contributed_packages/mpc/api.rst
new file mode 100644
index 00000000000..2752fea8af6
--- /dev/null
+++ b/doc/OnlineDocs/contributed_packages/mpc/api.rst
@@ -0,0 +1,10 @@
+.. _mpc_api:
+
+API Reference
+=============
+
+.. toctree::
+ data.rst
+ conversion.rst
+ interface.rst
+ modeling.rst
diff --git a/doc/OnlineDocs/contributed_packages/mpc/conversion.rst b/doc/OnlineDocs/contributed_packages/mpc/conversion.rst
new file mode 100644
index 00000000000..9d9406edb75
--- /dev/null
+++ b/doc/OnlineDocs/contributed_packages/mpc/conversion.rst
@@ -0,0 +1,5 @@
+Data Conversion
+===============
+
+.. automodule:: pyomo.contrib.mpc.data.convert
+ :members:
diff --git a/doc/OnlineDocs/contributed_packages/mpc/data.rst b/doc/OnlineDocs/contributed_packages/mpc/data.rst
new file mode 100644
index 00000000000..73cb6543b1e
--- /dev/null
+++ b/doc/OnlineDocs/contributed_packages/mpc/data.rst
@@ -0,0 +1,17 @@
+Data Structures
+===============
+
+.. automodule:: pyomo.contrib.mpc.data.get_cuid
+ :members:
+
+.. automodule:: pyomo.contrib.mpc.data.dynamic_data_base
+ :members:
+
+.. automodule:: pyomo.contrib.mpc.data.scalar_data
+ :members:
+
+.. automodule:: pyomo.contrib.mpc.data.series_data
+ :members:
+
+.. automodule:: pyomo.contrib.mpc.data.interval_data
+ :members:
diff --git a/doc/OnlineDocs/contributed_packages/mpc/index.rst b/doc/OnlineDocs/contributed_packages/mpc/index.rst
index b93abf223e2..e512d1a6ef5 100644
--- a/doc/OnlineDocs/contributed_packages/mpc/index.rst
+++ b/doc/OnlineDocs/contributed_packages/mpc/index.rst
@@ -1,7 +1,7 @@
MPC
===
-This package contains data structures and utilities for dynamic optimization
+Pyomo MPC contains data structures and utilities for dynamic optimization
and rolling horizon applications, e.g. model predictive control.
.. toctree::
@@ -10,3 +10,23 @@ and rolling horizon applications, e.g. model predictive control.
overview.rst
examples.rst
faq.rst
+ api.rst
+
+Citation
+--------
+
+If you use Pyomo MPC in your research, please cite the following paper:
+
+.. code-block:: bibtex
+
+ @article{parker2023mpc,
+ title = {Model predictive control simulations with block-hierarchical differential-algebraic process models},
+ journal = {Journal of Process Control},
+ volume = {132},
+ pages = {103113},
+ year = {2023},
+ issn = {0959-1524},
+ doi = {https://doi.org/10.1016/j.jprocont.2023.103113},
+ url = {https://www.sciencedirect.com/science/article/pii/S0959152423002007},
+ author = {Robert B. Parker and Bethany L. Nicholson and John D. Siirola and Lorenz T. Biegler},
+ }
diff --git a/doc/OnlineDocs/contributed_packages/mpc/interface.rst b/doc/OnlineDocs/contributed_packages/mpc/interface.rst
new file mode 100644
index 00000000000..eb5bac548fd
--- /dev/null
+++ b/doc/OnlineDocs/contributed_packages/mpc/interface.rst
@@ -0,0 +1,8 @@
+Interfaces
+==========
+
+.. automodule:: pyomo.contrib.mpc.interfaces.model_interface
+ :members:
+
+.. automodule:: pyomo.contrib.mpc.interfaces.var_linker
+ :members:
diff --git a/doc/OnlineDocs/contributed_packages/mpc/modeling.rst b/doc/OnlineDocs/contributed_packages/mpc/modeling.rst
new file mode 100644
index 00000000000..cbae03161b1
--- /dev/null
+++ b/doc/OnlineDocs/contributed_packages/mpc/modeling.rst
@@ -0,0 +1,11 @@
+Modeling Components
+===================
+
+.. automodule:: pyomo.contrib.mpc.modeling.constraints
+ :members:
+
+.. automodule:: pyomo.contrib.mpc.modeling.cost_expressions
+ :members:
+
+.. automodule:: pyomo.contrib.mpc.modeling.terminal
+ :members:
diff --git a/doc/OnlineDocs/contributed_packages/mpc/overview.rst b/doc/OnlineDocs/contributed_packages/mpc/overview.rst
index f5dbe85e523..f3bc7504b59 100644
--- a/doc/OnlineDocs/contributed_packages/mpc/overview.rst
+++ b/doc/OnlineDocs/contributed_packages/mpc/overview.rst
@@ -189,7 +189,7 @@ a tracking cost expression.
>>> m.setpoint_idx = var_set
>>> m.tracking_cost = tr_cost
>>> m.tracking_cost.pprint()
- tracking_cost : Size=6, Index=tracking_cost_index
+ tracking_cost : Size=6, Index=setpoint_idx*time
Key : Expression
(0, 0) : (var[0,A] - 0.5)**2
(0, 1) : (var[1,A] - 0.5)**2
diff --git a/doc/OnlineDocs/contributed_packages/parmest/datarec.rst b/doc/OnlineDocs/contributed_packages/parmest/datarec.rst
index 6b721377e46..2260450192c 100644
--- a/doc/OnlineDocs/contributed_packages/parmest/datarec.rst
+++ b/doc/OnlineDocs/contributed_packages/parmest/datarec.rst
@@ -3,56 +3,52 @@
Data Reconciliation
====================
-The method :class:`~pyomo.contrib.parmest.parmest.Estimator.theta_est`
-can optionally return model values. This feature can be used to return
-reconciled data using a user specified objective. In this case, the list
-of variable names the user wants to estimate (theta_names) is set to an
-empty list and the objective function is defined to minimize
+The optional argument ``return_values`` in :class:`~pyomo.contrib.parmest.parmest.Estimator.theta_est`
+can be used for data reconciliation or to return model values based on the specified objective.
+
+For data reconciliation, the ``m.unknown_parameters`` is empty
+and the objective function is defined to minimize
measurement to model error. Note that the model used for data
reconciliation may differ from the model used for parameter estimation.
-The following example illustrates the use of parmest for data
-reconciliation. The functions
+The functions
:class:`~pyomo.contrib.parmest.graphics.grouped_boxplot` or
:class:`~pyomo.contrib.parmest.graphics.grouped_violinplot` can be used
to visually compare the original and reconciled data.
-Here's a stylized code snippet showing how box plots might be created:
-
-.. doctest::
- :skipif: True
-
- >>> import pyomo.contrib.parmest.parmest as parmest
- >>> pest = parmest.Estimator(model_function, data, [], objective_function)
- >>> obj, theta, data_rec = pest.theta_est(return_values=['A', 'B'])
- >>> parmest.graphics.grouped_boxplot(data, data_rec)
-
-Returned Values
-^^^^^^^^^^^^^^^
+The following example from the reactor design subdirectory returns reconciled values for experiment outputs
+(`ca`, `cb`, `cc`, and `cd`) and then uses those values in
+parameter estimation (`k1`, `k2`, and `k3`).
-Here's a full program that can be run to see returned values (in this case it
-is the response function that is defined in the model file):
+.. literalinclude:: ../../../../pyomo/contrib/parmest/examples/reactor_design/datarec_example.py
+ :language: python
+
+The following example returns model values from a Pyomo Expression.
.. doctest::
:skipif: not ipopt_available or not parmest_available
>>> import pandas as pd
>>> import pyomo.contrib.parmest.parmest as parmest
- >>> from pyomo.contrib.parmest.examples.rooney_biegler.rooney_biegler import rooney_biegler_model
-
- >>> theta_names = ['asymptote', 'rate_constant']
+ >>> from pyomo.contrib.parmest.examples.rooney_biegler.rooney_biegler import RooneyBieglerExperiment
+ >>> # Generate data
>>> data = pd.DataFrame(data=[[1,8.3],[2,10.3],[3,19.0],
... [4,16.0],[5,15.6],[7,19.8]],
... columns=['hour', 'y'])
- >>> def SSE(model, data):
- ... expr = sum((data.y[i]\
- ... - model.response_function[data.hour[i]])**2 for i in data.index)
+ >>> # Create an experiment list
+ >>> exp_list = []
+ >>> for i in range(data.shape[0]):
+ ... exp_list.append(RooneyBieglerExperiment(data.loc[i, :]))
+
+ >>> # Define objective
+ >>> def SSE(model):
+ ... expr = (model.experiment_outputs[model.y]
+ ... - model.response_function[model.experiment_outputs[model.hour]]
+ ... ) ** 2
... return expr
- >>> pest = parmest.Estimator(rooney_biegler_model, data, theta_names, SSE,
- ... solver_options=None)
+ >>> pest = parmest.Estimator(exp_list, obj_function=SSE, solver_options=None)
>>> obj, theta, var_values = pest.theta_est(return_values=['response_function'])
>>> #print(var_values)
-
diff --git a/doc/OnlineDocs/contributed_packages/parmest/driver.rst b/doc/OnlineDocs/contributed_packages/parmest/driver.rst
index 28238928b83..5881d2748f9 100644
--- a/doc/OnlineDocs/contributed_packages/parmest/driver.rst
+++ b/doc/OnlineDocs/contributed_packages/parmest/driver.rst
@@ -4,7 +4,7 @@ Parameter Estimation
==================================
Parameter Estimation using parmest requires a Pyomo model, experimental
-data which defines multiple scenarios, and a list of parameter names
+data which defines multiple scenarios, and parameters
(thetas) to estimate. parmest uses Pyomo [PyomoBookII]_ and (optionally)
mpi-sppy [mpisppy]_ to solve a
two-stage stochastic programming problem, where the experimental data is
@@ -36,13 +36,12 @@ which includes the following methods:
~pyomo.contrib.parmest.parmest.Estimator.likelihood_ratio_test
~pyomo.contrib.parmest.parmest.Estimator.leaveNout_bootstrap_test
-Additional functions are available in parmest to group data, plot
-results, and fit distributions to theta values.
+Additional functions are available in parmest to plot
+results and fit distributions to theta values.
.. autosummary::
:nosignatures:
- ~pyomo.contrib.parmest.parmest.group_data
~pyomo.contrib.parmest.graphics.pairwise_plot
~pyomo.contrib.parmest.graphics.grouped_boxplot
~pyomo.contrib.parmest.graphics.grouped_violinplot
@@ -58,21 +57,33 @@ Section.
.. testsetup:: *
:skipif: not __import__('pyomo.contrib.parmest.parmest').contrib.parmest.parmest.parmest_available
+ # Data
import pandas as pd
- from pyomo.contrib.parmest.examples.rooney_biegler.rooney_biegler import rooney_biegler_model as model_function
- data = pd.DataFrame(data=[[1,8.3],[2,10.3],[3,19.0],
- [4,16.0],[5,15.6],[6,19.8]],
- columns=['hour', 'y'])
- theta_names = ['asymptote', 'rate_constant']
- def objective_function(model, data):
- expr = sum((data.y[i] - model.response_function[data.hour[i]])**2 for i in data.index)
+ data = pd.DataFrame(
+ data=[[1, 8.3], [2, 10.3], [3, 19.0],
+ [4, 16.0], [5, 15.6], [7, 19.8]],
+ columns=['hour', 'y'],
+ )
+
+ # Sum of squared error function
+ def SSE(model):
+ expr = (
+ model.experiment_outputs[model.y]
+ - model.response_function[model.experiment_outputs[model.hour]]
+ ) ** 2
return expr
+ # Create an experiment list
+ from pyomo.contrib.parmest.examples.rooney_biegler.rooney_biegler import RooneyBieglerExperiment
+ exp_list = []
+ for i in range(data.shape[0]):
+ exp_list.append(RooneyBieglerExperiment(data.loc[i, :]))
+
.. doctest::
:skipif: not __import__('pyomo.contrib.parmest.parmest').contrib.parmest.parmest.parmest_available
>>> import pyomo.contrib.parmest.parmest as parmest
- >>> pest = parmest.Estimator(model_function, data, theta_names, objective_function)
+ >>> pest = parmest.Estimator(exp_list, obj_function=SSE)
Optionally, solver options can be supplied, e.g.,
@@ -80,66 +91,44 @@ Optionally, solver options can be supplied, e.g.,
:skipif: not __import__('pyomo.contrib.parmest.parmest').contrib.parmest.parmest.parmest_available
>>> solver_options = {"max_iter": 6000}
- >>> pest = parmest.Estimator(model_function, data, theta_names, objective_function, solver_options)
-
-
-
-Model function
---------------
-
-The first argument is a function which uses data for a single scenario
-to return a populated and initialized Pyomo model for that scenario.
-
-Parameters that the user would like to estimate can be defined as
-**mutable parameters (Pyomo `Param`) or variables (Pyomo `Var`)**.
-Within parmest, any parameters that are to be estimated are converted to unfixed variables.
-Variables that are to be estimated are also unfixed.
-
-The model does not have to be specifically written as a
-two-stage stochastic programming problem for parmest.
-That is, parmest can modify the
-objective, see :ref:`ObjFunction` below.
-
-Data
-----
-
-The second argument is the data which will be used to populate the Pyomo
-model. Supported data formats include:
-
-* **Pandas Dataframe** where each row is a separate scenario and column
- names refer to observed quantities. Pandas DataFrames are easily
- stored and read in from csv, excel, or databases, or created directly
- in Python.
-* **List of Pandas Dataframe** where each entry in the list is a separate scenario.
- Dataframes store observed quantities, referenced by index and column.
-* **List of dictionaries** where each entry in the list is a separate
- scenario and the keys (or nested keys) refer to observed quantities.
- Dictionaries are often preferred over DataFrames when using static and
- time series data. Dictionaries are easily stored and read in from
- json or yaml files, or created directly in Python.
-* **List of json file names** where each entry in the list contains a
- json file name for a separate scenario. This format is recommended
- when using large datasets in parallel computing.
-
-The data must be compatible with the model function that returns a
-populated and initialized Pyomo model for a single scenario. Data can
-include multiple entries per variable (time series and/or duplicate
-sensors). This information can be included in custom objective
-functions, see :ref:`ObjFunction` below.
-
-Theta names
------------
-
-The third argument is a list of parameters or variable names that the user wants to
-estimate. The list contains strings with `Param` and/or `Var` names from the Pyomo
-model.
+ >>> pest = parmest.Estimator(exp_list, obj_function=SSE, solver_options=solver_options)
+
+
+List of experiment objects
+--------------------------
+
+The first argument is a list of experiment objects which is used to
+create one labeled model for each expeirment.
+The template :class:`~pyomo.contrib.parmest.experiment.Experiment`
+can be used to generate a list of experiment objects.
+
+A labeled Pyomo model ``m`` has the following additional suffixes (Pyomo `Suffix`):
+
+* ``m.experiment_outputs`` which defines experiment output (Pyomo `Param`, `Var`, or `Expression`)
+ and their associated data values (float, int).
+* ``m.unknown_parameters`` which defines the mutable parameters or variables (Pyomo `Param` or `Var`)
+ to estimate along with their component unique identifier (Pyomo `ComponentUID`).
+ Within parmest, any parameters that are to be estimated are converted to unfixed variables.
+ Variables that are to be estimated are also unfixed.
+
+The experiment class has one required method:
+
+* :class:`~pyomo.contrib.parmest.experiment.Experiment.get_labeled_model` which returns the labeled Pyomo model.
+ Note that the model does not have to be specifically written as a
+ two-stage stochastic programming problem for parmest.
+ That is, parmest can modify the
+ objective, see :ref:`ObjFunction` below.
+
+Parmest comes with several :ref:`examplesection` that illustrates how to set up the list of experiment objects.
+The examples commonly include additional :class:`~pyomo.contrib.parmest.experiment.Experiment` class methods to
+create the model, finalize the model, and label the model. The user can customize methods to suit their needs.
.. _ObjFunction:
Objective function
------------------
-The fourth argument is an optional argument which defines the
+The second argument is an optional argument which defines the
optimization objective function to use in parameter estimation.
If no objective function is specified, the Pyomo model is used "as is" and
@@ -150,20 +139,27 @@ stochastic programming problem.
If the Pyomo model is not written as a two-stage stochastic programming problem in
this format, and/or if the user wants to use an objective that is
different than the original model, a custom objective function can be
-defined for parameter estimation. The objective function arguments
-include `model` and `data` and the objective function returns a Pyomo
+defined for parameter estimation. The objective function has a single argument,
+which is the model from a single experiment.
+The objective function returns a Pyomo
expression which is used to define "SecondStageCost". The objective
function can be used to customize data points and weights that are used
in parameter estimation.
+Parmest includes one built in objective function to compute the sum of squared errors ("SSE") between the
+``m.experiment_outputs`` model values and data values.
+
Suggested initialization procedure for parameter estimation problems
--------------------------------------------------------------------
To check the quality of initial guess values provided for the fitted parameters, we suggest solving a
square instance of the problem prior to solving the parameter estimation problem using the following steps:
-1. Create :class:`~pyomo.contrib.parmest.parmest.Estimator` object. To initialize the parameter estimation solve from the square problem solution, set optional argument ``solver_options = {bound_push: 1e-8}``.
+1. Create :class:`~pyomo.contrib.parmest.parmest.Estimator` object. To initialize the parameter
+estimation solve from the square problem solution, set optional argument ``solver_options = {bound_push: 1e-8}``.
-2. Call :class:`~pyomo.contrib.parmest.parmest.Estimator.objective_at_theta` with optional argument ``(initialize_parmest_model=True)``. Different initial guess values for the fitted parameters can be provided using optional argument `theta_values` (**Pandas Dataframe**)
+2. Call :class:`~pyomo.contrib.parmest.parmest.Estimator.objective_at_theta` with optional
+argument ``(initialize_parmest_model=True)``. Different initial guess values for the fitted
+parameters can be provided using optional argument `theta_values` (**Pandas Dataframe**)
3. Solve parameter estimation problem by calling :class:`~pyomo.contrib.parmest.parmest.Estimator.theta_est`
diff --git a/doc/OnlineDocs/contributed_packages/parmest/examples.rst b/doc/OnlineDocs/contributed_packages/parmest/examples.rst
index 793ff3d0c8d..a59d79dfa2b 100644
--- a/doc/OnlineDocs/contributed_packages/parmest/examples.rst
+++ b/doc/OnlineDocs/contributed_packages/parmest/examples.rst
@@ -20,7 +20,7 @@ Additional use cases include:
* Parameter estimation using mpi4py, the example saves results to a file
for later analysis/graphics (semibatch example)
-The description below uses the reactor design example. The file
+The example below uses the reactor design example. The file
**reactor_design.py** includes a function which returns an populated
instance of the Pyomo model. Note that the model is defined to maximize
`cb` and that `k1`, `k2`, and `k3` are fixed. The _main_ program is
diff --git a/doc/OnlineDocs/contributed_packages/parmest/scencreate.rst b/doc/OnlineDocs/contributed_packages/parmest/scencreate.rst
index 66d41d4c606..b63ac5893c2 100644
--- a/doc/OnlineDocs/contributed_packages/parmest/scencreate.rst
+++ b/doc/OnlineDocs/contributed_packages/parmest/scencreate.rst
@@ -18,5 +18,5 @@ scenarios to the screen, accessing them via the ``ScensItator`` a ``print``
:language: python
.. note::
- This example may produce an error message your version of Ipopt is not based
+ This example may produce an error message if your version of Ipopt is not based
on a good linear solver.
diff --git a/doc/OnlineDocs/contributed_packages/pynumero/backward_compatibility.rst b/doc/OnlineDocs/contributed_packages/pynumero/backward_compatibility.rst
new file mode 100644
index 00000000000..036a00bee62
--- /dev/null
+++ b/doc/OnlineDocs/contributed_packages/pynumero/backward_compatibility.rst
@@ -0,0 +1,14 @@
+Backward Compatibility
+======================
+
+While PyNumero is a third-party contribution to Pyomo, we intend to maintain
+the stability of its core functionality. The core functionality of PyNumero
+consists of:
+
+1. The ``NLP`` API and ``PyomoNLP`` implementation of this API
+2. HSL and MUMPS linear solver interfaces
+3. ``BlockVector`` and ``BlockMatrix`` classes
+4. CyIpopt and SciPy solver interfaces
+
+Other parts of PyNumero, such as ``ExternalGreyBoxBlock`` and
+``ImplicitFunctionSolver``, are experimental and subject to change without notice.
diff --git a/doc/OnlineDocs/contributed_packages/pynumero/index.rst b/doc/OnlineDocs/contributed_packages/pynumero/index.rst
index 6ff8b29f812..711bb83eb3b 100644
--- a/doc/OnlineDocs/contributed_packages/pynumero/index.rst
+++ b/doc/OnlineDocs/contributed_packages/pynumero/index.rst
@@ -13,6 +13,7 @@ PyNumero. For more details, see the API documentation (:ref:`pynumero_api`).
installation.rst
tutorial.rst
api.rst
+ backward_compatibility.rst
Developers
diff --git a/doc/OnlineDocs/contributed_packages/pynumero/pynumero.sparse.block_vector.rst b/doc/OnlineDocs/contributed_packages/pynumero/pynumero.sparse.block_vector.rst
index 6e1dc1f20e5..c17d3d1df86 100644
--- a/doc/OnlineDocs/contributed_packages/pynumero/pynumero.sparse.block_vector.rst
+++ b/doc/OnlineDocs/contributed_packages/pynumero/pynumero.sparse.block_vector.rst
@@ -77,7 +77,7 @@ NumPy compatible functions:
* `numpy.arccos() `_
* `numpy.sinh() `_
* `numpy.cosh() `_
- * `numpy.abs() `_
+ * `numpy.abs() `_
* `numpy.tanh() `_
* `numpy.arccosh() `_
* `numpy.arcsinh() `_
diff --git a/doc/OnlineDocs/contributed_packages/pyros.rst b/doc/OnlineDocs/contributed_packages/pyros.rst
index 3ff1bfccf0e..95049eded8a 100644
--- a/doc/OnlineDocs/contributed_packages/pyros.rst
+++ b/doc/OnlineDocs/contributed_packages/pyros.rst
@@ -142,6 +142,7 @@ PyROS Solver Interface
Otherwise, the solution returned is certified to only be robust feasible.
+
PyROS Uncertainty Sets
-----------------------------
Uncertainty sets are represented by subclasses of
@@ -518,7 +519,7 @@ correspond to first-stage degrees of freedom.
>>> # === Designate which variables correspond to first-stage
>>> # and second-stage degrees of freedom ===
- >>> first_stage_variables =[
+ >>> first_stage_variables = [
... m.x1, m.x2, m.x3, m.x4, m.x5, m.x6,
... m.x19, m.x20, m.x21, m.x22, m.x23, m.x24, m.x31,
... ]
@@ -539,7 +540,7 @@ correspond to first-stage degrees of freedom.
... load_solution=False,
... )
==============================================================================
- PyROS: The Pyomo Robust Optimization Solver.
+ PyROS: The Pyomo Robust Optimization Solver...
...
------------------------------------------------------------------------------
Robust optimal solution identified.
@@ -657,6 +658,54 @@ For this example, we notice a ~25% decrease in the final objective
value when switching from a static decision rule (no second-stage recourse)
to an affine decision rule.
+
+Specifying Arguments Indirectly Through ``options``
+"""""""""""""""""""""""""""""""""""""""""""""""""""
+Like other Pyomo solver interface methods,
+:meth:`~pyomo.contrib.pyros.PyROS.solve`
+provides support for specifying options indirectly by passing
+a keyword argument ``options``, whose value must be a :class:`dict`
+mapping names of arguments to :meth:`~pyomo.contrib.pyros.PyROS.solve`
+to their desired values.
+For example, the ``solve()`` statement in the
+:ref:`two-stage problem snippet `
+could have been equivalently written as:
+
+.. doctest::
+ :skipif: not (baron.available() and baron.license_is_valid())
+
+ >>> results_2 = pyros_solver.solve(
+ ... model=m,
+ ... first_stage_variables=first_stage_variables,
+ ... second_stage_variables=second_stage_variables,
+ ... uncertain_params=uncertain_parameters,
+ ... uncertainty_set=box_uncertainty_set,
+ ... local_solver=local_solver,
+ ... global_solver=global_solver,
+ ... options={
+ ... "objective_focus": pyros.ObjectiveType.worst_case,
+ ... "solve_master_globally": True,
+ ... "decision_rule_order": 1,
+ ... },
+ ... )
+ ==============================================================================
+ PyROS: The Pyomo Robust Optimization Solver...
+ ...
+ ------------------------------------------------------------------------------
+ Robust optimal solution identified.
+ ------------------------------------------------------------------------------
+ ...
+ ------------------------------------------------------------------------------
+ All done. Exiting PyROS.
+ ==============================================================================
+
+In the event an argument is passed directly
+by position or keyword, *and* indirectly through ``options``,
+an appropriate warning is issued,
+and the value passed directly takes precedence over the value
+passed through ``options``.
+
+
The Price of Robustness
""""""""""""""""""""""""
In conjunction with standard Python control flow tools,
@@ -854,10 +903,10 @@ Observe that the log contains the following information:
:linenos:
==============================================================================
- PyROS: The Pyomo Robust Optimization Solver, v1.2.9.
- Pyomo version: 6.7.0
+ PyROS: The Pyomo Robust Optimization Solver, v1.2.11.
+ Pyomo version: 6.7.2
Commit hash: unknown
- Invoked at UTC 2023-12-16T00:00:00.000000
+ Invoked at UTC 2024-03-28T00:00:00.000000
Developed by: Natalie M. Isenberg (1), Jason A. F. Sherman (1),
John D. Siirola (2), Chrysanthos E. Gounaris (1)
@@ -877,6 +926,7 @@ Observe that the log contains the following information:
keepfiles=False
tee=False
load_solution=True
+ symbolic_solver_labels=False
objective_focus=
nominal_uncertain_param_vals=[0.13248000000000001, 4.97, 4.97, 1800]
decision_rule_order=1
diff --git a/doc/OnlineDocs/contribution_guide.rst b/doc/OnlineDocs/contribution_guide.rst
index 10670627546..9ad5bdfee0e 100644
--- a/doc/OnlineDocs/contribution_guide.rst
+++ b/doc/OnlineDocs/contribution_guide.rst
@@ -71,6 +71,10 @@ at least 70% coverage of the lines modified in the PR and prefer coverage
closer to 90%. We also require that all tests pass before a PR will be
merged.
+.. note::
+ If you are having issues getting tests to pass on your Pull Request,
+ please tag any of the core developers to ask for help.
+
The Pyomo main branch provides a Github Actions workflow (configured
in the ``.github/`` directory) that will test any changes pushed to
a branch with a subset of the complete test harness that includes
@@ -82,13 +86,16 @@ This will enable the tests to run automatically with each push to your fork.
At any point in the development cycle, a "work in progress" pull request
may be opened by including '[WIP]' at the beginning of the PR
-title. This allows your code changes to be tested by the full suite of
-Pyomo's automatic
-testing infrastructure. Any pull requests marked '[WIP]' will not be
+title. Any pull requests marked '[WIP]' or draft will not be
reviewed or merged by the core development team. However, any
'[WIP]' pull request left open for an extended period of time without
active development may be marked 'stale' and closed.
+.. note::
+ Draft and WIP Pull Requests will **NOT** trigger tests. This is an effort to
+ reduce our CI backlog. Please make use of the provided
+ branch test suite for evaluating / testing draft functionality.
+
Python Version Support
++++++++++++++++++++++
@@ -397,50 +404,10 @@ Contrib packages will be tested along with Pyomo. If test failures
arise, then these packages will be disabled and an issue will be
created to resolve these test failures.
-The following two examples illustrate the two ways
-that ``pyomo.contrib`` can be used to integrate third-party
-contributions.
-
-Including External Packages
-+++++++++++++++++++++++++++
-
-The `pyomocontrib_simplemodel
-`_ package
-is derived from Pyomo, and it defines the class SimpleModel that
-illustrates how Pyomo can be used in a simple, less object-oriented
-manner. Specifically, this class mimics the modeling style supported
-by `PuLP `_.
-
-While ``pyomocontrib_simplemodel`` can be installed and used separate
-from Pyomo, this package is included in ``pyomo/contrib/simplemodel``.
-This allows this package to be referenced as if were defined as a
-subpackage of ``pyomo.contrib``. For example::
-
- from pyomo.contrib.simplemodel import *
- from math import pi
-
- m = SimpleModel()
-
- r = m.var('r', bounds=(0,None))
- h = m.var('h', bounds=(0,None))
-
- m += 2*pi*r*(r + h)
- m += pi*h*r**2 == 355
-
- status = m.solve("ipopt")
-
-This example illustrates that a package can be distributed separate
-from Pyomo while appearing to be included in the ``pyomo.contrib``
-subpackage. Pyomo requires a separate directory be defined under
-``pyomo/contrib`` for each such package, and the Pyomo developer
-team will approve the inclusion of third-party packages in this
-manner.
-
-
Contrib Packages within Pyomo
+++++++++++++++++++++++++++++
-Third-party contributions can also be included directly within the
+Third-party contributions can be included directly within the
``pyomo.contrib`` package. The ``pyomo/contrib/example`` package
provides an example of how this can be done, including a directory
for plugins and package tests. For example, this package can be
@@ -458,7 +425,7 @@ import this package, but if an import failure occurs, Pyomo will
silently ignore it. Otherwise, this pyomo package will be treated
like any other. Specifically:
-* Plugin classes defined in this package are loaded when `pyomo.environ` is loaded.
+* Plugin classes defined in this package are loaded when ``pyomo.environ`` is loaded.
* Tests in this package are run with other Pyomo tests.
diff --git a/doc/OnlineDocs/developer_reference/future.rst b/doc/OnlineDocs/developer_reference/future.rst
new file mode 100644
index 00000000000..531c0fdb5c6
--- /dev/null
+++ b/doc/OnlineDocs/developer_reference/future.rst
@@ -0,0 +1,3 @@
+
+.. automodule:: pyomo.__future__
+ :noindex:
diff --git a/doc/OnlineDocs/developer_reference/index.rst b/doc/OnlineDocs/developer_reference/index.rst
index 8c29150015c..0feb33cdab9 100644
--- a/doc/OnlineDocs/developer_reference/index.rst
+++ b/doc/OnlineDocs/developer_reference/index.rst
@@ -12,3 +12,5 @@ scripts using Pyomo.
config.rst
deprecation.rst
expressions/index.rst
+ future.rst
+ solvers.rst
diff --git a/doc/OnlineDocs/developer_reference/solvers.rst b/doc/OnlineDocs/developer_reference/solvers.rst
new file mode 100644
index 00000000000..9e3281246f4
--- /dev/null
+++ b/doc/OnlineDocs/developer_reference/solvers.rst
@@ -0,0 +1,351 @@
+Future Solver Interface Changes
+===============================
+
+.. note::
+
+ The new solver interfaces are still under active development. They
+ are included in the releases as development previews. Please be
+ aware that APIs and functionality may change with no notice.
+
+ We welcome any feedback and ideas as we develop this capability.
+ Please post feedback on
+ `Issue 1030 `_.
+
+Pyomo offers interfaces into multiple solvers, both commercial and open
+source. To support better capabilities for solver interfaces, the Pyomo
+team is actively redesigning the existing interfaces to make them more
+maintainable and intuitive for use. A preview of the redesigned
+interfaces can be found in ``pyomo.contrib.solver``.
+
+.. currentmodule:: pyomo.contrib.solver
+
+
+New Interface Usage
+-------------------
+
+The new interfaces are not completely backwards compatible with the
+existing Pyomo solver interfaces. However, to aid in testing and
+evaluation, we are distributing versions of the new solver interfaces
+that are compatible with the existing ("legacy") solver interface.
+These "legacy" interfaces are registered with the current
+``SolverFactory`` using slightly different names (to avoid conflicts
+with existing interfaces).
+
+.. |br| raw:: html
+
+
+
+.. list-table:: Available Redesigned Solvers and Names Registered
+ in the SolverFactories
+ :header-rows: 1
+
+ * - Solver
+ - Name registered in the |br| ``pyomo.contrib.solver.factory.SolverFactory``
+ - Name registered in the |br| ``pyomo.opt.base.solvers.LegacySolverFactory``
+ * - Ipopt
+ - ``ipopt``
+ - ``ipopt_v2``
+ * - Gurobi (persistent)
+ - ``gurobi``
+ - ``gurobi_v2``
+ * - Gurobi (direct)
+ - ``gurobi_direct``
+ - ``gurobi_direct_v2``
+
+Using the new interfaces through the legacy interface
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Here we use the new interface as exposed through the existing (legacy)
+solver factory and solver interface wrapper. This provides an API that
+is compatible with the existing (legacy) Pyomo solver interface and can
+be used with other Pyomo tools / capabilities.
+
+.. testcode::
+ :skipif: not ipopt_available
+
+ import pyomo.environ as pyo
+ from pyomo.contrib.solver.util import assert_optimal_termination
+
+ model = pyo.ConcreteModel()
+ model.x = pyo.Var(initialize=1.5)
+ model.y = pyo.Var(initialize=1.5)
+
+ def rosenbrock(model):
+ return (1.0 - model.x) ** 2 + 100.0 * (model.y - model.x**2) ** 2
+
+ model.obj = pyo.Objective(rule=rosenbrock, sense=pyo.minimize)
+
+ status = pyo.SolverFactory('ipopt_v2').solve(model)
+ assert_optimal_termination(status)
+ model.pprint()
+
+.. testoutput::
+ :skipif: not ipopt_available
+ :hide:
+
+ 2 Var Declarations
+ ...
+ 3 Declarations: x y obj
+
+In keeping with our commitment to backwards compatibility, both the legacy and
+future methods of specifying solver options are supported:
+
+.. testcode::
+ :skipif: not ipopt_available
+
+ import pyomo.environ as pyo
+
+ model = pyo.ConcreteModel()
+ model.x = pyo.Var(initialize=1.5)
+ model.y = pyo.Var(initialize=1.5)
+
+ def rosenbrock(model):
+ return (1.0 - model.x) ** 2 + 100.0 * (model.y - model.x**2) ** 2
+
+ model.obj = pyo.Objective(rule=rosenbrock, sense=pyo.minimize)
+
+ # Backwards compatible
+ status = pyo.SolverFactory('ipopt_v2').solve(model, options={'max_iter' : 6})
+ # Forwards compatible
+ status = pyo.SolverFactory('ipopt_v2').solve(model, solver_options={'max_iter' : 6})
+ model.pprint()
+
+.. testoutput::
+ :skipif: not ipopt_available
+ :hide:
+
+ 2 Var Declarations
+ ...
+ 3 Declarations: x y obj
+
+Using the new interfaces directly
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Here we use the new interface by importing it directly:
+
+.. testcode::
+ :skipif: not ipopt_available
+
+ # Direct import
+ import pyomo.environ as pyo
+ from pyomo.contrib.solver.util import assert_optimal_termination
+ from pyomo.contrib.solver.ipopt import Ipopt
+
+ model = pyo.ConcreteModel()
+ model.x = pyo.Var(initialize=1.5)
+ model.y = pyo.Var(initialize=1.5)
+
+ def rosenbrock(model):
+ return (1.0 - model.x) ** 2 + 100.0 * (model.y - model.x**2) ** 2
+
+ model.obj = pyo.Objective(rule=rosenbrock, sense=pyo.minimize)
+
+ opt = Ipopt()
+ status = opt.solve(model)
+ assert_optimal_termination(status)
+ # Displays important results information; only available through the new interfaces
+ status.display()
+ model.pprint()
+
+.. testoutput::
+ :skipif: not ipopt_available
+ :hide:
+
+ solution_loader: ...
+ ...
+ 3 Declarations: x y obj
+
+Using the new interfaces through the "new" SolverFactory
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Here we use the new interface by retrieving it from the new ``SolverFactory``:
+
+.. testcode::
+ :skipif: not ipopt_available
+
+ # Import through new SolverFactory
+ import pyomo.environ as pyo
+ from pyomo.contrib.solver.util import assert_optimal_termination
+ from pyomo.contrib.solver.factory import SolverFactory
+
+ model = pyo.ConcreteModel()
+ model.x = pyo.Var(initialize=1.5)
+ model.y = pyo.Var(initialize=1.5)
+
+ def rosenbrock(model):
+ return (1.0 - model.x) ** 2 + 100.0 * (model.y - model.x**2) ** 2
+
+ model.obj = pyo.Objective(rule=rosenbrock, sense=pyo.minimize)
+
+ opt = SolverFactory('ipopt')
+ status = opt.solve(model)
+ assert_optimal_termination(status)
+ # Displays important results information; only available through the new interfaces
+ status.display()
+ model.pprint()
+
+.. testoutput::
+ :skipif: not ipopt_available
+ :hide:
+
+ solution_loader: ...
+ ...
+ 3 Declarations: x y obj
+
+Switching all of Pyomo to use the new interfaces
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+We also provide a mechanism to get a "preview" of the future where we
+replace the existing (legacy) SolverFactory and utilities with the new
+(development) version (see :doc:`future`):
+
+.. testcode::
+ :skipif: not ipopt_available
+
+ # Change default SolverFactory version
+ import pyomo.environ as pyo
+ from pyomo.contrib.solver.util import assert_optimal_termination
+ from pyomo.__future__ import solver_factory_v3
+
+ model = pyo.ConcreteModel()
+ model.x = pyo.Var(initialize=1.5)
+ model.y = pyo.Var(initialize=1.5)
+
+ def rosenbrock(model):
+ return (1.0 - model.x) ** 2 + 100.0 * (model.y - model.x**2) ** 2
+
+ model.obj = pyo.Objective(rule=rosenbrock, sense=pyo.minimize)
+
+ status = pyo.SolverFactory('ipopt').solve(model)
+ assert_optimal_termination(status)
+ # Displays important results information; only available through the new interfaces
+ status.display()
+ model.pprint()
+
+.. testoutput::
+ :skipif: not ipopt_available
+ :hide:
+
+ solution_loader: ...
+ ...
+ 3 Declarations: x y obj
+
+.. testcode::
+ :skipif: not ipopt_available
+ :hide:
+
+ from pyomo.__future__ import solver_factory_v1
+
+Linear Presolve and Scaling
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The new interface allows access to new capabilities in the various
+problem writers, including the linear presolve and scaling options
+recently incorporated into the redesigned NL writer. For example, you
+can control the NL writer in the new ``ipopt`` interface through the
+solver's ``writer_config`` configuration option:
+
+.. autoclass:: pyomo.contrib.solver.ipopt.Ipopt
+ :members: solve
+
+.. testcode::
+
+ from pyomo.contrib.solver.ipopt import Ipopt
+ opt = Ipopt()
+ opt.config.writer_config.display()
+
+.. testoutput::
+
+ show_section_timing: false
+ skip_trivial_constraints: true
+ file_determinism: FileDeterminism.ORDERED
+ symbolic_solver_labels: false
+ scale_model: true
+ export_nonlinear_variables: None
+ row_order: None
+ column_order: None
+ export_defined_variables: true
+ linear_presolve: true
+
+Note that, by default, both ``linear_presolve`` and ``scale_model`` are enabled.
+Users can manipulate ``linear_presolve`` and ``scale_model`` to their preferred
+states by changing their values.
+
+.. code-block:: python
+
+ >>> opt.config.writer_config.linear_presolve = False
+
+
+Interface Implementation
+------------------------
+
+All new interfaces should be built upon one of two classes (currently):
+:class:`SolverBase` or
+:class:`PersistentSolverBase`.
+
+All solvers should have the following:
+
+.. autoclass:: pyomo.contrib.solver.base.SolverBase
+ :members:
+
+Persistent solvers include additional members as well as other configuration options:
+
+.. autoclass:: pyomo.contrib.solver.base.PersistentSolverBase
+ :show-inheritance:
+ :members:
+
+Results
+-------
+
+Every solver, at the end of a
+:meth:`solve` call, will
+return a :class:`Results`
+object. This object is a :py:class:`pyomo.common.config.ConfigDict`,
+which can be manipulated similar to a standard ``dict`` in Python.
+
+.. autoclass:: pyomo.contrib.solver.results.Results
+ :show-inheritance:
+ :members:
+ :undoc-members:
+
+
+Termination Conditions
+^^^^^^^^^^^^^^^^^^^^^^
+
+Pyomo offers a standard set of termination conditions to map to solver
+returns. The intent of
+:class:`TerminationCondition`
+is to notify the user of why the solver exited. The user is expected
+to inspect the :class:`Results`
+object or any returned solver messages or logs for more information.
+
+.. autoclass:: pyomo.contrib.solver.results.TerminationCondition
+ :show-inheritance:
+
+
+Solution Status
+^^^^^^^^^^^^^^^
+
+Pyomo offers a standard set of solution statuses to map to solver
+output. The intent of
+:class:`SolutionStatus`
+is to notify the user of what the solver returned at a high level. The
+user is expected to inspect the
+:class:`Results` object or any
+returned solver messages or logs for more information.
+
+.. autoclass:: pyomo.contrib.solver.results.SolutionStatus
+ :show-inheritance:
+
+
+Solution
+--------
+
+Solutions can be loaded back into a model using a ``SolutionLoader``. A specific
+loader should be written for each unique case. Several have already been
+implemented. For example, for ``ipopt``:
+
+.. autoclass:: pyomo.contrib.solver.ipopt.IpoptSolutionLoader
+ :show-inheritance:
+ :members:
+ :inherited-members:
diff --git a/doc/OnlineDocs/installation.rst b/doc/OnlineDocs/installation.rst
index ecba05e13fb..83cd08e7a4a 100644
--- a/doc/OnlineDocs/installation.rst
+++ b/doc/OnlineDocs/installation.rst
@@ -12,7 +12,7 @@ version, Pyomo will remove testing for that Python version.
Using CONDA
~~~~~~~~~~~
-We recommend installation with *conda*, which is included with the
+We recommend installation with ``conda``, which is included with the
Anaconda distribution of Python. You can install Pyomo in your system
Python installation by executing the following in a shell:
@@ -21,7 +21,7 @@ Python installation by executing the following in a shell:
conda install -c conda-forge pyomo
Optimization solvers are not installed with Pyomo, but some open source
-optimization solvers can be installed with conda as well:
+optimization solvers can be installed with ``conda`` as well:
::
@@ -31,7 +31,7 @@ optimization solvers can be installed with conda as well:
Using PIP
~~~~~~~~~
-The standard utility for installing Python packages is *pip*. You
+The standard utility for installing Python packages is ``pip``. You
can install Pyomo in your system Python installation by executing
the following in a shell:
@@ -43,14 +43,14 @@ the following in a shell:
Conditional Dependencies
~~~~~~~~~~~~~~~~~~~~~~~~
-Extensions to Pyomo, and many of the contributions in `pyomo.contrib`,
+Extensions to Pyomo, and many of the contributions in ``pyomo.contrib``,
often have conditional dependencies on a variety of third-party Python
packages including but not limited to: matplotlib, networkx, numpy,
openpyxl, pandas, pint, pymysql, pyodbc, pyro4, scipy, sympy, and
xlrd.
A full list of conditional dependencies can be found in Pyomo's
-`setup.py` and displayed using:
+``setup.py`` and displayed using:
::
@@ -72,3 +72,28 @@ with the standard Anaconda installation.
You can check which Python packages you have installed using the command
``conda list`` or ``pip list``. Additional Python packages may be
installed as needed.
+
+
+Installation with Cython
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Users can opt to install Pyomo with
+`cython `_
+initialized.
+
+.. note::
+ This can only be done via ``pip`` or from source.
+
+Via ``pip``:
+
+::
+
+ pip install pyomo --global-option="--with-cython"
+
+From source (recommended for advanced users only):
+
+::
+
+ git clone https://github.com/Pyomo/pyomo.git
+ cd pyomo
+ python setup.py install --with-cython
diff --git a/doc/OnlineDocs/library_reference/appsi/appsi.solvers.maingo.rst b/doc/OnlineDocs/library_reference/appsi/appsi.solvers.maingo.rst
new file mode 100644
index 00000000000..21e61c38d51
--- /dev/null
+++ b/doc/OnlineDocs/library_reference/appsi/appsi.solvers.maingo.rst
@@ -0,0 +1,14 @@
+MAiNGO
+======
+
+.. autoclass:: pyomo.contrib.appsi.solvers.maingo.MAiNGOConfig
+ :members:
+ :inherited-members:
+ :undoc-members:
+ :show-inheritance:
+
+.. autoclass:: pyomo.contrib.appsi.solvers.maingo.MAiNGO
+ :members:
+ :inherited-members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/doc/OnlineDocs/library_reference/appsi/appsi.solvers.rst b/doc/OnlineDocs/library_reference/appsi/appsi.solvers.rst
index 1c598d95628..f4dcb81b4be 100644
--- a/doc/OnlineDocs/library_reference/appsi/appsi.solvers.rst
+++ b/doc/OnlineDocs/library_reference/appsi/appsi.solvers.rst
@@ -13,3 +13,4 @@ Solvers
appsi.solvers.cplex
appsi.solvers.cbc
appsi.solvers.highs
+ appsi.solvers.maingo
diff --git a/doc/OnlineDocs/library_reference/common/config.rst b/doc/OnlineDocs/library_reference/common/config.rst
index 7a400b26ce3..c5dc607977a 100644
--- a/doc/OnlineDocs/library_reference/common/config.rst
+++ b/doc/OnlineDocs/library_reference/common/config.rst
@@ -36,6 +36,7 @@ Domain validators
NonPositiveFloat
NonNegativeFloat
In
+ IsInstance
InEnum
ListOf
Module
@@ -75,6 +76,7 @@ Domain validators
.. autofunction:: NonPositiveFloat
.. autofunction:: NonNegativeFloat
.. autoclass:: In
+.. autoclass:: IsInstance
.. autoclass:: InEnum
.. autoclass:: ListOf
.. autoclass:: Module
diff --git a/doc/OnlineDocs/library_reference/common/enums.rst b/doc/OnlineDocs/library_reference/common/enums.rst
new file mode 100644
index 00000000000..5ed2dbb1e80
--- /dev/null
+++ b/doc/OnlineDocs/library_reference/common/enums.rst
@@ -0,0 +1,7 @@
+
+pyomo.common.enums
+==================
+
+.. automodule:: pyomo.common.enums
+ :members:
+ :member-order: bysource
diff --git a/doc/OnlineDocs/library_reference/common/index.rst b/doc/OnlineDocs/library_reference/common/index.rst
index c9c99008250..c03436600f2 100644
--- a/doc/OnlineDocs/library_reference/common/index.rst
+++ b/doc/OnlineDocs/library_reference/common/index.rst
@@ -11,6 +11,7 @@ or rely on any other parts of Pyomo.
config.rst
dependencies.rst
deprecation.rst
+ enums.rst
errors.rst
fileutils.rst
formatting.rst
diff --git a/doc/OnlineDocs/library_reference/expressions/context_managers.rst b/doc/OnlineDocs/library_reference/expressions/context_managers.rst
index 0e92f583c73..ae6884d684f 100644
--- a/doc/OnlineDocs/library_reference/expressions/context_managers.rst
+++ b/doc/OnlineDocs/library_reference/expressions/context_managers.rst
@@ -8,6 +8,3 @@ Context Managers
.. autoclass:: pyomo.core.expr.linear_expression
:members:
-.. autoclass:: pyomo.core.expr.current.clone_counter
- :members:
-
diff --git a/doc/OnlineDocs/library_reference/kernel/examples/aml_example.py b/doc/OnlineDocs/library_reference/kernel/examples/aml_example.py
index 146048a6046..a640b94cc76 100644
--- a/doc/OnlineDocs/library_reference/kernel/examples/aml_example.py
+++ b/doc/OnlineDocs/library_reference/kernel/examples/aml_example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# @Import_Syntax
import pyomo.environ as aml
diff --git a/doc/OnlineDocs/library_reference/kernel/examples/conic.py b/doc/OnlineDocs/library_reference/kernel/examples/conic.py
index 9282bc67f9a..0418d188722 100644
--- a/doc/OnlineDocs/library_reference/kernel/examples/conic.py
+++ b/doc/OnlineDocs/library_reference/kernel/examples/conic.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# @Class
import pyomo.kernel as pmo
diff --git a/doc/OnlineDocs/library_reference/kernel/examples/kernel_containers.py b/doc/OnlineDocs/library_reference/kernel/examples/kernel_containers.py
index f2a4ec25ac5..1931c6d9b56 100644
--- a/doc/OnlineDocs/library_reference/kernel/examples/kernel_containers.py
+++ b/doc/OnlineDocs/library_reference/kernel/examples/kernel_containers.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel
# @all
diff --git a/doc/OnlineDocs/library_reference/kernel/examples/kernel_example.py b/doc/OnlineDocs/library_reference/kernel/examples/kernel_example.py
index 1caf064bb2a..1f80bce9788 100644
--- a/doc/OnlineDocs/library_reference/kernel/examples/kernel_example.py
+++ b/doc/OnlineDocs/library_reference/kernel/examples/kernel_example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# @Import_Syntax
import pyomo.kernel as pmo
diff --git a/doc/OnlineDocs/library_reference/kernel/examples/kernel_solving.py b/doc/OnlineDocs/library_reference/kernel/examples/kernel_solving.py
index 5a8eed9fd89..13d7efc052a 100644
--- a/doc/OnlineDocs/library_reference/kernel/examples/kernel_solving.py
+++ b/doc/OnlineDocs/library_reference/kernel/examples/kernel_solving.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
model = pmo.block()
diff --git a/doc/OnlineDocs/library_reference/kernel/examples/kernel_subclassing.py b/doc/OnlineDocs/library_reference/kernel/examples/kernel_subclassing.py
index c21c6dc890b..d6e38f6b0e0 100644
--- a/doc/OnlineDocs/library_reference/kernel/examples/kernel_subclassing.py
+++ b/doc/OnlineDocs/library_reference/kernel/examples/kernel_subclassing.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel
diff --git a/doc/OnlineDocs/library_reference/kernel/examples/transformer.py b/doc/OnlineDocs/library_reference/kernel/examples/transformer.py
index 66893008cf9..43a1d0675bf 100644
--- a/doc/OnlineDocs/library_reference/kernel/examples/transformer.py
+++ b/doc/OnlineDocs/library_reference/kernel/examples/transformer.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ
import pyomo.kernel
diff --git a/doc/OnlineDocs/modeling_extensions/__init__.py b/doc/OnlineDocs/modeling_extensions/__init__.py
index e69de29bb2d..a4a626013c4 100644
--- a/doc/OnlineDocs/modeling_extensions/__init__.py
+++ b/doc/OnlineDocs/modeling_extensions/__init__.py
@@ -0,0 +1,10 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
diff --git a/doc/OnlineDocs/modeling_extensions/dae.rst b/doc/OnlineDocs/modeling_extensions/dae.rst
index 703e83f4f14..ff0fb75e610 100644
--- a/doc/OnlineDocs/modeling_extensions/dae.rst
+++ b/doc/OnlineDocs/modeling_extensions/dae.rst
@@ -738,7 +738,7 @@ supported by CasADi. A list of available integrators for each package is
given below. Please refer to the `SciPy
`_
and `CasADi
-`_ documentation directly for the most up-to-date information about
+`_ documentation directly for the most up-to-date information about
these packages and for more information about the various integrators and
options.
diff --git a/doc/OnlineDocs/modeling_extensions/gdp/modeling.rst b/doc/OnlineDocs/modeling_extensions/gdp/modeling.rst
index b70e37d5935..996ebcb0366 100644
--- a/doc/OnlineDocs/modeling_extensions/gdp/modeling.rst
+++ b/doc/OnlineDocs/modeling_extensions/gdp/modeling.rst
@@ -166,7 +166,7 @@ Usage:
>>> TransformationFactory('core.logical_to_linear').apply_to(m)
>>> # constraint auto-generated by transformation
>>> m.logic_to_linear.transformed_constraints.pprint()
- transformed_constraints : Size=1, Index=logic_to_linear.transformed_constraints_index, Active=True
+ transformed_constraints : Size=1, Index={1}, Active=True
Key : Lower : Body : Upper : Active
1 : 3.0 : Y_asbinary[1] + Y_asbinary[2] + Y_asbinary[3] + Y_asbinary[4] : +Inf : True
diff --git a/doc/OnlineDocs/modeling_extensions/gdp/solving.rst b/doc/OnlineDocs/modeling_extensions/gdp/solving.rst
index 2f3076862e6..9fea90ebf5f 100644
--- a/doc/OnlineDocs/modeling_extensions/gdp/solving.rst
+++ b/doc/OnlineDocs/modeling_extensions/gdp/solving.rst
@@ -140,6 +140,10 @@ For example, to apply the transformation and store the M values, use:
From the Pyomo command line, include the ``--transform pyomo.gdp.mbigm`` option.
+.. warning::
+ The Multiple Big-M transformation does not currently support Suffixes and will
+ ignore "BigM" Suffixes.
+
Hull Reformulation (HR)
^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/doc/OnlineDocs/src/data/ABCD1.py b/doc/OnlineDocs/src/data/ABCD1.py
index 32600b226e1..aa2f46e71fa 100644
--- a/doc/OnlineDocs/src/data/ABCD1.py
+++ b/doc/OnlineDocs/src/data/ABCD1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/ABCD2.py b/doc/OnlineDocs/src/data/ABCD2.py
index 65a46415368..ec0e7ccb15c 100644
--- a/doc/OnlineDocs/src/data/ABCD2.py
+++ b/doc/OnlineDocs/src/data/ABCD2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/ABCD3.py b/doc/OnlineDocs/src/data/ABCD3.py
index 48797ced5bb..ba55fd970cc 100644
--- a/doc/OnlineDocs/src/data/ABCD3.py
+++ b/doc/OnlineDocs/src/data/ABCD3.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/ABCD4.py b/doc/OnlineDocs/src/data/ABCD4.py
index 20f6a21c011..2fb397aa3b0 100644
--- a/doc/OnlineDocs/src/data/ABCD4.py
+++ b/doc/OnlineDocs/src/data/ABCD4.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/ABCD5.py b/doc/OnlineDocs/src/data/ABCD5.py
index 58461af056b..abc03505e96 100644
--- a/doc/OnlineDocs/src/data/ABCD5.py
+++ b/doc/OnlineDocs/src/data/ABCD5.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/ABCD6.py b/doc/OnlineDocs/src/data/ABCD6.py
index 961408dbc7e..59e0e8e98ae 100644
--- a/doc/OnlineDocs/src/data/ABCD6.py
+++ b/doc/OnlineDocs/src/data/ABCD6.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/ABCD7.py b/doc/OnlineDocs/src/data/ABCD7.py
index a97e764fa5a..1bfb4d1e3fb 100644
--- a/doc/OnlineDocs/src/data/ABCD7.py
+++ b/doc/OnlineDocs/src/data/ABCD7.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
import pyomo.common
import sys
diff --git a/doc/OnlineDocs/src/data/ABCD8.py b/doc/OnlineDocs/src/data/ABCD8.py
index 9bcd950c681..aa1ba0b4cf5 100644
--- a/doc/OnlineDocs/src/data/ABCD8.py
+++ b/doc/OnlineDocs/src/data/ABCD8.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
import pyomo.common
import sys
diff --git a/doc/OnlineDocs/src/data/ABCD9.py b/doc/OnlineDocs/src/data/ABCD9.py
index 29fcb6426db..194c71486d9 100644
--- a/doc/OnlineDocs/src/data/ABCD9.py
+++ b/doc/OnlineDocs/src/data/ABCD9.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
import pyomo.common
import sys
diff --git a/doc/OnlineDocs/src/data/diet1.py b/doc/OnlineDocs/src/data/diet1.py
index ef0d8096350..40582e16ba0 100644
--- a/doc/OnlineDocs/src/data/diet1.py
+++ b/doc/OnlineDocs/src/data/diet1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# diet1.py
from pyomo.environ import *
diff --git a/doc/OnlineDocs/src/data/ex.py b/doc/OnlineDocs/src/data/ex.py
index 8c9473f2852..a66ee30b494 100644
--- a/doc/OnlineDocs/src/data/ex.py
+++ b/doc/OnlineDocs/src/data/ex.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/import1.tab.py b/doc/OnlineDocs/src/data/import1.tab.py
index c9164ab73ec..e160e4fdcde 100644
--- a/doc/OnlineDocs/src/data/import1.tab.py
+++ b/doc/OnlineDocs/src/data/import1.tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/import2.tab.py b/doc/OnlineDocs/src/data/import2.tab.py
index d03f053d090..54339551279 100644
--- a/doc/OnlineDocs/src/data/import2.tab.py
+++ b/doc/OnlineDocs/src/data/import2.tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/import3.tab.py b/doc/OnlineDocs/src/data/import3.tab.py
index e86557677ee..664151d1438 100644
--- a/doc/OnlineDocs/src/data/import3.tab.py
+++ b/doc/OnlineDocs/src/data/import3.tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/import4.tab.py b/doc/OnlineDocs/src/data/import4.tab.py
index 93df9c761ab..91dd3f26a42 100644
--- a/doc/OnlineDocs/src/data/import4.tab.py
+++ b/doc/OnlineDocs/src/data/import4.tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/import5.tab.py b/doc/OnlineDocs/src/data/import5.tab.py
index 1d20476a16f..263677c308c 100644
--- a/doc/OnlineDocs/src/data/import5.tab.py
+++ b/doc/OnlineDocs/src/data/import5.tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/import6.tab.py b/doc/OnlineDocs/src/data/import6.tab.py
index 8a1ab232f86..8f4824ad3fe 100644
--- a/doc/OnlineDocs/src/data/import6.tab.py
+++ b/doc/OnlineDocs/src/data/import6.tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/import7.tab.py b/doc/OnlineDocs/src/data/import7.tab.py
index 747d884be31..503f9224323 100644
--- a/doc/OnlineDocs/src/data/import7.tab.py
+++ b/doc/OnlineDocs/src/data/import7.tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/import8.tab.py b/doc/OnlineDocs/src/data/import8.tab.py
index b7866d7a3e5..02b8724fe45 100644
--- a/doc/OnlineDocs/src/data/import8.tab.py
+++ b/doc/OnlineDocs/src/data/import8.tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param1.py b/doc/OnlineDocs/src/data/param1.py
index c4bc8de5acc..336a04287b9 100644
--- a/doc/OnlineDocs/src/data/param1.py
+++ b/doc/OnlineDocs/src/data/param1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param2.py b/doc/OnlineDocs/src/data/param2.py
index f46f05ceebc..a7d0feafff9 100644
--- a/doc/OnlineDocs/src/data/param2.py
+++ b/doc/OnlineDocs/src/data/param2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param2a.py b/doc/OnlineDocs/src/data/param2a.py
index 4557f63d841..42056793ffd 100644
--- a/doc/OnlineDocs/src/data/param2a.py
+++ b/doc/OnlineDocs/src/data/param2a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param3.py b/doc/OnlineDocs/src/data/param3.py
index 149155ce67d..952f9a9b707 100644
--- a/doc/OnlineDocs/src/data/param3.py
+++ b/doc/OnlineDocs/src/data/param3.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param3a.py b/doc/OnlineDocs/src/data/param3a.py
index 0e99cad0c7a..028e1d07296 100644
--- a/doc/OnlineDocs/src/data/param3a.py
+++ b/doc/OnlineDocs/src/data/param3a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param3b.py b/doc/OnlineDocs/src/data/param3b.py
index deda175ea12..97f8598610a 100644
--- a/doc/OnlineDocs/src/data/param3b.py
+++ b/doc/OnlineDocs/src/data/param3b.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param3c.py b/doc/OnlineDocs/src/data/param3c.py
index 4056dc8107d..582b0f7db75 100644
--- a/doc/OnlineDocs/src/data/param3c.py
+++ b/doc/OnlineDocs/src/data/param3c.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param4.py b/doc/OnlineDocs/src/data/param4.py
index 1190dae8dec..010c46fc9c5 100644
--- a/doc/OnlineDocs/src/data/param4.py
+++ b/doc/OnlineDocs/src/data/param4.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param5.py b/doc/OnlineDocs/src/data/param5.py
index 69f6cc46552..2db07f3f990 100644
--- a/doc/OnlineDocs/src/data/param5.py
+++ b/doc/OnlineDocs/src/data/param5.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param5a.py b/doc/OnlineDocs/src/data/param5a.py
index 303b92f9f2e..32a53d24e9b 100644
--- a/doc/OnlineDocs/src/data/param5a.py
+++ b/doc/OnlineDocs/src/data/param5a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param6.py b/doc/OnlineDocs/src/data/param6.py
index c3e4b25d144..e3364a933cf 100644
--- a/doc/OnlineDocs/src/data/param6.py
+++ b/doc/OnlineDocs/src/data/param6.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param6a.py b/doc/OnlineDocs/src/data/param6a.py
index 07e8280cc18..3d2fa645411 100644
--- a/doc/OnlineDocs/src/data/param6a.py
+++ b/doc/OnlineDocs/src/data/param6a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param7a.py b/doc/OnlineDocs/src/data/param7a.py
index 3bb68b3f3b7..b3aba9ec23d 100644
--- a/doc/OnlineDocs/src/data/param7a.py
+++ b/doc/OnlineDocs/src/data/param7a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param7b.py b/doc/OnlineDocs/src/data/param7b.py
index 6e5c857851f..8b022f399a8 100644
--- a/doc/OnlineDocs/src/data/param7b.py
+++ b/doc/OnlineDocs/src/data/param7b.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/param8a.py b/doc/OnlineDocs/src/data/param8a.py
index 57c9b08ca43..abfa885ded4 100644
--- a/doc/OnlineDocs/src/data/param8a.py
+++ b/doc/OnlineDocs/src/data/param8a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/set1.py b/doc/OnlineDocs/src/data/set1.py
index 5248e9d5dc9..c84c1ef0819 100644
--- a/doc/OnlineDocs/src/data/set1.py
+++ b/doc/OnlineDocs/src/data/set1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/set2.py b/doc/OnlineDocs/src/data/set2.py
index 82772f48e46..9048a49fecb 100644
--- a/doc/OnlineDocs/src/data/set2.py
+++ b/doc/OnlineDocs/src/data/set2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/set2a.py b/doc/OnlineDocs/src/data/set2a.py
index edf28757f96..f2fa4d71916 100644
--- a/doc/OnlineDocs/src/data/set2a.py
+++ b/doc/OnlineDocs/src/data/set2a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/set3.py b/doc/OnlineDocs/src/data/set3.py
index d58e0c0dd43..9cdacbe39e0 100644
--- a/doc/OnlineDocs/src/data/set3.py
+++ b/doc/OnlineDocs/src/data/set3.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/set4.py b/doc/OnlineDocs/src/data/set4.py
index 29548519571..b3485638c6f 100644
--- a/doc/OnlineDocs/src/data/set4.py
+++ b/doc/OnlineDocs/src/data/set4.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/set5.py b/doc/OnlineDocs/src/data/set5.py
index 35acd4e4317..d745d8408d0 100644
--- a/doc/OnlineDocs/src/data/set5.py
+++ b/doc/OnlineDocs/src/data/set5.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table0.py b/doc/OnlineDocs/src/data/table0.py
index af7f634bd34..de0fae0c861 100644
--- a/doc/OnlineDocs/src/data/table0.py
+++ b/doc/OnlineDocs/src/data/table0.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table0.ul.py b/doc/OnlineDocs/src/data/table0.ul.py
index 213407b071c..524c3756782 100644
--- a/doc/OnlineDocs/src/data/table0.ul.py
+++ b/doc/OnlineDocs/src/data/table0.ul.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table1.py b/doc/OnlineDocs/src/data/table1.py
index 1f86508c60a..f36714b8f1f 100644
--- a/doc/OnlineDocs/src/data/table1.py
+++ b/doc/OnlineDocs/src/data/table1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table2.py b/doc/OnlineDocs/src/data/table2.py
index d7708b9277f..03648a00f8c 100644
--- a/doc/OnlineDocs/src/data/table2.py
+++ b/doc/OnlineDocs/src/data/table2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table2.txt b/doc/OnlineDocs/src/data/table2.txt
index 60eb55aab4a..a710b6b6042 100644
--- a/doc/OnlineDocs/src/data/table2.txt
+++ b/doc/OnlineDocs/src/data/table2.txt
@@ -1,13 +1,10 @@
-3 Set Declarations
+2 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'B1', 'B2', 'B3'}
- N_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 'B1'), ('A1', 'B2'), ('A1', 'B3'), ('A2', 'B1'), ('A2', 'B2'), ('A2', 'B3'), ('A3', 'B1'), ('A3', 'B2'), ('A3', 'B3')}
2 Param Declarations
M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
@@ -15,10 +12,10 @@
A1 : 4.3
A2 : 4.4
A3 : 4.5
- N : Size=3, Index=N_index, Domain=Any, Default=None, Mutable=False
+ N : Size=3, Index=A*B, Domain=Any, Default=None, Mutable=False
Key : Value
('A1', 'B1') : 5.3
('A2', 'B2') : 5.4
('A3', 'B3') : 5.5
-5 Declarations: A B M N_index N
+4 Declarations: A B M N
diff --git a/doc/OnlineDocs/src/data/table3.py b/doc/OnlineDocs/src/data/table3.py
index fa871a4f79c..2c598f112df 100644
--- a/doc/OnlineDocs/src/data/table3.py
+++ b/doc/OnlineDocs/src/data/table3.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table3.txt b/doc/OnlineDocs/src/data/table3.txt
index cb5e63b30d4..c0c61cd5a5b 100644
--- a/doc/OnlineDocs/src/data/table3.txt
+++ b/doc/OnlineDocs/src/data/table3.txt
@@ -1,13 +1,10 @@
-4 Set Declarations
+3 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'B1', 'B2', 'B3'}
- N_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 'B1'), ('A1', 'B2'), ('A1', 'B3'), ('A2', 'B1'), ('A2', 'B2'), ('A2', 'B3'), ('A3', 'B1'), ('A3', 'B2'), ('A3', 'B3')}
Z : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
@@ -18,10 +15,10 @@
A1 : 4.3
A2 : 4.4
A3 : 4.5
- N : Size=3, Index=N_index, Domain=Any, Default=None, Mutable=False
+ N : Size=3, Index=A*B, Domain=Any, Default=None, Mutable=False
Key : Value
('A1', 'B1') : 5.3
('A2', 'B2') : 5.4
('A3', 'B3') : 5.5
-6 Declarations: A B Z M N_index N
+5 Declarations: A B Z M N
diff --git a/doc/OnlineDocs/src/data/table3.ul.py b/doc/OnlineDocs/src/data/table3.ul.py
index 713d36b9f3a..18ced12b388 100644
--- a/doc/OnlineDocs/src/data/table3.ul.py
+++ b/doc/OnlineDocs/src/data/table3.ul.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table3.ul.txt b/doc/OnlineDocs/src/data/table3.ul.txt
index cb5e63b30d4..c0c61cd5a5b 100644
--- a/doc/OnlineDocs/src/data/table3.ul.txt
+++ b/doc/OnlineDocs/src/data/table3.ul.txt
@@ -1,13 +1,10 @@
-4 Set Declarations
+3 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'B1', 'B2', 'B3'}
- N_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 'B1'), ('A1', 'B2'), ('A1', 'B3'), ('A2', 'B1'), ('A2', 'B2'), ('A2', 'B3'), ('A3', 'B1'), ('A3', 'B2'), ('A3', 'B3')}
Z : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
@@ -18,10 +15,10 @@
A1 : 4.3
A2 : 4.4
A3 : 4.5
- N : Size=3, Index=N_index, Domain=Any, Default=None, Mutable=False
+ N : Size=3, Index=A*B, Domain=Any, Default=None, Mutable=False
Key : Value
('A1', 'B1') : 5.3
('A2', 'B2') : 5.4
('A3', 'B3') : 5.5
-6 Declarations: A B Z M N_index N
+5 Declarations: A B Z M N
diff --git a/doc/OnlineDocs/src/data/table4.py b/doc/OnlineDocs/src/data/table4.py
index 1af9fe47a44..bd20682b5a9 100644
--- a/doc/OnlineDocs/src/data/table4.py
+++ b/doc/OnlineDocs/src/data/table4.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table4.ul.py b/doc/OnlineDocs/src/data/table4.ul.py
index 2acf8e21ca8..9f16f21fe19 100644
--- a/doc/OnlineDocs/src/data/table4.ul.py
+++ b/doc/OnlineDocs/src/data/table4.ul.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table5.py b/doc/OnlineDocs/src/data/table5.py
index 2fe3d08fe91..a3cb01209a2 100644
--- a/doc/OnlineDocs/src/data/table5.py
+++ b/doc/OnlineDocs/src/data/table5.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table6.py b/doc/OnlineDocs/src/data/table6.py
index fcbc2f10860..1db0a764a23 100644
--- a/doc/OnlineDocs/src/data/table6.py
+++ b/doc/OnlineDocs/src/data/table6.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/data/table7.py b/doc/OnlineDocs/src/data/table7.py
index f8f8e769b2e..84a841aca86 100644
--- a/doc/OnlineDocs/src/data/table7.py
+++ b/doc/OnlineDocs/src/data/table7.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/dataportal/PP_sqlite.py b/doc/OnlineDocs/src/dataportal/PP_sqlite.py
index 9c6fc5ddc0b..1592e820900 100644
--- a/doc/OnlineDocs/src/dataportal/PP_sqlite.py
+++ b/doc/OnlineDocs/src/dataportal/PP_sqlite.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/doc/OnlineDocs/src/dataportal/dataportal_tab.py b/doc/OnlineDocs/src/dataportal/dataportal_tab.py
index d1a75196c99..655329d31de 100644
--- a/doc/OnlineDocs/src/dataportal/dataportal_tab.py
+++ b/doc/OnlineDocs/src/dataportal/dataportal_tab.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
# --------------------------------------------------
diff --git a/doc/OnlineDocs/src/dataportal/dataportal_tab.txt b/doc/OnlineDocs/src/dataportal/dataportal_tab.txt
index 2e507971157..a23c63d90c9 100644
--- a/doc/OnlineDocs/src/dataportal/dataportal_tab.txt
+++ b/doc/OnlineDocs/src/dataportal/dataportal_tab.txt
@@ -85,19 +85,16 @@
A3 : 4.5
2 Declarations: A w
-3 Set Declarations
+2 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
I : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 4 : {'I1', 'I2', 'I3', 'I4'}
- u_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : I*A : 12 : {('I1', 'A1'), ('I1', 'A2'), ('I1', 'A3'), ('I2', 'A1'), ('I2', 'A2'), ('I2', 'A3'), ('I3', 'A1'), ('I3', 'A2'), ('I3', 'A3'), ('I4', 'A1'), ('I4', 'A2'), ('I4', 'A3')}
1 Param Declarations
- u : Size=12, Index=u_index, Domain=Any, Default=None, Mutable=False
+ u : Size=12, Index=I*A, Domain=Any, Default=None, Mutable=False
Key : Value
('I1', 'A1') : 1.3
('I1', 'A2') : 2.3
@@ -112,20 +109,17 @@
('I4', 'A2') : 2.6
('I4', 'A3') : 3.6
-4 Declarations: A I u_index u
-3 Set Declarations
+3 Declarations: A I u
+2 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
I : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 4 : {'I1', 'I2', 'I3', 'I4'}
- t_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*I : 12 : {('A1', 'I1'), ('A1', 'I2'), ('A1', 'I3'), ('A1', 'I4'), ('A2', 'I1'), ('A2', 'I2'), ('A2', 'I3'), ('A2', 'I4'), ('A3', 'I1'), ('A3', 'I2'), ('A3', 'I3'), ('A3', 'I4')}
1 Param Declarations
- t : Size=12, Index=t_index, Domain=Any, Default=None, Mutable=False
+ t : Size=12, Index=A*I, Domain=Any, Default=None, Mutable=False
Key : Value
('A1', 'I1') : 1.3
('A1', 'I2') : 1.4
@@ -140,7 +134,7 @@
('A3', 'I3') : 3.5
('A3', 'I4') : 3.6
-4 Declarations: A I t_index t
+3 Declarations: A I t
1 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
@@ -185,13 +179,9 @@
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
1 Declarations: A
-1 Set Declarations
- y_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
2 Param Declarations
- y : Size=3, Index=y_index, Domain=Any, Default=None, Mutable=False
+ y : Size=3, Index={A1, A2, A3}, Domain=Any, Default=None, Mutable=False
Key : Value
A1 : 3.3
A2 : 3.4
@@ -200,7 +190,7 @@
Key : Value
None : 1.1
-3 Declarations: z y_index y
+2 Declarations: z y
['A1', 'A2', 'A3']
1.1
A1 3.3
diff --git a/doc/OnlineDocs/src/dataportal/param_initialization.py b/doc/OnlineDocs/src/dataportal/param_initialization.py
index 5567b01f284..7f9270b5fda 100644
--- a/doc/OnlineDocs/src/dataportal/param_initialization.py
+++ b/doc/OnlineDocs/src/dataportal/param_initialization.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
import numpy
diff --git a/doc/OnlineDocs/src/dataportal/param_initialization.txt b/doc/OnlineDocs/src/dataportal/param_initialization.txt
index fec8a06a84a..49ea105f120 100644
--- a/doc/OnlineDocs/src/dataportal/param_initialization.txt
+++ b/doc/OnlineDocs/src/dataportal/param_initialization.txt
@@ -1,24 +1,16 @@
-2 Set Declarations
- b_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
- c_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
-
3 Param Declarations
a : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
Key : Value
None : 1.1
- b : Size=3, Index=b_index, Domain=Any, Default=None, Mutable=False
+ b : Size=3, Index={1, 2, 3}, Domain=Any, Default=None, Mutable=False
Key : Value
1 : 1
2 : 2
3 : 3
- c : Size=3, Index=c_index, Domain=Any, Default=None, Mutable=False
+ c : Size=3, Index={1, 2, 3}, Domain=Any, Default=None, Mutable=False
Key : Value
1 : 1
2 : 2
3 : 3
-5 Declarations: a b_index b c_index c
+3 Declarations: a b c
diff --git a/doc/OnlineDocs/src/dataportal/set_initialization.py b/doc/OnlineDocs/src/dataportal/set_initialization.py
index aa7b426fa82..a5ab03894e3 100644
--- a/doc/OnlineDocs/src/dataportal/set_initialization.py
+++ b/doc/OnlineDocs/src/dataportal/set_initialization.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
import numpy
diff --git a/doc/OnlineDocs/src/dataportal/set_initialization.txt b/doc/OnlineDocs/src/dataportal/set_initialization.txt
index c6be448eba9..3c2960ce4ef 100644
--- a/doc/OnlineDocs/src/dataportal/set_initialization.txt
+++ b/doc/OnlineDocs/src/dataportal/set_initialization.txt
@@ -1,6 +1,6 @@
WARNING: Initializing ordered Set B with a fundamentally unordered data source
(type: set). This WILL potentially lead to nondeterministic behavior in Pyomo
-9 Set Declarations
+8 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {2, 3, 5}
@@ -22,13 +22,10 @@ WARNING: Initializing ordered Set B with a fundamentally unordered data source
G : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {2, 3, 5}
- H : Size=3, Index=H_index, Ordered=Insertion
+ H : Size=3, Index={2, 3, 4}, Ordered=Insertion
Key : Dimen : Domain : Size : Members
2 : 1 : Any : 3 : {1, 3, 5}
3 : 1 : Any : 3 : {2, 4, 6}
4 : 1 : Any : 3 : {3, 5, 7}
- H_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {2, 3, 4}
-9 Declarations: A B C D E F G H_index H
+8 Declarations: A B C D E F G H
diff --git a/doc/OnlineDocs/src/expr/design.py b/doc/OnlineDocs/src/expr/design.py
index b122a5f2bf3..647a4537ca4 100644
--- a/doc/OnlineDocs/src/expr/design.py
+++ b/doc/OnlineDocs/src/expr/design.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
# ---------------------------------------------
diff --git a/doc/OnlineDocs/src/expr/index.py b/doc/OnlineDocs/src/expr/index.py
index 9c9c79bf7be..fe5b03461c0 100644
--- a/doc/OnlineDocs/src/expr/index.py
+++ b/doc/OnlineDocs/src/expr/index.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
# ---------------------------------------------
diff --git a/doc/OnlineDocs/src/expr/managing.py b/doc/OnlineDocs/src/expr/managing.py
index 0a59c13bc1b..ff149e4fd5c 100644
--- a/doc/OnlineDocs/src/expr/managing.py
+++ b/doc/OnlineDocs/src/expr/managing.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
from math import isclose
import math
@@ -170,7 +181,7 @@ def clone_expression(expr):
# x[0] + 5*x[1]
print(str(ce))
# x[0] + 5*x[1]
-print(e.arg(0) is not ce.arg(0))
+print(e.arg(0) is ce.arg(0))
# True
print(e.arg(1) is not ce.arg(1))
# True
diff --git a/doc/OnlineDocs/src/expr/overview.py b/doc/OnlineDocs/src/expr/overview.py
index 6207a4c4288..d33725edb88 100644
--- a/doc/OnlineDocs/src/expr/overview.py
+++ b/doc/OnlineDocs/src/expr/overview.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
# ---------------------------------------------
diff --git a/doc/OnlineDocs/src/expr/performance.py b/doc/OnlineDocs/src/expr/performance.py
index 53ac5bb4f9e..8936bd2ed8c 100644
--- a/doc/OnlineDocs/src/expr/performance.py
+++ b/doc/OnlineDocs/src/expr/performance.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
# ---------------------------------------------
diff --git a/doc/OnlineDocs/src/expr/quicksum.py b/doc/OnlineDocs/src/expr/quicksum.py
index a1ad9660664..1b6cd3f9909 100644
--- a/doc/OnlineDocs/src/expr/quicksum.py
+++ b/doc/OnlineDocs/src/expr/quicksum.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
from pyomo.repn import generate_standard_repn
import time
diff --git a/doc/OnlineDocs/src/kernel/examples.txt b/doc/OnlineDocs/src/kernel/examples.txt
index e85c64efd86..8ba072d28b1 100644
--- a/doc/OnlineDocs/src/kernel/examples.txt
+++ b/doc/OnlineDocs/src/kernel/examples.txt
@@ -1,22 +1,7 @@
-6 Set Declarations
- cd_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : s*q : 6 : {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)}
- cl_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
- ol_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
+1 Set Declarations
s : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 2 : {1, 2}
- sd_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {1, 2}
- vl_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
1 RangeSet Declarations
q : Dimen=1, Size=3, Bounds=(1, 3)
@@ -43,7 +28,7 @@
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : None : None : 9 : False : True : Reals
2 : None : None : 9 : False : True : Reals
- vl : Size=3, Index=vl_index
+ vl : Size=3, Index={1, 2, 3}
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : 1 : None : None : False : True : Reals
2 : 2 : None : None : False : True : Reals
@@ -66,7 +51,7 @@
Key : Active : Sense : Expression
1 : True : minimize : - vd[1]
2 : True : minimize : - vd[2]
- ol : Size=3, Index=ol_index, Active=True
+ ol : Size=3, Index={1, 2, 3}, Active=True
Key : Active : Sense : Expression
1 : True : minimize : - vl[1]
2 : True : minimize : - vl[2]
@@ -76,7 +61,7 @@
c : Size=1, Index=None, Active=True
Key : Lower : Body : Upper : Active
None : -Inf : vd[1] + vd[2] : 9.0 : True
- cd : Size=6, Index=cd_index, Active=True
+ cd : Size=6, Index=s*q, Active=True
Key : Lower : Body : Upper : Active
(1, 1) : 1.0 : vd[1] : 1.0 : True
(1, 2) : 2.0 : vd[1] : 2.0 : True
@@ -84,14 +69,14 @@
(2, 1) : 1.0 : vd[2] : 1.0 : True
(2, 2) : 2.0 : vd[2] : 2.0 : True
(2, 3) : 3.0 : vd[2] : 3.0 : True
- cl : Size=3, Index=cl_index, Active=True
+ cl : Size=3, Index={1, 2, 3}, Active=True
Key : Lower : Body : Upper : Active
1 : -5.0 : vl[1] - v : 5.0 : True
2 : -5.0 : vl[2] - v : 5.0 : True
3 : -5.0 : vl[3] - v : 5.0 : True
3 SOSConstraint Declarations
- sd : Size=2 Index= sd_index
+ sd : Size=2 Index= OrderedScalarSet
1
Type=1
Weight : Variable
@@ -119,16 +104,8 @@
b : Size=1, Index=None, Active=True
0 Declarations:
pw : Size=1, Index=None, Active=True
- 2 Set Declarations
- SOS2_constraint_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
- SOS2_y_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 4 : {0, 1, 2, 3}
-
1 Var Declarations
- SOS2_y : Size=4, Index=pw.SOS2_y_index
+ SOS2_y : Size=4, Index={0, 1, 2, 3}
Key : Lower : Value : Upper : Fixed : Stale : Domain
0 : 0 : None : None : False : True : NonNegativeReals
1 : 0 : None : None : False : True : NonNegativeReals
@@ -136,7 +113,7 @@
3 : 0 : None : None : False : True : NonNegativeReals
1 Constraint Declarations
- SOS2_constraint : Size=3, Index=pw.SOS2_constraint_index, Active=True
+ SOS2_constraint : Size=3, Index={1, 2, 3}, Active=True
Key : Lower : Body : Upper : Active
1 : 0.0 : v - (pw.SOS2_y[0] + 2*pw.SOS2_y[1] + 3*pw.SOS2_y[2] + 4*pw.SOS2_y[3]) : 0.0 : True
2 : 0.0 : f - (pw.SOS2_y[0] + 2*pw.SOS2_y[1] + pw.SOS2_y[2] + 2*pw.SOS2_y[3]) : 0.0 : True
@@ -151,13 +128,13 @@
3 : pw.SOS2_y[2]
4 : pw.SOS2_y[3]
- 5 Declarations: SOS2_y_index SOS2_y SOS2_constraint_index SOS2_constraint SOS2_sosconstraint
+ 3 Declarations: SOS2_y SOS2_constraint SOS2_sosconstraint
1 Suffix Declarations
dual : Direction=IMPORT, Datatype=FLOAT
Key : Value
-27 Declarations: b s q p pd v vd vl_index vl c cd_index cd cl_index cl e ed o od ol_index ol sos1 sos2 sd_index sd dual f pw
+22 Declarations: b s q p pd v vd vl c cd cl e ed o od ol sos1 sos2 sd dual f pw
: block(active=True, ctype=IBlock)
- b: block(active=True, ctype=IBlock)
- p: parameter(active=True, value=0)
@@ -231,4 +208,4 @@
- pw.c[2]: linear_constraint(active=True, expr=pw.v[0] + pw.v[1] + pw.v[2] + pw.v[3] == 1)
- pw.s: sos(active=True, level=2, entries=['(pw.v[0],1)', '(pw.v[1],2)', '(pw.v[2],3)', '(pw.v[3],4)'])
Memory: 1.9 KB
-Memory: 9.5 KB
+Memory: 9.7 KB
diff --git a/doc/OnlineDocs/src/scripting/AbstractSuffixes.py b/doc/OnlineDocs/src/scripting/AbstractSuffixes.py
index 20a4cc20581..1c064042c6b 100644
--- a/doc/OnlineDocs/src/scripting/AbstractSuffixes.py
+++ b/doc/OnlineDocs/src/scripting/AbstractSuffixes.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/src/scripting/Isinglebuild.py b/doc/OnlineDocs/src/scripting/Isinglebuild.py
index 00f79c9a750..344f8905a4a 100644
--- a/doc/OnlineDocs/src/scripting/Isinglebuild.py
+++ b/doc/OnlineDocs/src/scripting/Isinglebuild.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Isinglebuild.py
# NodesIn and NodesOut are created by a build action using the Arcs
from pyomo.environ import *
diff --git a/doc/OnlineDocs/src/scripting/NodesIn_init.py b/doc/OnlineDocs/src/scripting/NodesIn_init.py
index 4a90029baa3..c17b70150bc 100644
--- a/doc/OnlineDocs/src/scripting/NodesIn_init.py
+++ b/doc/OnlineDocs/src/scripting/NodesIn_init.py
@@ -1,3 +1,15 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+
def NodesIn_init(model, node):
retval = []
for i, j in model.Arcs:
diff --git a/doc/OnlineDocs/src/scripting/Z_init.py b/doc/OnlineDocs/src/scripting/Z_init.py
index 426de6f7d08..1dd2843f4f0 100644
--- a/doc/OnlineDocs/src/scripting/Z_init.py
+++ b/doc/OnlineDocs/src/scripting/Z_init.py
@@ -1,3 +1,15 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+
def Z_init(model, i):
if i > 10:
return Set.End
diff --git a/doc/OnlineDocs/src/scripting/abstract2.py b/doc/OnlineDocs/src/scripting/abstract2.py
index 1e14d1d1898..544399a8a42 100644
--- a/doc/OnlineDocs/src/scripting/abstract2.py
+++ b/doc/OnlineDocs/src/scripting/abstract2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# abstract2.py
diff --git a/doc/OnlineDocs/src/scripting/abstract2piece.py b/doc/OnlineDocs/src/scripting/abstract2piece.py
index 225ec0d1a64..03c5139004e 100644
--- a/doc/OnlineDocs/src/scripting/abstract2piece.py
+++ b/doc/OnlineDocs/src/scripting/abstract2piece.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# abstract2piece.py
# Similar to abstract2.py, but the objective is now c times x to the fourth power
diff --git a/doc/OnlineDocs/src/scripting/abstract2piecebuild.py b/doc/OnlineDocs/src/scripting/abstract2piecebuild.py
index 1f00cdb0265..d454d7fbc79 100644
--- a/doc/OnlineDocs/src/scripting/abstract2piecebuild.py
+++ b/doc/OnlineDocs/src/scripting/abstract2piecebuild.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# abstract2piecebuild.py
# Similar to abstract2piece.py, but the breakpoints are created using a build action
diff --git a/doc/OnlineDocs/src/scripting/block_iter_example.py b/doc/OnlineDocs/src/scripting/block_iter_example.py
index 680e0d1728b..10c8a4ea43d 100644
--- a/doc/OnlineDocs/src/scripting/block_iter_example.py
+++ b/doc/OnlineDocs/src/scripting/block_iter_example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# written by jds, adapted for doc by dlw
from pyomo.environ import *
diff --git a/doc/OnlineDocs/src/scripting/concrete1.py b/doc/OnlineDocs/src/scripting/concrete1.py
index 2cd1a1f722c..399715efde6 100644
--- a/doc/OnlineDocs/src/scripting/concrete1.py
+++ b/doc/OnlineDocs/src/scripting/concrete1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = ConcreteModel()
diff --git a/doc/OnlineDocs/src/scripting/doubleA.py b/doc/OnlineDocs/src/scripting/doubleA.py
index 12a07944db3..abf35979a05 100644
--- a/doc/OnlineDocs/src/scripting/doubleA.py
+++ b/doc/OnlineDocs/src/scripting/doubleA.py
@@ -1,3 +1,15 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+
def doubleA_init(model):
return (i * 2 for i in model.A)
diff --git a/doc/OnlineDocs/src/scripting/driveabs2.py b/doc/OnlineDocs/src/scripting/driveabs2.py
index 45862195a57..f8f972460b1 100644
--- a/doc/OnlineDocs/src/scripting/driveabs2.py
+++ b/doc/OnlineDocs/src/scripting/driveabs2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# driveabs2.py
import pyomo.environ as pyo
diff --git a/doc/OnlineDocs/src/scripting/driveconc1.py b/doc/OnlineDocs/src/scripting/driveconc1.py
index 95b0f42806d..49b92f32d09 100644
--- a/doc/OnlineDocs/src/scripting/driveconc1.py
+++ b/doc/OnlineDocs/src/scripting/driveconc1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# driveconc1.py
import pyomo.environ as pyo
diff --git a/doc/OnlineDocs/src/scripting/iterative1.py b/doc/OnlineDocs/src/scripting/iterative1.py
index 61b0fd3828e..939120e834f 100644
--- a/doc/OnlineDocs/src/scripting/iterative1.py
+++ b/doc/OnlineDocs/src/scripting/iterative1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# @Import_symbols_for_pyomo
# iterative1.py
import pyomo.environ as pyo
diff --git a/doc/OnlineDocs/src/scripting/iterative2.py b/doc/OnlineDocs/src/scripting/iterative2.py
index e559a2c8400..7506337a491 100644
--- a/doc/OnlineDocs/src/scripting/iterative2.py
+++ b/doc/OnlineDocs/src/scripting/iterative2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# iterative2.py
import pyomo.environ as pyo
diff --git a/doc/OnlineDocs/src/scripting/noiteration1.py b/doc/OnlineDocs/src/scripting/noiteration1.py
index be9fb529855..c7a86e9d1e9 100644
--- a/doc/OnlineDocs/src/scripting/noiteration1.py
+++ b/doc/OnlineDocs/src/scripting/noiteration1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# noiteration1.py
import pyomo.environ as pyo
diff --git a/doc/OnlineDocs/src/scripting/parallel.py b/doc/OnlineDocs/src/scripting/parallel.py
index cf9b55d9605..e6cfa002780 100644
--- a/doc/OnlineDocs/src/scripting/parallel.py
+++ b/doc/OnlineDocs/src/scripting/parallel.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# parallel.py
# run with mpirun -np 2 python -m mpi4py parallel.py
import pyomo.environ as pyo
diff --git a/doc/OnlineDocs/src/scripting/spy4Constraints.py b/doc/OnlineDocs/src/scripting/spy4Constraints.py
index f0033bbc33e..66f82802402 100644
--- a/doc/OnlineDocs/src/scripting/spy4Constraints.py
+++ b/doc/OnlineDocs/src/scripting/spy4Constraints.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""
David L. Woodruff and Mingye Yang, Spring 2018
Code snippets for Constraints.rst in testable form
diff --git a/doc/OnlineDocs/src/scripting/spy4Expressions.py b/doc/OnlineDocs/src/scripting/spy4Expressions.py
index 0e8a50c78b3..cf7ed1f112f 100644
--- a/doc/OnlineDocs/src/scripting/spy4Expressions.py
+++ b/doc/OnlineDocs/src/scripting/spy4Expressions.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""
David L. Woodruff and Mingye Yang, Spring 2018
Code snippets for Expressions.rst in testable form
diff --git a/doc/OnlineDocs/src/scripting/spy4PyomoCommand.py b/doc/OnlineDocs/src/scripting/spy4PyomoCommand.py
index f655b812076..9f6698d63c9 100644
--- a/doc/OnlineDocs/src/scripting/spy4PyomoCommand.py
+++ b/doc/OnlineDocs/src/scripting/spy4PyomoCommand.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""
David L. Woodruff and Mingye Yang, Spring 2018
Code snippets for PyomoCommand.rst in testable form
diff --git a/doc/OnlineDocs/src/scripting/spy4Variables.py b/doc/OnlineDocs/src/scripting/spy4Variables.py
index c4e2ff612f1..1bc2dc9f1ef 100644
--- a/doc/OnlineDocs/src/scripting/spy4Variables.py
+++ b/doc/OnlineDocs/src/scripting/spy4Variables.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""
David L. Woodruff and Mingye Yang, Spring 2018
Code snippets for Variables.rst in testable form
diff --git a/doc/OnlineDocs/src/scripting/spy4scripts.py b/doc/OnlineDocs/src/scripting/spy4scripts.py
index 48ba923d09c..f71a1b67b11 100644
--- a/doc/OnlineDocs/src/scripting/spy4scripts.py
+++ b/doc/OnlineDocs/src/scripting/spy4scripts.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
###NOTE: as of May 16, this will not even come close to running. DLW
### and it is "wrong" in a lot of places.
### Someone should edit this file, then delete these comment lines. DLW may 16
diff --git a/doc/OnlineDocs/src/strip_examples.py b/doc/OnlineDocs/src/strip_examples.py
index 045af6b87cc..2fd03256499 100644
--- a/doc/OnlineDocs/src/strip_examples.py
+++ b/doc/OnlineDocs/src/strip_examples.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#
# This script finds all *.py files in the current and subdirectories.
# It processes these files to find blocks that start/end with "# @"
diff --git a/doc/OnlineDocs/src/test_examples.py b/doc/OnlineDocs/src/test_examples.py
index a7991eadf19..c5c9a135ee9 100644
--- a/doc/OnlineDocs/src/test_examples.py
+++ b/doc/OnlineDocs/src/test_examples.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/doc/OnlineDocs/tutorial_examples.rst b/doc/OnlineDocs/tutorial_examples.rst
index dc58b6a6f59..a18f9d77d42 100644
--- a/doc/OnlineDocs/tutorial_examples.rst
+++ b/doc/OnlineDocs/tutorial_examples.rst
@@ -3,13 +3,18 @@ Pyomo Tutorial Examples
Additional Pyomo tutorials and examples can be found at the following links:
-`Pyomo Workshop Slides and Exercises
-`_
+* `Pyomo — Optimization Modeling in Python
+ `_ ([PyomoBookIII]_)
-`Prof. Jeffrey Kantor's Pyomo Cookbook
-`_
+* `Pyomo Workshop Slides and Exercises
+ `_
-`Pyomo Gallery
-`_
+* `Prof. Jeffrey Kantor's Pyomo Cookbook
+ `_
+
+* The `companion notebooks `_
+ for *Hands-On Mathematical Optimization with Python*
+
+* `Pyomo Gallery `_
diff --git a/doc/OnlineDocs/working_abstractmodels/data/raw_dicts.rst b/doc/OnlineDocs/working_abstractmodels/data/raw_dicts.rst
index e10042b3ceb..f78e349c28b 100644
--- a/doc/OnlineDocs/working_abstractmodels/data/raw_dicts.rst
+++ b/doc/OnlineDocs/working_abstractmodels/data/raw_dicts.rst
@@ -28,13 +28,10 @@ components, the required data dictionary maps the implicit index
... }}
>>> i = m.create_instance(data)
>>> i.pprint()
- 2 Set Declarations
+ 1 Set Declarations
I : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {1, 2, 3}
- r_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : I*I : 9 : {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}
3 Param Declarations
p : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
@@ -45,12 +42,12 @@ components, the required data dictionary maps the implicit index
1 : 10
2 : 20
3 : 30
- r : Size=9, Index=r_index, Domain=Any, Default=0, Mutable=False
+ r : Size=9, Index=I*I, Domain=Any, Default=0, Mutable=False
Key : Value
(1, 1) : 110
(1, 2) : 120
(2, 3) : 230
- 5 Declarations: I p q r_index r
+ 4 Declarations: I p q r
diff --git a/examples/dae/Heat_Conduction.py b/examples/dae/Heat_Conduction.py
index 11f35fddd13..7e11ec59263 100644
--- a/examples/dae/Heat_Conduction.py
+++ b/examples/dae/Heat_Conduction.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/Optimal_Control.py b/examples/dae/Optimal_Control.py
index ed44d5eeb59..676c95271f2 100644
--- a/examples/dae/Optimal_Control.py
+++ b/examples/dae/Optimal_Control.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/PDE_example.py b/examples/dae/PDE_example.py
index 6cb7eb4a7fe..0aea173415b 100644
--- a/examples/dae/PDE_example.py
+++ b/examples/dae/PDE_example.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/Parameter_Estimation.py b/examples/dae/Parameter_Estimation.py
index 7ee2f112b94..332a21d93dc 100644
--- a/examples/dae/Parameter_Estimation.py
+++ b/examples/dae/Parameter_Estimation.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/Path_Constraint.py b/examples/dae/Path_Constraint.py
index 866b4b3b90a..69f31980c63 100644
--- a/examples/dae/Path_Constraint.py
+++ b/examples/dae/Path_Constraint.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/ReactionKinetics.py b/examples/dae/ReactionKinetics.py
index ef760820c4b..2e474ae40d3 100644
--- a/examples/dae/ReactionKinetics.py
+++ b/examples/dae/ReactionKinetics.py
@@ -2,7 +2,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -304,7 +304,10 @@ def regression_model():
# Model & data from:
#
- # http://www.doiserbia.nb.rs/img/doi/0367-598X/2014/0367-598X1300037A.pdf
+ # https://doiserbia.nb.rs/img/doi/0367-598X/2014/0367-598X1300037A.pdf
+ # Almagrbi, A. M., Hatami, T., Glišić, S., & Orlović, A. (2014).
+ # Determination of kinetic parameters for complex transesterification
+ # reaction by standard optimisation methods.
#
model = ConcreteModel()
diff --git a/examples/dae/car_example.py b/examples/dae/car_example.py
index a157159cf6c..b6ca2203860 100644
--- a/examples/dae/car_example.py
+++ b/examples/dae/car_example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Ampl Car Example
#
# Shows how to convert a minimize final time optimal control problem
diff --git a/examples/dae/disease_DAE.py b/examples/dae/disease_DAE.py
index 59e598aa504..bfeb2530fc9 100644
--- a/examples/dae/disease_DAE.py
+++ b/examples/dae/disease_DAE.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
###
# SIR disease model using radau collocation
###
diff --git a/examples/dae/distill_DAE.py b/examples/dae/distill_DAE.py
index cdfd543f9a8..e822cfb1752 100644
--- a/examples/dae/distill_DAE.py
+++ b/examples/dae/distill_DAE.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/dynamic_scheduling.py b/examples/dae/dynamic_scheduling.py
index 13cabeb5bcf..137307e31a9 100644
--- a/examples/dae/dynamic_scheduling.py
+++ b/examples/dae/dynamic_scheduling.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/laplace_BVP.py b/examples/dae/laplace_BVP.py
index 6b2e2841575..61f911b3826 100644
--- a/examples/dae/laplace_BVP.py
+++ b/examples/dae/laplace_BVP.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/run_Optimal_Control.py b/examples/dae/run_Optimal_Control.py
index 2523bd8c607..2e7bc79dff4 100644
--- a/examples/dae/run_Optimal_Control.py
+++ b/examples/dae/run_Optimal_Control.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/run_Parameter_Estimation.py b/examples/dae/run_Parameter_Estimation.py
index a319000cb59..c9b649df8dd 100644
--- a/examples/dae/run_Parameter_Estimation.py
+++ b/examples/dae/run_Parameter_Estimation.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/run_Path_Constraint.py b/examples/dae/run_Path_Constraint.py
index 17a576a57d8..996b432a555 100644
--- a/examples/dae/run_Path_Constraint.py
+++ b/examples/dae/run_Path_Constraint.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/run_disease.py b/examples/dae/run_disease.py
index 139046d434e..5d9595a89d5 100644
--- a/examples/dae/run_disease.py
+++ b/examples/dae/run_disease.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
from pyomo.dae import *
from disease_DAE import model
diff --git a/examples/dae/run_distill.py b/examples/dae/run_distill.py
index d9ececf34fc..9b09850f90a 100644
--- a/examples/dae/run_distill.py
+++ b/examples/dae/run_distill.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/dae/run_stochpdegas_automatic.py b/examples/dae/run_stochpdegas_automatic.py
index dd710588406..6fc9f6d594c 100644
--- a/examples/dae/run_stochpdegas_automatic.py
+++ b/examples/dae/run_stochpdegas_automatic.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import time
from pyomo.environ import *
diff --git a/examples/dae/simulator_dae_example.py b/examples/dae/simulator_dae_example.py
index ef6484be6c6..4ea1f9fd5f0 100644
--- a/examples/dae/simulator_dae_example.py
+++ b/examples/dae/simulator_dae_example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#
# Batch reactor example from Biegler book on Nonlinear Programming Chapter 9
#
diff --git a/examples/dae/simulator_dae_multindex_example.py b/examples/dae/simulator_dae_multindex_example.py
index d1a97fec79f..775eb4f8c79 100644
--- a/examples/dae/simulator_dae_multindex_example.py
+++ b/examples/dae/simulator_dae_multindex_example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#
# Batch reactor example from Biegler book on Nonlinear Programming Chapter 9
#
diff --git a/examples/dae/simulator_ode_example.py b/examples/dae/simulator_ode_example.py
index bf600cf163e..f6f28b87d07 100644
--- a/examples/dae/simulator_ode_example.py
+++ b/examples/dae/simulator_ode_example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#
# Example from Scipy odeint examples
#
diff --git a/examples/dae/simulator_ode_multindex_example.py b/examples/dae/simulator_ode_multindex_example.py
index fa2623f4cc2..b1b9111084b 100644
--- a/examples/dae/simulator_ode_multindex_example.py
+++ b/examples/dae/simulator_ode_multindex_example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#
# Example from Scipy odeint examples
#
diff --git a/examples/dae/stochpdegas_automatic.py b/examples/dae/stochpdegas_automatic.py
index fdde099a396..397b4a18100 100644
--- a/examples/dae/stochpdegas_automatic.py
+++ b/examples/dae/stochpdegas_automatic.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# stochastic pde model for natural gas network
# victor m. zavala / 2013
diff --git a/examples/doc/samples/__init__.py b/examples/doc/samples/__init__.py
index 3115f06ef53..0110902b288 100644
--- a/examples/doc/samples/__init__.py
+++ b/examples/doc/samples/__init__.py
@@ -1 +1,12 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Dummy file for pytest
diff --git a/examples/doc/samples/case_studies/deer/DeerProblem.py b/examples/doc/samples/case_studies/deer/DeerProblem.py
index 0b6b7252aaa..d09c9b53887 100644
--- a/examples/doc/samples/case_studies/deer/DeerProblem.py
+++ b/examples/doc/samples/case_studies/deer/DeerProblem.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
#
diff --git a/examples/doc/samples/case_studies/diet/DietProblem.py b/examples/doc/samples/case_studies/diet/DietProblem.py
index f070201c28e..64624310943 100644
--- a/examples/doc/samples/case_studies/diet/DietProblem.py
+++ b/examples/doc/samples/case_studies/diet/DietProblem.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
model = AbstractModel()
diff --git a/examples/doc/samples/case_studies/disease_est/DiseaseEstimation.py b/examples/doc/samples/case_studies/disease_est/DiseaseEstimation.py
index c685a6ee67f..6a0edb38350 100644
--- a/examples/doc/samples/case_studies/disease_est/DiseaseEstimation.py
+++ b/examples/doc/samples/case_studies/disease_est/DiseaseEstimation.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
model = AbstractModel()
diff --git a/examples/doc/samples/case_studies/max_flow/MaxFlow.py b/examples/doc/samples/case_studies/max_flow/MaxFlow.py
index c6eb42ccf7d..1e75fa4e79d 100644
--- a/examples/doc/samples/case_studies/max_flow/MaxFlow.py
+++ b/examples/doc/samples/case_studies/max_flow/MaxFlow.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
model = AbstractModel()
diff --git a/examples/doc/samples/case_studies/network_flow/networkFlow1.py b/examples/doc/samples/case_studies/network_flow/networkFlow1.py
index adfaab4476b..eb8c8e48a1a 100644
--- a/examples/doc/samples/case_studies/network_flow/networkFlow1.py
+++ b/examples/doc/samples/case_studies/network_flow/networkFlow1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
model = AbstractModel()
diff --git a/examples/doc/samples/case_studies/rosen/Rosenbrock.py b/examples/doc/samples/case_studies/rosen/Rosenbrock.py
index 9677cea95dd..51e7d51b57d 100644
--- a/examples/doc/samples/case_studies/rosen/Rosenbrock.py
+++ b/examples/doc/samples/case_studies/rosen/Rosenbrock.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# @intro:
from pyomo.core import *
diff --git a/examples/doc/samples/case_studies/transportation/transportation.py b/examples/doc/samples/case_studies/transportation/transportation.py
index 26fcb5f0b66..588ae764953 100644
--- a/examples/doc/samples/case_studies/transportation/transportation.py
+++ b/examples/doc/samples/case_studies/transportation/transportation.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
model = AbstractModel()
diff --git a/examples/doc/samples/comparisons/cutstock/cutstock_cplex.py b/examples/doc/samples/comparisons/cutstock/cutstock_cplex.py
index 796c39810f8..f49c5b591ae 100644
--- a/examples/doc/samples/comparisons/cutstock/cutstock_cplex.py
+++ b/examples/doc/samples/comparisons/cutstock/cutstock_cplex.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import cplex
from cutstock_util import *
from cplex.exceptions import CplexSolverError
diff --git a/examples/doc/samples/comparisons/cutstock/cutstock_grb.py b/examples/doc/samples/comparisons/cutstock/cutstock_grb.py
index 4fa4556fc96..483d84b02e6 100644
--- a/examples/doc/samples/comparisons/cutstock/cutstock_grb.py
+++ b/examples/doc/samples/comparisons/cutstock/cutstock_grb.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from gurobipy import *
from cutstock_util import *
diff --git a/examples/doc/samples/comparisons/cutstock/cutstock_lpsolve.py b/examples/doc/samples/comparisons/cutstock/cutstock_lpsolve.py
index 658ee006c30..9a6c8301e8f 100644
--- a/examples/doc/samples/comparisons/cutstock/cutstock_lpsolve.py
+++ b/examples/doc/samples/comparisons/cutstock/cutstock_lpsolve.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from lpsolve55 import *
from cutstock_util import *
diff --git a/examples/doc/samples/comparisons/cutstock/cutstock_pulpor.py b/examples/doc/samples/comparisons/cutstock/cutstock_pulpor.py
index 2f2506ba3d6..d14b0fe46c1 100644
--- a/examples/doc/samples/comparisons/cutstock/cutstock_pulpor.py
+++ b/examples/doc/samples/comparisons/cutstock/cutstock_pulpor.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pulp import *
from cutstock_util import *
diff --git a/examples/doc/samples/comparisons/cutstock/cutstock_pyomo.py b/examples/doc/samples/comparisons/cutstock/cutstock_pyomo.py
index a67ebdd0675..48d7e6b26fd 100644
--- a/examples/doc/samples/comparisons/cutstock/cutstock_pyomo.py
+++ b/examples/doc/samples/comparisons/cutstock/cutstock_pyomo.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
import pyomo.opt
from cutstock_util import *
diff --git a/examples/doc/samples/comparisons/cutstock/cutstock_util.py b/examples/doc/samples/comparisons/cutstock/cutstock_util.py
index 1cd8c61922f..da5349ec06c 100644
--- a/examples/doc/samples/comparisons/cutstock/cutstock_util.py
+++ b/examples/doc/samples/comparisons/cutstock/cutstock_util.py
@@ -1,3 +1,15 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+
def getCutCount():
cutCount = 0
fout1 = open('WidthDemand.csv', 'r')
diff --git a/examples/doc/samples/comparisons/sched/pyomo/sched.py b/examples/doc/samples/comparisons/sched/pyomo/sched.py
index 627bc083fbe..cf781713641 100644
--- a/examples/doc/samples/comparisons/sched/pyomo/sched.py
+++ b/examples/doc/samples/comparisons/sched/pyomo/sched.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
model = AbstractModel()
diff --git a/examples/doc/samples/scripts/__init__.py b/examples/doc/samples/scripts/__init__.py
index 3115f06ef53..0110902b288 100644
--- a/examples/doc/samples/scripts/__init__.py
+++ b/examples/doc/samples/scripts/__init__.py
@@ -1 +1,12 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Dummy file for pytest
diff --git a/examples/doc/samples/scripts/s1/knapsack.py b/examples/doc/samples/scripts/s1/knapsack.py
index 642e0faaaed..cee3937b668 100644
--- a/examples/doc/samples/scripts/s1/knapsack.py
+++ b/examples/doc/samples/scripts/s1/knapsack.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
diff --git a/examples/doc/samples/scripts/s1/script.py b/examples/doc/samples/scripts/s1/script.py
index 02b6b406922..4ddaea45e19 100644
--- a/examples/doc/samples/scripts/s1/script.py
+++ b/examples/doc/samples/scripts/s1/script.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
import pyomo.opt
import pyomo.environ
diff --git a/examples/doc/samples/scripts/s2/knapsack.py b/examples/doc/samples/scripts/s2/knapsack.py
index a7d693f5d35..3131cee7bc5 100644
--- a/examples/doc/samples/scripts/s2/knapsack.py
+++ b/examples/doc/samples/scripts/s2/knapsack.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
diff --git a/examples/doc/samples/scripts/s2/script.py b/examples/doc/samples/scripts/s2/script.py
index 88de1dec680..fe97d6ab8fd 100644
--- a/examples/doc/samples/scripts/s2/script.py
+++ b/examples/doc/samples/scripts/s2/script.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
import pyomo.opt
import pyomo.environ
diff --git a/examples/doc/samples/scripts/test_scripts.py b/examples/doc/samples/scripts/test_scripts.py
index ca0c8a7cc4e..691a44aea2d 100644
--- a/examples/doc/samples/scripts/test_scripts.py
+++ b/examples/doc/samples/scripts/test_scripts.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/doc/samples/update.py b/examples/doc/samples/update.py
index 9eae2f4b694..8789413303c 100644
--- a/examples/doc/samples/update.py
+++ b/examples/doc/samples/update.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#!/usr/bin/env python
#
# This is a Python script that regenerates the top-level TRAC.txt file, which
diff --git a/examples/gdp/batchProcessing.py b/examples/gdp/batchProcessing.py
index f0980dd5034..9810f5d63f1 100644
--- a/examples/gdp/batchProcessing.py
+++ b/examples/gdp/batchProcessing.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
from pyomo.gdp import *
diff --git a/examples/gdp/circles/circles.py b/examples/gdp/circles/circles.py
index ae905998403..a8b7a156fad 100644
--- a/examples/gdp/circles/circles.py
+++ b/examples/gdp/circles/circles.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""
The "circles" GDP example problem originating in Lee and Grossman (2000). The
goal is to choose a point to minimize a convex quadratic function over a set of
diff --git a/examples/gdp/constrained_layout/cons_layout_model.py b/examples/gdp/constrained_layout/cons_layout_model.py
index 245aa2df58e..d38fd0cc66b 100644
--- a/examples/gdp/constrained_layout/cons_layout_model.py
+++ b/examples/gdp/constrained_layout/cons_layout_model.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""2-D constrained layout example.
Example based on: https://www.minlp.org/library/problem/index.php?i=107&lib=GDP
diff --git a/examples/gdp/disease_model.py b/examples/gdp/disease_model.py
index bc3e69600ec..498337e35e6 100644
--- a/examples/gdp/disease_model.py
+++ b/examples/gdp/disease_model.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/gdp/eight_process/eight_proc_logical.py b/examples/gdp/eight_process/eight_proc_logical.py
index 60f7acee876..4496427d421 100644
--- a/examples/gdp/eight_process/eight_proc_logical.py
+++ b/examples/gdp/eight_process/eight_proc_logical.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Disjunctive re-implementation of eight-process problem.
Re-implementation of Duran example 3 superstructure synthesis problem in Pyomo
diff --git a/examples/gdp/eight_process/eight_proc_model.py b/examples/gdp/eight_process/eight_proc_model.py
index 840b6911d83..41bb6d462f1 100644
--- a/examples/gdp/eight_process/eight_proc_model.py
+++ b/examples/gdp/eight_process/eight_proc_model.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Disjunctive re-implementation of eight-process problem.
Re-implementation of Duran example 3 superstructure synthesis problem in Pyomo
diff --git a/examples/gdp/eight_process/eight_proc_verbose_model.py b/examples/gdp/eight_process/eight_proc_verbose_model.py
index cae584d4127..1fd68909146 100644
--- a/examples/gdp/eight_process/eight_proc_verbose_model.py
+++ b/examples/gdp/eight_process/eight_proc_verbose_model.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Disjunctive re-implementation of eight-process problem.
This is the more verbose formulation of the same problem given in
diff --git a/examples/gdp/farm_layout/farm_layout.py b/examples/gdp/farm_layout/farm_layout.py
index 411e2de3242..1b232b9cfa6 100644
--- a/examples/gdp/farm_layout/farm_layout.py
+++ b/examples/gdp/farm_layout/farm_layout.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""
Farm layout example from Sawaya (2006). The goal is to determine optimal placements and dimensions for farm
plots of specified areas to minimize the perimeter of a minimal enclosing fence. This is a GDP problem with
diff --git a/examples/gdp/jobshop-nodisjuncts.py b/examples/gdp/jobshop-nodisjuncts.py
index bc656dc4717..0cd5b5ab274 100644
--- a/examples/gdp/jobshop-nodisjuncts.py
+++ b/examples/gdp/jobshop-nodisjuncts.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/gdp/jobshop.py b/examples/gdp/jobshop.py
index 619ece47e72..7119ee7655c 100644
--- a/examples/gdp/jobshop.py
+++ b/examples/gdp/jobshop.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/gdp/medTermPurchasing_Literal.py b/examples/gdp/medTermPurchasing_Literal.py
index c9b27920396..b6d16c216fe 100755
--- a/examples/gdp/medTermPurchasing_Literal.py
+++ b/examples/gdp/medTermPurchasing_Literal.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
from pyomo.gdp import *
diff --git a/examples/gdp/nine_process/small_process.py b/examples/gdp/nine_process/small_process.py
index 2758069f316..2abffef1af6 100644
--- a/examples/gdp/nine_process/small_process.py
+++ b/examples/gdp/nine_process/small_process.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Small process synthesis-inspired toy GDP example.
"""
diff --git a/examples/gdp/simple1.py b/examples/gdp/simple1.py
index f7c77b111f0..de41c0bfd00 100644
--- a/examples/gdp/simple1.py
+++ b/examples/gdp/simple1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Example: modeling a complementarity condition as a
# disjunction
#
diff --git a/examples/gdp/simple2.py b/examples/gdp/simple2.py
index 6bcc7bbf747..b066d705036 100644
--- a/examples/gdp/simple2.py
+++ b/examples/gdp/simple2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Example: modeling a complementarity condition as a
# disjunction
#
diff --git a/examples/gdp/simple3.py b/examples/gdp/simple3.py
index 6b3d6ec46c4..890daf8882b 100644
--- a/examples/gdp/simple3.py
+++ b/examples/gdp/simple3.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Example: modeling a complementarity condition as a
# disjunction
#
diff --git a/examples/gdp/small_lit/basic_step.py b/examples/gdp/small_lit/basic_step.py
index 48ef52d9ba0..2d9da97167c 100644
--- a/examples/gdp/small_lit/basic_step.py
+++ b/examples/gdp/small_lit/basic_step.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
""" Example from Section 3.2 in paper of Pseudo Basic Steps
Ref:
diff --git a/examples/gdp/small_lit/contracts_problem.py b/examples/gdp/small_lit/contracts_problem.py
index 500fe15cb2a..0c59d2264ee 100644
--- a/examples/gdp/small_lit/contracts_problem.py
+++ b/examples/gdp/small_lit/contracts_problem.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
""" Example from 'Lagrangean Relaxation of the Hull-Reformulation of Linear \
Generalized Disjunctive Programs and its use in Disjunctive Branch \
and Bound' Page 25 f.
diff --git a/examples/gdp/small_lit/ex1_Lee.py b/examples/gdp/small_lit/ex1_Lee.py
index ddd2e1c3d2f..abbf470a1c3 100644
--- a/examples/gdp/small_lit/ex1_Lee.py
+++ b/examples/gdp/small_lit/ex1_Lee.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Simple example of nonlinear problem modeled with GDP framework.
Taken from Example 1 of the paper "New Algorithms for Nonlinear Generalized Disjunctive Programming" by Lee and Grossmann
diff --git a/examples/gdp/small_lit/ex_633_trespalacios.py b/examples/gdp/small_lit/ex_633_trespalacios.py
index 61b7294e3ba..b0c5fbd85ac 100644
--- a/examples/gdp/small_lit/ex_633_trespalacios.py
+++ b/examples/gdp/small_lit/ex_633_trespalacios.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Analytical example from Section 6.3.3 of F. Trespalacions Ph.D. Thesis (2015)
Analytical example for a nonconvex GDP with 2 disjunctions, each with 2 disjuncts.
diff --git a/examples/gdp/small_lit/nonconvex_HEN.py b/examples/gdp/small_lit/nonconvex_HEN.py
index 99e2c4f15e2..05fad970b84 100644
--- a/examples/gdp/small_lit/nonconvex_HEN.py
+++ b/examples/gdp/small_lit/nonconvex_HEN.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
""" Example from 'Systematic Modeling of Discrete-Continuous Optimization \
Models through Generalized Disjunctive Programming'
Ignacio E. Grossmann and Francisco Trespalacios, 2013
diff --git a/examples/gdp/stickies.py b/examples/gdp/stickies.py
index 75beb911415..73b537ff13d 100644
--- a/examples/gdp/stickies.py
+++ b/examples/gdp/stickies.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import os
from pyomo.common.fileutils import this_file_dir
diff --git a/examples/gdp/strip_packing/stripPacking.py b/examples/gdp/strip_packing/stripPacking.py
index 0e8902c5ee4..39f7208b838 100644
--- a/examples/gdp/strip_packing/stripPacking.py
+++ b/examples/gdp/strip_packing/stripPacking.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
from pyomo.gdp import *
diff --git a/examples/gdp/strip_packing/strip_packing_8rect.py b/examples/gdp/strip_packing/strip_packing_8rect.py
index e1350dbc39e..2bd7c4840ca 100644
--- a/examples/gdp/strip_packing/strip_packing_8rect.py
+++ b/examples/gdp/strip_packing/strip_packing_8rect.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Strip packing example from MINLP.org library.
Strip-packing example from http://minlp.org/library/lib.php?lib=GDP
This model packs a set of rectangles without rotation or overlap within a
diff --git a/examples/gdp/strip_packing/strip_packing_concrete.py b/examples/gdp/strip_packing/strip_packing_concrete.py
index 1313d75561c..b0907cdea61 100644
--- a/examples/gdp/strip_packing/strip_packing_concrete.py
+++ b/examples/gdp/strip_packing/strip_packing_concrete.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Strip packing example from MINLP.org library.
Strip-packing example from http://minlp.org/library/lib.php?lib=GDP
diff --git a/examples/gdp/two_rxn_lee/two_rxn_model.py b/examples/gdp/two_rxn_lee/two_rxn_model.py
index 2e5f1734130..98e4cc2e878 100644
--- a/examples/gdp/two_rxn_lee/two_rxn_model.py
+++ b/examples/gdp/two_rxn_lee/two_rxn_model.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
"""Two reactor model from literature. See README.md."""
from pyomo.core import ConcreteModel, Constraint, Objective, Param, Var, maximize
diff --git a/examples/kernel/blocks.py b/examples/kernel/blocks.py
index 7036981dcc8..db1cb6655c2 100644
--- a/examples/kernel/blocks.py
+++ b/examples/kernel/blocks.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
#
diff --git a/examples/kernel/conic.py b/examples/kernel/conic.py
index a2a787794a4..5ee66a00ee9 100644
--- a/examples/kernel/conic.py
+++ b/examples/kernel/conic.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
#
diff --git a/examples/kernel/constraints.py b/examples/kernel/constraints.py
index 6495ad12f63..69823a6ebbe 100644
--- a/examples/kernel/constraints.py
+++ b/examples/kernel/constraints.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
v = pmo.variable()
diff --git a/examples/kernel/containers.py b/examples/kernel/containers.py
index 9b525e87af6..9ec749b8c3e 100644
--- a/examples/kernel/containers.py
+++ b/examples/kernel/containers.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
#
diff --git a/examples/kernel/expressions.py b/examples/kernel/expressions.py
index 1756e5d3fd4..faef8d1d4ad 100644
--- a/examples/kernel/expressions.py
+++ b/examples/kernel/expressions.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
v = pmo.variable(value=2)
diff --git a/examples/kernel/mosek/geometric1.py b/examples/kernel/mosek/geometric1.py
index b5ec59541c4..8148e707819 100644
--- a/examples/kernel/mosek/geometric1.py
+++ b/examples/kernel/mosek/geometric1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Source: https://docs.mosek.com/9.0/pythonapi/tutorial-gp-shared.html
import pyomo.kernel as pmo
diff --git a/examples/kernel/mosek/geometric2.py b/examples/kernel/mosek/geometric2.py
index 84825c0a39b..3fb62c86312 100644
--- a/examples/kernel/mosek/geometric2.py
+++ b/examples/kernel/mosek/geometric2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Source: https://docs.mosek.com/modeling-cookbook/expo.html
# (first example in Section 5.3.1)
diff --git a/examples/kernel/mosek/maximum_volume_cuboid.py b/examples/kernel/mosek/maximum_volume_cuboid.py
index 92e210cf400..df200cc801c 100644
--- a/examples/kernel/mosek/maximum_volume_cuboid.py
+++ b/examples/kernel/mosek/maximum_volume_cuboid.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from scipy.spatial import ConvexHull
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
diff --git a/examples/kernel/mosek/power1.py b/examples/kernel/mosek/power1.py
index d7a12c1ce54..a6d6ebbe47d 100644
--- a/examples/kernel/mosek/power1.py
+++ b/examples/kernel/mosek/power1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Source: https://docs.mosek.com/9.0/pythonapi/tutorial-pow-shared.html
import pyomo.kernel as pmo
diff --git a/examples/kernel/mosek/semidefinite.py b/examples/kernel/mosek/semidefinite.py
index 44ab7c95a68..6be47d85451 100644
--- a/examples/kernel/mosek/semidefinite.py
+++ b/examples/kernel/mosek/semidefinite.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# Source: https://docs.mosek.com/latest/pythonfusion/tutorial-sdo-shared.html#doc-tutorial-sdo
# This examples illustrates SDP formulations in Pyomo using
diff --git a/examples/kernel/objectives.py b/examples/kernel/objectives.py
index 7d87671ef8d..27a41f4edb5 100644
--- a/examples/kernel/objectives.py
+++ b/examples/kernel/objectives.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
v = pmo.variable(value=2)
diff --git a/examples/kernel/parameters.py b/examples/kernel/parameters.py
index 55b230add6b..e9e412525bb 100644
--- a/examples/kernel/parameters.py
+++ b/examples/kernel/parameters.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
#
diff --git a/examples/kernel/piecewise_functions.py b/examples/kernel/piecewise_functions.py
index 528d4c16791..73a7f680725 100644
--- a/examples/kernel/piecewise_functions.py
+++ b/examples/kernel/piecewise_functions.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
#
diff --git a/examples/kernel/piecewise_nd_functions.py b/examples/kernel/piecewise_nd_functions.py
index 847bb5f4a84..7de37fcbfc6 100644
--- a/examples/kernel/piecewise_nd_functions.py
+++ b/examples/kernel/piecewise_nd_functions.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import random
import sys
diff --git a/examples/kernel/special_ordered_sets.py b/examples/kernel/special_ordered_sets.py
index 9526a551c12..abacc3d4205 100644
--- a/examples/kernel/special_ordered_sets.py
+++ b/examples/kernel/special_ordered_sets.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
v1 = pmo.variable()
diff --git a/examples/kernel/suffixes.py b/examples/kernel/suffixes.py
index 39caa5b8652..ae95fbbdd09 100644
--- a/examples/kernel/suffixes.py
+++ b/examples/kernel/suffixes.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
#
diff --git a/examples/kernel/variables.py b/examples/kernel/variables.py
index 7ab571245a1..36865b58183 100644
--- a/examples/kernel/variables.py
+++ b/examples/kernel/variables.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.kernel as pmo
#
diff --git a/examples/mpec/bard1.py b/examples/mpec/bard1.py
index dbe666a7004..59955eefb8e 100644
--- a/examples/mpec/bard1.py
+++ b/examples/mpec/bard1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# bard1.py QQR2-MN-8-5
# Original Pyomo coding by William Hart
# Adapted from AMPL coding by Sven Leyffer
diff --git a/examples/mpec/df.py b/examples/mpec/df.py
index 41984992bdd..7bb25b11e07 100644
--- a/examples/mpec/df.py
+++ b/examples/mpec/df.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/mpec/indexed.py b/examples/mpec/indexed.py
index b69d5093477..0aff5de5b20 100644
--- a/examples/mpec/indexed.py
+++ b/examples/mpec/indexed.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/mpec/linear1.py b/examples/mpec/linear1.py
index eba04759ae3..f24fd357e62 100644
--- a/examples/mpec/linear1.py
+++ b/examples/mpec/linear1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/mpec/munson1.py b/examples/mpec/munson1.py
index debdf709db9..99c240b5c06 100644
--- a/examples/mpec/munson1.py
+++ b/examples/mpec/munson1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/mpec/munson1a.py b/examples/mpec/munson1a.py
index 519db4e6ec2..67f8f318531 100644
--- a/examples/mpec/munson1a.py
+++ b/examples/mpec/munson1a.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/mpec/munson1b.py b/examples/mpec/munson1b.py
index ff2b7b51294..46fff90a785 100644
--- a/examples/mpec/munson1b.py
+++ b/examples/mpec/munson1b.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/mpec/munson1c.py b/examples/mpec/munson1c.py
index 2592b25c515..dee5b224e75 100644
--- a/examples/mpec/munson1c.py
+++ b/examples/mpec/munson1c.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/mpec/munson1d.py b/examples/mpec/munson1d.py
index 0fb08ce73fb..157177f2eb0 100644
--- a/examples/mpec/munson1d.py
+++ b/examples/mpec/munson1d.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/mpec/scholtes4.py b/examples/mpec/scholtes4.py
index 904729780cf..8d574dd1916 100644
--- a/examples/mpec/scholtes4.py
+++ b/examples/mpec/scholtes4.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# scholtes4.py LQR2-MN-3-2
# Original Pyomo coding by William Hart
# Adapted from AMPL coding by Sven Leyffer
diff --git a/examples/performance/dae/run_stochpdegas1_automatic.py b/examples/performance/dae/run_stochpdegas1_automatic.py
index 993e22c7c86..fffa1a71ae1 100644
--- a/examples/performance/dae/run_stochpdegas1_automatic.py
+++ b/examples/performance/dae/run_stochpdegas1_automatic.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import time
from pyomo.environ import *
diff --git a/examples/performance/dae/stochpdegas1_automatic.py b/examples/performance/dae/stochpdegas1_automatic.py
index 905ec9a5330..ce6132e6cf5 100644
--- a/examples/performance/dae/stochpdegas1_automatic.py
+++ b/examples/performance/dae/stochpdegas1_automatic.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# stochastic pde model for natural gas network
# victor m. zavala / 2013
diff --git a/examples/performance/jump/clnlbeam.py b/examples/performance/jump/clnlbeam.py
index d2ceda790ec..410068a6753 100644
--- a/examples/performance/jump/clnlbeam.py
+++ b/examples/performance/jump/clnlbeam.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/examples/performance/jump/facility.py b/examples/performance/jump/facility.py
index 6832e8d32ac..fa0c306d6e5 100644
--- a/examples/performance/jump/facility.py
+++ b/examples/performance/jump/facility.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
model = AbstractModel()
diff --git a/examples/performance/jump/lqcp.py b/examples/performance/jump/lqcp.py
index bb3e66b36f5..b8ef096d7be 100644
--- a/examples/performance/jump/lqcp.py
+++ b/examples/performance/jump/lqcp.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.core import *
model = ConcreteModel()
diff --git a/examples/performance/jump/opf_66200bus.py b/examples/performance/jump/opf_66200bus.py
index f3e1822fbfb..702ff59a61c 100644
--- a/examples/performance/jump/opf_66200bus.py
+++ b/examples/performance/jump/opf_66200bus.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/jump/opf_6620bus.py b/examples/performance/jump/opf_6620bus.py
index 64348ae931e..34b910f43c0 100644
--- a/examples/performance/jump/opf_6620bus.py
+++ b/examples/performance/jump/opf_6620bus.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/jump/opf_662bus.py b/examples/performance/jump/opf_662bus.py
index 6ff97c577e3..8a768ca16e0 100644
--- a/examples/performance/jump/opf_662bus.py
+++ b/examples/performance/jump/opf_662bus.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/bilinear1_100.py b/examples/performance/misc/bilinear1_100.py
index e68fbba6283..d86091c4c76 100644
--- a/examples/performance/misc/bilinear1_100.py
+++ b/examples/performance/misc/bilinear1_100.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/bilinear1_100000.py b/examples/performance/misc/bilinear1_100000.py
index 924d7233d24..0fa2eafedc6 100644
--- a/examples/performance/misc/bilinear1_100000.py
+++ b/examples/performance/misc/bilinear1_100000.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/bilinear2_100.py b/examples/performance/misc/bilinear2_100.py
index 4dd9f9ead57..227bfe000e0 100644
--- a/examples/performance/misc/bilinear2_100.py
+++ b/examples/performance/misc/bilinear2_100.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/bilinear2_100000.py b/examples/performance/misc/bilinear2_100000.py
index 90eeaf82271..9d2a4d6fb7c 100644
--- a/examples/performance/misc/bilinear2_100000.py
+++ b/examples/performance/misc/bilinear2_100000.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/diag1_100.py b/examples/performance/misc/diag1_100.py
index e47a9179974..369d81982f0 100644
--- a/examples/performance/misc/diag1_100.py
+++ b/examples/performance/misc/diag1_100.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/diag1_100000.py b/examples/performance/misc/diag1_100000.py
index a110c0d9d67..536758fda5d 100644
--- a/examples/performance/misc/diag1_100000.py
+++ b/examples/performance/misc/diag1_100000.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/diag2_100.py b/examples/performance/misc/diag2_100.py
index fe820e8590b..6ad47528ff2 100644
--- a/examples/performance/misc/diag2_100.py
+++ b/examples/performance/misc/diag2_100.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/diag2_100000.py b/examples/performance/misc/diag2_100000.py
index 38563de57b9..b95e2dd1d6f 100644
--- a/examples/performance/misc/diag2_100000.py
+++ b/examples/performance/misc/diag2_100000.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
diff --git a/examples/performance/misc/set1.py b/examples/performance/misc/set1.py
index 53227a3ee73..8a8b84fdcc3 100644
--- a/examples/performance/misc/set1.py
+++ b/examples/performance/misc/set1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
model = ConcreteModel()
diff --git a/examples/performance/misc/sparse1.py b/examples/performance/misc/sparse1.py
index 264862760f9..b4883d379bc 100644
--- a/examples/performance/misc/sparse1.py
+++ b/examples/performance/misc/sparse1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#
# This is a performance test that we cannot easily execute right now
#
diff --git a/examples/performance/pmedian/pmedian1.py b/examples/performance/pmedian/pmedian1.py
index 3d3f6c5407f..a22540efdd5 100644
--- a/examples/performance/pmedian/pmedian1.py
+++ b/examples/performance/pmedian/pmedian1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/performance/pmedian/pmedian2.py b/examples/performance/pmedian/pmedian2.py
index 434ded6dcbc..ff25a6c15eb 100644
--- a/examples/performance/pmedian/pmedian2.py
+++ b/examples/performance/pmedian/pmedian2.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/amplbook2/diet.py b/examples/pyomo/amplbook2/diet.py
index 8cdffefa20f..cc52eacae20 100644
--- a/examples/pyomo/amplbook2/diet.py
+++ b/examples/pyomo/amplbook2/diet.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/amplbook2/dieti.py b/examples/pyomo/amplbook2/dieti.py
index 0934dcf83c6..45d403dd810 100644
--- a/examples/pyomo/amplbook2/dieti.py
+++ b/examples/pyomo/amplbook2/dieti.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/amplbook2/econ2min.py b/examples/pyomo/amplbook2/econ2min.py
index 0d27df780bb..fb870e02364 100644
--- a/examples/pyomo/amplbook2/econ2min.py
+++ b/examples/pyomo/amplbook2/econ2min.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/amplbook2/econmin.py b/examples/pyomo/amplbook2/econmin.py
index 84e41107ff2..d9c95758d4d 100644
--- a/examples/pyomo/amplbook2/econmin.py
+++ b/examples/pyomo/amplbook2/econmin.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/amplbook2/prod.py b/examples/pyomo/amplbook2/prod.py
index 74e456e013f..236f7254b29 100644
--- a/examples/pyomo/amplbook2/prod.py
+++ b/examples/pyomo/amplbook2/prod.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/amplbook2/steel.py b/examples/pyomo/amplbook2/steel.py
index 43bea775526..8c5c9b2a1d3 100644
--- a/examples/pyomo/amplbook2/steel.py
+++ b/examples/pyomo/amplbook2/steel.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/amplbook2/steel3.py b/examples/pyomo/amplbook2/steel3.py
index e9e494b6a1a..dd3b3ac202f 100644
--- a/examples/pyomo/amplbook2/steel3.py
+++ b/examples/pyomo/amplbook2/steel3.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/amplbook2/steel4.py b/examples/pyomo/amplbook2/steel4.py
index b6709e478e9..10cb0979d24 100644
--- a/examples/pyomo/amplbook2/steel4.py
+++ b/examples/pyomo/amplbook2/steel4.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/benders/master.py b/examples/pyomo/benders/master.py
index a457bf28b06..372810dc024 100644
--- a/examples/pyomo/benders/master.py
+++ b/examples/pyomo/benders/master.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/benders/subproblem.py b/examples/pyomo/benders/subproblem.py
index 886f71ff321..ae46dad2d41 100644
--- a/examples/pyomo/benders/subproblem.py
+++ b/examples/pyomo/benders/subproblem.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/callbacks/sc.py b/examples/pyomo/callbacks/sc.py
index ce32b0a1074..0882815c6b7 100644
--- a/examples/pyomo/callbacks/sc.py
+++ b/examples/pyomo/callbacks/sc.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/callbacks/sc_callback.py b/examples/pyomo/callbacks/sc_callback.py
index 0dae9e1befc..cacc438b380 100644
--- a/examples/pyomo/callbacks/sc_callback.py
+++ b/examples/pyomo/callbacks/sc_callback.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/callbacks/sc_script.py b/examples/pyomo/callbacks/sc_script.py
index 8e4ade21b51..d3044e4d667 100644
--- a/examples/pyomo/callbacks/sc_script.py
+++ b/examples/pyomo/callbacks/sc_script.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/callbacks/scalability/run.py b/examples/pyomo/callbacks/scalability/run.py
index 8465e3f5019..cf95076fcc3 100644
--- a/examples/pyomo/callbacks/scalability/run.py
+++ b/examples/pyomo/callbacks/scalability/run.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/callbacks/tsp.py b/examples/pyomo/callbacks/tsp.py
index d3e28a98d3f..8526a540b66 100644
--- a/examples/pyomo/callbacks/tsp.py
+++ b/examples/pyomo/callbacks/tsp.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/columngeneration/cutting_stock.py b/examples/pyomo/columngeneration/cutting_stock.py
index 58df6a5ad16..2d9399c7db4 100644
--- a/examples/pyomo/columngeneration/cutting_stock.py
+++ b/examples/pyomo/columngeneration/cutting_stock.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/concrete/Whiskas.py b/examples/pyomo/concrete/Whiskas.py
index 9bc8dd87e9d..3d3c19e94ac 100644
--- a/examples/pyomo/concrete/Whiskas.py
+++ b/examples/pyomo/concrete/Whiskas.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/concrete/knapsack-abstract.py b/examples/pyomo/concrete/knapsack-abstract.py
index bbef95f7810..9766d902722 100644
--- a/examples/pyomo/concrete/knapsack-abstract.py
+++ b/examples/pyomo/concrete/knapsack-abstract.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/concrete/knapsack-concrete.py b/examples/pyomo/concrete/knapsack-concrete.py
index cd115ab40a3..8966d0b8498 100644
--- a/examples/pyomo/concrete/knapsack-concrete.py
+++ b/examples/pyomo/concrete/knapsack-concrete.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/concrete/rosen.py b/examples/pyomo/concrete/rosen.py
index a8e8a175127..ae51ae50ac0 100644
--- a/examples/pyomo/concrete/rosen.py
+++ b/examples/pyomo/concrete/rosen.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# rosen.py
from pyomo.environ import *
diff --git a/examples/pyomo/concrete/sodacan.py b/examples/pyomo/concrete/sodacan.py
index 3c0cfd3aab2..5429b27a9d5 100644
--- a/examples/pyomo/concrete/sodacan.py
+++ b/examples/pyomo/concrete/sodacan.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# sodacan.py
from pyomo.environ import *
from math import pi
diff --git a/examples/pyomo/concrete/sodacan_fig.py b/examples/pyomo/concrete/sodacan_fig.py
index bf9ae476b4c..b263eaf558d 100644
--- a/examples/pyomo/concrete/sodacan_fig.py
+++ b/examples/pyomo/concrete/sodacan_fig.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
diff --git a/examples/pyomo/concrete/sp.py b/examples/pyomo/concrete/sp.py
index edc2d68b170..e82a4bca0a9 100644
--- a/examples/pyomo/concrete/sp.py
+++ b/examples/pyomo/concrete/sp.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# sp.py
from pyomo.environ import *
from sp_data import * # define c, b, h, and d
diff --git a/examples/pyomo/concrete/sp_data.py b/examples/pyomo/concrete/sp_data.py
index 58210126819..4453a10cead 100644
--- a/examples/pyomo/concrete/sp_data.py
+++ b/examples/pyomo/concrete/sp_data.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
c = 1.0
b = 1.5
h = 0.1
diff --git a/examples/pyomo/connectors/network_flow.py b/examples/pyomo/connectors/network_flow.py
index cb75ca7ecf2..d5587fdf4c8 100644
--- a/examples/pyomo/connectors/network_flow.py
+++ b/examples/pyomo/connectors/network_flow.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/connectors/network_flow_proposed.py b/examples/pyomo/connectors/network_flow_proposed.py
index ed603ff6626..f234f2decf4 100644
--- a/examples/pyomo/connectors/network_flow_proposed.py
+++ b/examples/pyomo/connectors/network_flow_proposed.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/core/block1.py b/examples/pyomo/core/block1.py
index 96f8114f19c..161fc2ca2f7 100644
--- a/examples/pyomo/core/block1.py
+++ b/examples/pyomo/core/block1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/core/integrality1.py b/examples/pyomo/core/integrality1.py
index db81805555f..0ab3a433dac 100644
--- a/examples/pyomo/core/integrality1.py
+++ b/examples/pyomo/core/integrality1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/core/integrality2.py b/examples/pyomo/core/integrality2.py
index 2d85c9f2455..6461d36f923 100644
--- a/examples/pyomo/core/integrality2.py
+++ b/examples/pyomo/core/integrality2.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/core/simple.py b/examples/pyomo/core/simple.py
index d0359c143bf..6976f3d25ad 100644
--- a/examples/pyomo/core/simple.py
+++ b/examples/pyomo/core/simple.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/core/t1.py b/examples/pyomo/core/t1.py
index 4135049d4be..5d5416985a9 100644
--- a/examples/pyomo/core/t1.py
+++ b/examples/pyomo/core/t1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/core/t2.py b/examples/pyomo/core/t2.py
index 5d687917fba..4d3f1934cbe 100644
--- a/examples/pyomo/core/t2.py
+++ b/examples/pyomo/core/t2.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/core/t5.py b/examples/pyomo/core/t5.py
index 38605751015..6b9d94e0ff1 100644
--- a/examples/pyomo/core/t5.py
+++ b/examples/pyomo/core/t5.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/diet/diet-sqlite.py b/examples/pyomo/diet/diet-sqlite.py
index e8963485294..dccd3c338d0 100644
--- a/examples/pyomo/diet/diet-sqlite.py
+++ b/examples/pyomo/diet/diet-sqlite.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/diet/diet1.py b/examples/pyomo/diet/diet1.py
index 1fd61ca268c..217f80b9c25 100644
--- a/examples/pyomo/diet/diet1.py
+++ b/examples/pyomo/diet/diet1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/diet/diet2.py b/examples/pyomo/diet/diet2.py
index 526dbcef484..291261b0901 100644
--- a/examples/pyomo/diet/diet2.py
+++ b/examples/pyomo/diet/diet2.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/draft/api.py b/examples/pyomo/draft/api.py
index 5b506882d9b..d785f41935e 100644
--- a/examples/pyomo/draft/api.py
+++ b/examples/pyomo/draft/api.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/draft/bpack.py b/examples/pyomo/draft/bpack.py
index 697ce531013..7b076f7737b 100644
--- a/examples/pyomo/draft/bpack.py
+++ b/examples/pyomo/draft/bpack.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/draft/diet2.py b/examples/pyomo/draft/diet2.py
index 9e4d2c5d9c4..d23fa3cf5db 100644
--- a/examples/pyomo/draft/diet2.py
+++ b/examples/pyomo/draft/diet2.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/p-median/decorated_pmedian.py b/examples/pyomo/p-median/decorated_pmedian.py
index 90345daf78d..c66971945f3 100644
--- a/examples/pyomo/p-median/decorated_pmedian.py
+++ b/examples/pyomo/p-median/decorated_pmedian.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.environ import *
import random
diff --git a/examples/pyomo/p-median/pmedian.py b/examples/pyomo/p-median/pmedian.py
index 88731f287d8..865aa7cb61f 100644
--- a/examples/pyomo/p-median/pmedian.py
+++ b/examples/pyomo/p-median/pmedian.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/p-median/solver1.py b/examples/pyomo/p-median/solver1.py
index 113bf9fdd29..2652ab13943 100644
--- a/examples/pyomo/p-median/solver1.py
+++ b/examples/pyomo/p-median/solver1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/p-median/solver2.py b/examples/pyomo/p-median/solver2.py
index c62f161fd24..50ec5388811 100644
--- a/examples/pyomo/p-median/solver2.py
+++ b/examples/pyomo/p-median/solver2.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/piecewise/convex.py b/examples/pyomo/piecewise/convex.py
index a3233ae5c3e..fb8095f80e3 100644
--- a/examples/pyomo/piecewise/convex.py
+++ b/examples/pyomo/piecewise/convex.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/piecewise/indexed.py b/examples/pyomo/piecewise/indexed.py
index dea56df3911..cde21ec847e 100644
--- a/examples/pyomo/piecewise/indexed.py
+++ b/examples/pyomo/piecewise/indexed.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/piecewise/indexed_nonlinear.py b/examples/pyomo/piecewise/indexed_nonlinear.py
index e871508d1be..d72fbc8a899 100644
--- a/examples/pyomo/piecewise/indexed_nonlinear.py
+++ b/examples/pyomo/piecewise/indexed_nonlinear.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/piecewise/indexed_points.py b/examples/pyomo/piecewise/indexed_points.py
index 15b1c33a7ec..66110bea342 100644
--- a/examples/pyomo/piecewise/indexed_points.py
+++ b/examples/pyomo/piecewise/indexed_points.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/piecewise/nonconvex.py b/examples/pyomo/piecewise/nonconvex.py
index 004748ab2eb..5300278d5b9 100644
--- a/examples/pyomo/piecewise/nonconvex.py
+++ b/examples/pyomo/piecewise/nonconvex.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/piecewise/points.py b/examples/pyomo/piecewise/points.py
index c822ceb5860..91d45684c4f 100644
--- a/examples/pyomo/piecewise/points.py
+++ b/examples/pyomo/piecewise/points.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/piecewise/step.py b/examples/pyomo/piecewise/step.py
index c3fbb4762ab..95aac74d7f7 100644
--- a/examples/pyomo/piecewise/step.py
+++ b/examples/pyomo/piecewise/step.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/quadratic/example1.py b/examples/pyomo/quadratic/example1.py
index dff911a0f0c..ab77c5a1733 100644
--- a/examples/pyomo/quadratic/example1.py
+++ b/examples/pyomo/quadratic/example1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/quadratic/example2.py b/examples/pyomo/quadratic/example2.py
index 981f2ef0bfb..ce02c6f70c8 100644
--- a/examples/pyomo/quadratic/example2.py
+++ b/examples/pyomo/quadratic/example2.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/quadratic/example3.py b/examples/pyomo/quadratic/example3.py
index 4d96afe3328..bdba936f694 100644
--- a/examples/pyomo/quadratic/example3.py
+++ b/examples/pyomo/quadratic/example3.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/quadratic/example4.py b/examples/pyomo/quadratic/example4.py
index 256fc862a16..ecfc9981162 100644
--- a/examples/pyomo/quadratic/example4.py
+++ b/examples/pyomo/quadratic/example4.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/radertext/Ex2_1.py b/examples/pyomo/radertext/Ex2_1.py
index d352325798a..981388d4c72 100644
--- a/examples/pyomo/radertext/Ex2_1.py
+++ b/examples/pyomo/radertext/Ex2_1.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/radertext/Ex2_2.py b/examples/pyomo/radertext/Ex2_2.py
index 13c23dd1816..41b56e52669 100644
--- a/examples/pyomo/radertext/Ex2_2.py
+++ b/examples/pyomo/radertext/Ex2_2.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/radertext/Ex2_3.py b/examples/pyomo/radertext/Ex2_3.py
index d4dc3109ea1..7dc39afa773 100644
--- a/examples/pyomo/radertext/Ex2_3.py
+++ b/examples/pyomo/radertext/Ex2_3.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/radertext/Ex2_5.py b/examples/pyomo/radertext/Ex2_5.py
index da90b473b1f..fee49b46cb0 100644
--- a/examples/pyomo/radertext/Ex2_5.py
+++ b/examples/pyomo/radertext/Ex2_5.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/radertext/Ex2_6a.py b/examples/pyomo/radertext/Ex2_6a.py
index dc33a9b64e2..24bb866ec51 100644
--- a/examples/pyomo/radertext/Ex2_6a.py
+++ b/examples/pyomo/radertext/Ex2_6a.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/radertext/Ex2_6b.py b/examples/pyomo/radertext/Ex2_6b.py
index 8049d4ebb05..1be55461b9e 100644
--- a/examples/pyomo/radertext/Ex2_6b.py
+++ b/examples/pyomo/radertext/Ex2_6b.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/sos/DepotSiting.py b/examples/pyomo/sos/DepotSiting.py
index 98697681f44..40826e989b7 100644
--- a/examples/pyomo/sos/DepotSiting.py
+++ b/examples/pyomo/sos/DepotSiting.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/sos/basic_sos2_example.py b/examples/pyomo/sos/basic_sos2_example.py
index 655169ffe54..3aa0887356c 100644
--- a/examples/pyomo/sos/basic_sos2_example.py
+++ b/examples/pyomo/sos/basic_sos2_example.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/sos/sos2_piecewise.py b/examples/pyomo/sos/sos2_piecewise.py
index 4e79ce2ee62..79195761f3d 100644
--- a/examples/pyomo/sos/sos2_piecewise.py
+++ b/examples/pyomo/sos/sos2_piecewise.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/duals_pyomo.py b/examples/pyomo/suffixes/duals_pyomo.py
index 9743add3ddd..6ce88fde429 100644
--- a/examples/pyomo/suffixes/duals_pyomo.py
+++ b/examples/pyomo/suffixes/duals_pyomo.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/duals_script.py b/examples/pyomo/suffixes/duals_script.py
index a9db615cad3..e8ef9aef1bc 100644
--- a/examples/pyomo/suffixes/duals_script.py
+++ b/examples/pyomo/suffixes/duals_script.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/gurobi_ampl_basis.py b/examples/pyomo/suffixes/gurobi_ampl_basis.py
index cd8e4e8f129..eab86f8aa47 100644
--- a/examples/pyomo/suffixes/gurobi_ampl_basis.py
+++ b/examples/pyomo/suffixes/gurobi_ampl_basis.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/gurobi_ampl_example.py b/examples/pyomo/suffixes/gurobi_ampl_example.py
index d133fa422dc..4f3364c09dc 100644
--- a/examples/pyomo/suffixes/gurobi_ampl_example.py
+++ b/examples/pyomo/suffixes/gurobi_ampl_example.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/gurobi_ampl_iis.py b/examples/pyomo/suffixes/gurobi_ampl_iis.py
index ccba226db78..da5bad073e7 100644
--- a/examples/pyomo/suffixes/gurobi_ampl_iis.py
+++ b/examples/pyomo/suffixes/gurobi_ampl_iis.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/ipopt_scaling.py b/examples/pyomo/suffixes/ipopt_scaling.py
index c192a98dd98..7113128c21d 100644
--- a/examples/pyomo/suffixes/ipopt_scaling.py
+++ b/examples/pyomo/suffixes/ipopt_scaling.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/ipopt_warmstart.py b/examples/pyomo/suffixes/ipopt_warmstart.py
index 6975bbaaa62..4882c48c8c8 100644
--- a/examples/pyomo/suffixes/ipopt_warmstart.py
+++ b/examples/pyomo/suffixes/ipopt_warmstart.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/sipopt_hicks.py b/examples/pyomo/suffixes/sipopt_hicks.py
index dbf4e07b8f7..c7e058d5907 100644
--- a/examples/pyomo/suffixes/sipopt_hicks.py
+++ b/examples/pyomo/suffixes/sipopt_hicks.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/suffixes/sipopt_parametric.py b/examples/pyomo/suffixes/sipopt_parametric.py
index 29bba934bd8..0cb1c35f441 100644
--- a/examples/pyomo/suffixes/sipopt_parametric.py
+++ b/examples/pyomo/suffixes/sipopt_parametric.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/transform/scaling_ex.py b/examples/pyomo/transform/scaling_ex.py
index a5960393e75..34f937cbb45 100644
--- a/examples/pyomo/transform/scaling_ex.py
+++ b/examples/pyomo/transform/scaling_ex.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/tutorials/data.out b/examples/pyomo/tutorials/data.out
index d1353f87858..7dce6012e2f 100644
--- a/examples/pyomo/tutorials/data.out
+++ b/examples/pyomo/tutorials/data.out
@@ -1,4 +1,4 @@
-20 Set Declarations
+14 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
@@ -9,30 +9,18 @@
Key : Dimen : Domain : Size : Members
None : 2 : A*B : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
D : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 2 : D_domain : 3 : {('A1', 1), ('A2', 2), ('A3', 3)}
- D_domain : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
+ None : 2 : A*B : 3 : {('A1', 1), ('A2', 2), ('A3', 3)}
E : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 3 : E_domain : 6 : {('A1', 1, 'A1'), ('A1', 1, 'A2'), ('A2', 2, 'A2'), ('A2', 2, 'A3'), ('A3', 3, 'A1'), ('A3', 3, 'A3')}
- E_domain : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 3 : E_domain_index_0*A : 27 : {('A1', 1, 'A1'), ('A1', 1, 'A2'), ('A1', 1, 'A3'), ('A1', 2, 'A1'), ('A1', 2, 'A2'), ('A1', 2, 'A3'), ('A1', 3, 'A1'), ('A1', 3, 'A2'), ('A1', 3, 'A3'), ('A2', 1, 'A1'), ('A2', 1, 'A2'), ('A2', 1, 'A3'), ('A2', 2, 'A1'), ('A2', 2, 'A2'), ('A2', 2, 'A3'), ('A2', 3, 'A1'), ('A2', 3, 'A2'), ('A2', 3, 'A3'), ('A3', 1, 'A1'), ('A3', 1, 'A2'), ('A3', 1, 'A3'), ('A3', 2, 'A1'), ('A3', 2, 'A2'), ('A3', 2, 'A3'), ('A3', 3, 'A1'), ('A3', 3, 'A2'), ('A3', 3, 'A3')}
- E_domain_index_0 : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
+ None : 3 : A*B*A : 6 : {('A1', 1, 'A1'), ('A1', 1, 'A2'), ('A2', 2, 'A2'), ('A2', 2, 'A3'), ('A3', 3, 'A1'), ('A3', 3, 'A3')}
F : Size=3, Index=A, Ordered=Insertion
Key : Dimen : Domain : Size : Members
A1 : 1 : Any : 3 : {1, 3, 5}
A2 : 1 : Any : 3 : {2, 4, 6}
A3 : 1 : Any : 3 : {3, 5, 7}
- G : Size=0, Index=G_index, Ordered=Insertion
+ G : Size=0, Index=A*B, Ordered=Insertion
Key : Dimen : Domain : Size : Members
- G_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
H : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'H1', 'H2', 'H3'}
@@ -45,12 +33,6 @@
K : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
- T_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*I : 12 : {('A1', 'I1'), ('A1', 'I2'), ('A1', 'I3'), ('A1', 'I4'), ('A2', 'I1'), ('A2', 'I2'), ('A2', 'I3'), ('A2', 'I4'), ('A3', 'I1'), ('A3', 'I2'), ('A3', 'I3'), ('A3', 'I4')}
- U_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : I*A : 12 : {('I1', 'A1'), ('I1', 'A2'), ('I1', 'A3'), ('I2', 'A1'), ('I2', 'A2'), ('I2', 'A3'), ('I3', 'A1'), ('I3', 'A2'), ('I3', 'A3'), ('I4', 'A1'), ('I4', 'A2'), ('I4', 'A3')}
x : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
@@ -116,7 +98,7 @@
Key : Value
A1 : 3.3
A3 : 3.5
- T : Size=12, Index=T_index, Domain=Any, Default=None, Mutable=False
+ T : Size=12, Index=A*I, Domain=Any, Default=None, Mutable=False
Key : Value
('A1', 'I1') : 1.3
('A1', 'I2') : 1.4
@@ -130,7 +112,7 @@
('A3', 'I2') : 3.4
('A3', 'I3') : 3.5
('A3', 'I4') : 3.6
- U : Size=12, Index=U_index, Domain=Any, Default=None, Mutable=False
+ U : Size=12, Index=I*A, Domain=Any, Default=None, Mutable=False
Key : Value
('I1', 'A1') : 1.3
('I1', 'A2') : 2.3
@@ -166,4 +148,4 @@
Key : Value
None : 2
-38 Declarations: A B C D_domain D E_domain_index_0 E_domain E F G_index G H I J K Z ZZ Y X W U_index U T_index T S R Q P PP O z y x M N MM MMM NNN
+32 Declarations: A B C D E F G H I J K Z ZZ Y X W U T S R Q P PP O z y x M N MM MMM NNN
diff --git a/examples/pyomo/tutorials/data.py b/examples/pyomo/tutorials/data.py
index d065c9ff9bc..ea2569af934 100644
--- a/examples/pyomo/tutorials/data.py
+++ b/examples/pyomo/tutorials/data.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/tutorials/excel.out b/examples/pyomo/tutorials/excel.out
index 5064d4fa511..5e30827f7ae 100644
--- a/examples/pyomo/tutorials/excel.out
+++ b/examples/pyomo/tutorials/excel.out
@@ -1,4 +1,4 @@
-16 Set Declarations
+10 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
@@ -9,27 +9,15 @@
Key : Dimen : Domain : Size : Members
None : 2 : A*B : 9 : {('A1', 1.0), ('A1', 2.0), ('A1', 3.0), ('A2', 1.0), ('A2', 2.0), ('A2', 3.0), ('A3', 1.0), ('A3', 2.0), ('A3', 3.0)}
D : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 2 : D_domain : 3 : {('A1', 1.0), ('A2', 2.0), ('A3', 3.0)}
- D_domain : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1.0), ('A1', 2.0), ('A1', 3.0), ('A2', 1.0), ('A2', 2.0), ('A2', 3.0), ('A3', 1.0), ('A3', 2.0), ('A3', 3.0)}
+ None : 2 : A*B : 3 : {('A1', 1.0), ('A2', 2.0), ('A3', 3.0)}
E : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 3 : E_domain : 6 : {('A1', 1.0, 'A1'), ('A1', 1.0, 'A2'), ('A2', 2.0, 'A2'), ('A2', 2.0, 'A3'), ('A3', 3.0, 'A1'), ('A3', 3.0, 'A3')}
- E_domain : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 3 : E_domain_index_0*A : 27 : {('A1', 1.0, 'A1'), ('A1', 1.0, 'A2'), ('A1', 1.0, 'A3'), ('A1', 2.0, 'A1'), ('A1', 2.0, 'A2'), ('A1', 2.0, 'A3'), ('A1', 3.0, 'A1'), ('A1', 3.0, 'A2'), ('A1', 3.0, 'A3'), ('A2', 1.0, 'A1'), ('A2', 1.0, 'A2'), ('A2', 1.0, 'A3'), ('A2', 2.0, 'A1'), ('A2', 2.0, 'A2'), ('A2', 2.0, 'A3'), ('A2', 3.0, 'A1'), ('A2', 3.0, 'A2'), ('A2', 3.0, 'A3'), ('A3', 1.0, 'A1'), ('A3', 1.0, 'A2'), ('A3', 1.0, 'A3'), ('A3', 2.0, 'A1'), ('A3', 2.0, 'A2'), ('A3', 2.0, 'A3'), ('A3', 3.0, 'A1'), ('A3', 3.0, 'A2'), ('A3', 3.0, 'A3')}
- E_domain_index_0 : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1.0), ('A1', 2.0), ('A1', 3.0), ('A2', 1.0), ('A2', 2.0), ('A2', 3.0), ('A3', 1.0), ('A3', 2.0), ('A3', 3.0)}
+ None : 3 : A*B : 6 : {('A1', 1.0, 'A1'), ('A1', 1.0, 'A2'), ('A2', 2.0, 'A2'), ('A2', 2.0, 'A3'), ('A3', 3.0, 'A1'), ('A3', 3.0, 'A3')}
F : Size=0, Index=A, Ordered=Insertion
Key : Dimen : Domain : Size : Members
- G : Size=0, Index=G_index, Ordered=Insertion
+ G : Size=0, Index=A*B, Ordered=Insertion
Key : Dimen : Domain : Size : Members
- G_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1.0), ('A1', 2.0), ('A1', 3.0), ('A2', 1.0), ('A2', 2.0), ('A2', 3.0), ('A3', 1.0), ('A3', 2.0), ('A3', 3.0)}
H : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'H1', 'H2', 'H3'}
@@ -39,12 +27,6 @@
J : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
- T_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*I : 12 : {('A1', 'I1'), ('A1', 'I2'), ('A1', 'I3'), ('A1', 'I4'), ('A2', 'I1'), ('A2', 'I2'), ('A2', 'I3'), ('A2', 'I4'), ('A3', 'I1'), ('A3', 'I2'), ('A3', 'I3'), ('A3', 'I4')}
- U_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : I*A : 12 : {('I1', 'A1'), ('I1', 'A2'), ('I1', 'A3'), ('I2', 'A1'), ('I2', 'A2'), ('I2', 'A3'), ('I3', 'A1'), ('I3', 'A2'), ('I3', 'A3'), ('I4', 'A1'), ('I4', 'A2'), ('I4', 'A3')}
12 Param Declarations
O : Size=3, Index=J, Domain=Reals, Default=None, Mutable=False
@@ -76,7 +58,7 @@
Key : Value
A1 : 3.3
A3 : 3.5
- T : Size=12, Index=T_index, Domain=Any, Default=None, Mutable=False
+ T : Size=12, Index=A*I, Domain=Any, Default=None, Mutable=False
Key : Value
('A1', 'I1') : 1.3
('A1', 'I2') : 1.4
@@ -90,7 +72,7 @@
('A3', 'I2') : 3.4
('A3', 'I3') : 3.5
('A3', 'I4') : 3.6
- U : Size=12, Index=U_index, Domain=Any, Default=None, Mutable=False
+ U : Size=12, Index=I*A, Domain=Any, Default=None, Mutable=False
Key : Value
('I1', 'A1') : 1.3
('I1', 'A2') : 2.3
@@ -123,4 +105,4 @@
Key : Value
None : 1.01
-28 Declarations: A B C D_domain D E_domain_index_0 E_domain E F G_index G H I J Z Y X W U_index U T_index T S R Q P PP O
+22 Declarations: A B C D E F G H I J Z Y X W U T S R Q P PP O
diff --git a/examples/pyomo/tutorials/excel.py b/examples/pyomo/tutorials/excel.py
index 127db722c07..f9a5f66826b 100644
--- a/examples/pyomo/tutorials/excel.py
+++ b/examples/pyomo/tutorials/excel.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/tutorials/param.out b/examples/pyomo/tutorials/param.out
index 57e6a752ea5..ea258f5b493 100644
--- a/examples/pyomo/tutorials/param.out
+++ b/examples/pyomo/tutorials/param.out
@@ -1,22 +1,13 @@
-5 Set Declarations
+2 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 4 : {2, 4, 6, 8}
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {1, 2, 3}
- R_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 12 : {(2, 1), (2, 2), (2, 3), (4, 1), (4, 2), (4, 3), (6, 1), (6, 2), (6, 3), (8, 1), (8, 2), (8, 3)}
- W_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 12 : {(2, 1), (2, 2), (2, 3), (4, 1), (4, 2), (4, 3), (6, 1), (6, 2), (6, 3), (8, 1), (8, 2), (8, 3)}
- X_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 12 : {(2, 1), (2, 2), (2, 3), (4, 1), (4, 2), (4, 3), (6, 1), (6, 2), (6, 3), (8, 1), (8, 2), (8, 3)}
9 Param Declarations
- R : Size=12, Index=R_index, Domain=Any, Default=99.0, Mutable=False
+ R : Size=12, Index=A*B, Domain=Any, Default=99.0, Mutable=False
Key : Value
(2, 1) : 1
(2, 2) : 1
@@ -35,7 +26,7 @@
1 : 1
2 : 2
3 : 9
- W : Size=12, Index=W_index, Domain=Any, Default=None, Mutable=False
+ W : Size=12, Index=A*B, Domain=Any, Default=None, Mutable=False
Key : Value
(2, 1) : 2
(2, 2) : 4
@@ -49,7 +40,7 @@
(8, 1) : 8
(8, 2) : 16
(8, 3) : 24
- X : Size=12, Index=X_index, Domain=Any, Default=None, Mutable=False
+ X : Size=12, Index=A*B, Domain=Any, Default=None, Mutable=False
Key : Value
(2, 1) : 1.3
(2, 2) : 1.4
@@ -73,4 +64,4 @@
Key : Value
None : 1.1
-14 Declarations: A B Z Y X_index X W_index W V U T S R_index R
+11 Declarations: A B Z Y X W V U T S R
diff --git a/examples/pyomo/tutorials/param.py b/examples/pyomo/tutorials/param.py
index ba31975ab4b..5a94bafaa5e 100644
--- a/examples/pyomo/tutorials/param.py
+++ b/examples/pyomo/tutorials/param.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomo/tutorials/set.dat b/examples/pyomo/tutorials/set.dat
index ab0d00b43cc..e2ad04122d8 100644
--- a/examples/pyomo/tutorials/set.dat
+++ b/examples/pyomo/tutorials/set.dat
@@ -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;
\ No newline at end of file
diff --git a/examples/pyomo/tutorials/set.out b/examples/pyomo/tutorials/set.out
index b01b666c012..dd1ef2d4335 100644
--- a/examples/pyomo/tutorials/set.out
+++ b/examples/pyomo/tutorials/set.out
@@ -1,15 +1,12 @@
-28 Set Declarations
+24 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {1, 2, 3}
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 4 : {2, 3, 4, 5}
- C : Size=0, Index=C_index, Ordered=Insertion
+ C : Size=0, Index=A*B, Ordered=Insertion
Key : Dimen : Domain : Size : Members
- C_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 12 : {(1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 2), (3, 3), (3, 4), (3, 5)}
D : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
None : 1 : A | B : 5 : {1, 2, 3, 4, 5}
@@ -26,15 +23,9 @@
Key : Dimen : Domain : Size : Members
None : 2 : A*B : 12 : {(1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 2), (3, 3), (3, 4), (3, 5)}
Hsub : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 2 : Hsub_domain : 3 : {(1, 2), (1, 3), (3, 3)}
- Hsub_domain : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 12 : {(1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 2), (3, 3), (3, 4), (3, 5)}
+ None : 2 : A*B : 3 : {(1, 2), (1, 3), (3, 3)}
I : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 2 : I_domain : 12 : {(1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 2), (3, 3), (3, 4), (3, 5)}
- I_domain : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
None : 2 : A*B : 12 : {(1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 2), (3, 3), (3, 4), (3, 5)}
J : Size=1, Index=None, Ordered=Insertion
@@ -53,15 +44,12 @@
Key : Dimen : Domain : Size : Members
None : 1 : Any : 2 : {1, 3}
N : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 2 : N_domain : 0 : {}
- N_domain : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 12 : {(1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 2), (3, 3), (3, 4), (3, 5)}
+ None : 2 : A*B : 0 : {}
O : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : -- : Any : 0 : {}
- P : Size=16, Index=P_index, Ordered=Insertion
+ P : Size=16, Index=B*B, Ordered=Insertion
Key : Dimen : Domain : Size : Members
(2, 2) : 1 : Any : 4 : {0, 1, 2, 3}
(2, 3) : 1 : Any : 6 : {0, 1, 2, 3, 4, 5}
@@ -79,9 +67,6 @@
(5, 3) : 1 : Any : 15 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}
(5, 4) : 1 : Any : 20 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}
(5, 5) : 1 : Any : 25 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
- P_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : B*B : 16 : {(2, 2), (2, 3), (2, 4), (2, 5), (3, 2), (3, 3), (3, 4), (3, 5), (4, 2), (4, 3), (4, 4), (4, 5), (5, 2), (5, 3), (5, 4), (5, 5)}
R : Size=3, Index=B, Ordered=Insertion
Key : Dimen : Domain : Size : Members
2 : 1 : Any : 3 : {1, 3, 5}
@@ -98,16 +83,15 @@
U : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 5 : {1, 2, 6, 24, 120}
- V : Size=4, Index=V_index, Ordered=Insertion
+ V : Size=4, Index=[1:4], Ordered=Insertion
Key : Dimen : Domain : Size : Members
1 : 1 : Any : 5 : {1, 2, 3, 4, 5}
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}
-1 RangeSet Declarations
- V_index : Dimen=1, Size=4, Bounds=(1, 4)
- Key : Finite : Members
- None : True : [1:4]
-
-29 Declarations: A B C_index C D E F G H Hsub_domain Hsub I_domain I J K K_2 L M N_domain N O P_index P R S T U V_index 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
diff --git a/examples/pyomo/tutorials/set.py b/examples/pyomo/tutorials/set.py
index 78f2656d739..c1ea60b48ad 100644
--- a/examples/pyomo/tutorials/set.py
+++ b/examples/pyomo/tutorials/set.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -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.
diff --git a/examples/pyomo/tutorials/table.out b/examples/pyomo/tutorials/table.out
index 1eba28afd19..75e2b0aee33 100644
--- a/examples/pyomo/tutorials/table.out
+++ b/examples/pyomo/tutorials/table.out
@@ -1,4 +1,4 @@
-16 Set Declarations
+10 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
@@ -9,27 +9,15 @@
Key : Dimen : Domain : Size : Members
None : 2 : A*B : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
D : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 2 : D_domain : 3 : {('A1', 1), ('A2', 2), ('A3', 3)}
- D_domain : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
+ None : 2 : A*B : 3 : {('A1', 1), ('A2', 2), ('A3', 3)}
E : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 3 : E_domain : 6 : {('A1', 1, 'A1'), ('A1', 1, 'A2'), ('A2', 2, 'A2'), ('A2', 2, 'A3'), ('A3', 3, 'A1'), ('A3', 3, 'A3')}
- E_domain : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 3 : E_domain_index_0*A : 27 : {('A1', 1, 'A1'), ('A1', 1, 'A2'), ('A1', 1, 'A3'), ('A1', 2, 'A1'), ('A1', 2, 'A2'), ('A1', 2, 'A3'), ('A1', 3, 'A1'), ('A1', 3, 'A2'), ('A1', 3, 'A3'), ('A2', 1, 'A1'), ('A2', 1, 'A2'), ('A2', 1, 'A3'), ('A2', 2, 'A1'), ('A2', 2, 'A2'), ('A2', 2, 'A3'), ('A2', 3, 'A1'), ('A2', 3, 'A2'), ('A2', 3, 'A3'), ('A3', 1, 'A1'), ('A3', 1, 'A2'), ('A3', 1, 'A3'), ('A3', 2, 'A1'), ('A3', 2, 'A2'), ('A3', 2, 'A3'), ('A3', 3, 'A1'), ('A3', 3, 'A2'), ('A3', 3, 'A3')}
- E_domain_index_0 : Size=1, Index=None, Ordered=True
Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
+ None : 3 : A*B*A : 6 : {('A1', 1, 'A1'), ('A1', 1, 'A2'), ('A2', 2, 'A2'), ('A2', 2, 'A3'), ('A3', 3, 'A1'), ('A3', 3, 'A3')}
F : Size=0, Index=A, Ordered=Insertion
Key : Dimen : Domain : Size : Members
- G : Size=0, Index=G_index, Ordered=Insertion
+ G : Size=0, Index=A*B, Ordered=Insertion
Key : Dimen : Domain : Size : Members
- G_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
H : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {'H1', 'H2', 'H3'}
@@ -39,12 +27,6 @@
J : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
- T_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*I : 12 : {('A1', 'I1'), ('A1', 'I2'), ('A1', 'I3'), ('A1', 'I4'), ('A2', 'I1'), ('A2', 'I2'), ('A2', 'I3'), ('A2', 'I4'), ('A3', 'I1'), ('A3', 'I2'), ('A3', 'I3'), ('A3', 'I4')}
- U_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : I*A : 12 : {('I1', 'A1'), ('I1', 'A2'), ('I1', 'A3'), ('I2', 'A1'), ('I2', 'A2'), ('I2', 'A3'), ('I3', 'A1'), ('I3', 'A2'), ('I3', 'A3'), ('I4', 'A1'), ('I4', 'A2'), ('I4', 'A3')}
12 Param Declarations
O : Size=3, Index=J, Domain=Reals, Default=None, Mutable=False
@@ -76,7 +58,7 @@
Key : Value
A1 : 3.3
A3 : 3.5
- T : Size=12, Index=T_index, Domain=Any, Default=None, Mutable=False
+ T : Size=12, Index=A*I, Domain=Any, Default=None, Mutable=False
Key : Value
('A1', 'I1') : 1.3
('A1', 'I2') : 1.4
@@ -90,7 +72,7 @@
('A3', 'I2') : 3.4
('A3', 'I3') : 3.5
('A3', 'I4') : 3.6
- U : Size=12, Index=U_index, Domain=Any, Default=None, Mutable=False
+ U : Size=12, Index=I*A, Domain=Any, Default=None, Mutable=False
Key : Value
('I1', 'A1') : 1.3
('I1', 'A2') : 2.3
@@ -123,4 +105,4 @@
Key : Value
None : 1.01
-28 Declarations: A B C D_domain D E_domain_index_0 E_domain E F G_index G H I J Z Y X W U_index U T_index T S R Q P PP O
+22 Declarations: A B C D E F G H I J Z Y X W U T S R Q P PP O
diff --git a/examples/pyomo/tutorials/table.py b/examples/pyomo/tutorials/table.py
index 16951352ee1..7d9fceda14a 100644
--- a/examples/pyomo/tutorials/table.py
+++ b/examples/pyomo/tutorials/table.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomobook/__init__.py b/examples/pyomobook/__init__.py
index e69de29bb2d..a4a626013c4 100644
--- a/examples/pyomobook/__init__.py
+++ b/examples/pyomobook/__init__.py
@@ -0,0 +1,10 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
diff --git a/examples/pyomobook/abstract-ch/AbstHLinScript.py b/examples/pyomobook/abstract-ch/AbstHLinScript.py
index adf700bfd5c..687d3fc4e6b 100644
--- a/examples/pyomobook/abstract-ch/AbstHLinScript.py
+++ b/examples/pyomobook/abstract-ch/AbstHLinScript.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# AbstHLinScript.py - Script for a simple linear version of (H)
import pyomo.environ as pyo
diff --git a/examples/pyomobook/abstract-ch/AbstractH.py b/examples/pyomobook/abstract-ch/AbstractH.py
index da9f0a4931c..7595cbc4933 100644
--- a/examples/pyomobook/abstract-ch/AbstractH.py
+++ b/examples/pyomobook/abstract-ch/AbstractH.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# AbstractH.py - Implement model (H)
import pyomo.environ as pyo
diff --git a/examples/pyomobook/abstract-ch/AbstractHLinear.py b/examples/pyomobook/abstract-ch/AbstractHLinear.py
index 575487d3e95..f312020a9d5 100644
--- a/examples/pyomobook/abstract-ch/AbstractHLinear.py
+++ b/examples/pyomobook/abstract-ch/AbstractHLinear.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# AbstractHLinear.py - A simple linear version of (H)
import pyomo.environ as pyo
diff --git a/examples/pyomobook/abstract-ch/abstract5.py b/examples/pyomobook/abstract-ch/abstract5.py
index 3a06256dff8..8849d2dfe7f 100644
--- a/examples/pyomobook/abstract-ch/abstract5.py
+++ b/examples/pyomobook/abstract-ch/abstract5.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# abstract5.py
import pyomo.environ as pyo
diff --git a/examples/pyomobook/abstract-ch/abstract6.py b/examples/pyomobook/abstract-ch/abstract6.py
index d11a4652f64..121b12a51fa 100644
--- a/examples/pyomobook/abstract-ch/abstract6.py
+++ b/examples/pyomobook/abstract-ch/abstract6.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# abstract6.py
import pyomo.environ as pyo
diff --git a/examples/pyomobook/abstract-ch/abstract7.py b/examples/pyomobook/abstract-ch/abstract7.py
index 2fd5d467d3e..3e8131bf42b 100644
--- a/examples/pyomobook/abstract-ch/abstract7.py
+++ b/examples/pyomobook/abstract-ch/abstract7.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# abstract7.py
import pyomo.environ as pyo
import pickle
diff --git a/examples/pyomobook/abstract-ch/buildactions.py b/examples/pyomobook/abstract-ch/buildactions.py
index ad918e2b5f2..6963f285c4c 100644
--- a/examples/pyomobook/abstract-ch/buildactions.py
+++ b/examples/pyomobook/abstract-ch/buildactions.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# buildactions.py: Warehouse location problem showing build actions
import pyomo.environ as pyo
diff --git a/examples/pyomobook/abstract-ch/concrete1.py b/examples/pyomobook/abstract-ch/concrete1.py
index 0ad41c79ea3..2c89fbafaad 100644
--- a/examples/pyomobook/abstract-ch/concrete1.py
+++ b/examples/pyomobook/abstract-ch/concrete1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/abstract-ch/concrete2.py b/examples/pyomobook/abstract-ch/concrete2.py
index 6aee434d556..f68c4d6e242 100644
--- a/examples/pyomobook/abstract-ch/concrete2.py
+++ b/examples/pyomobook/abstract-ch/concrete2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/abstract-ch/diet1.py b/examples/pyomobook/abstract-ch/diet1.py
index eb8b071cdb5..fa8bf5f549f 100644
--- a/examples/pyomobook/abstract-ch/diet1.py
+++ b/examples/pyomobook/abstract-ch/diet1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# diet1.py
import pyomo.environ as pyo
diff --git a/examples/pyomobook/abstract-ch/ex.py b/examples/pyomobook/abstract-ch/ex.py
index 88005b7dc0c..83cfd445e01 100644
--- a/examples/pyomobook/abstract-ch/ex.py
+++ b/examples/pyomobook/abstract-ch/ex.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param1.py b/examples/pyomobook/abstract-ch/param1.py
index fc9fac99ff4..3ff8b648661 100644
--- a/examples/pyomobook/abstract-ch/param1.py
+++ b/examples/pyomobook/abstract-ch/param1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param2.py b/examples/pyomobook/abstract-ch/param2.py
index d51cbeffe84..aca8fac0baf 100644
--- a/examples/pyomobook/abstract-ch/param2.py
+++ b/examples/pyomobook/abstract-ch/param2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param2a.py b/examples/pyomobook/abstract-ch/param2a.py
index fe928eb4197..6b6f77f2a8f 100644
--- a/examples/pyomobook/abstract-ch/param2a.py
+++ b/examples/pyomobook/abstract-ch/param2a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param3.py b/examples/pyomobook/abstract-ch/param3.py
index 64efba5c5ad..7545b47dadc 100644
--- a/examples/pyomobook/abstract-ch/param3.py
+++ b/examples/pyomobook/abstract-ch/param3.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param3a.py b/examples/pyomobook/abstract-ch/param3a.py
index 857d96f8318..4c52b6432fb 100644
--- a/examples/pyomobook/abstract-ch/param3a.py
+++ b/examples/pyomobook/abstract-ch/param3a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param3b.py b/examples/pyomobook/abstract-ch/param3b.py
index 655694c33dd..786d6b58a16 100644
--- a/examples/pyomobook/abstract-ch/param3b.py
+++ b/examples/pyomobook/abstract-ch/param3b.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param3c.py b/examples/pyomobook/abstract-ch/param3c.py
index 7d58b8b6a39..3f5da5f837e 100644
--- a/examples/pyomobook/abstract-ch/param3c.py
+++ b/examples/pyomobook/abstract-ch/param3c.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param4.py b/examples/pyomobook/abstract-ch/param4.py
index c902b9034ad..c1926ddea74 100644
--- a/examples/pyomobook/abstract-ch/param4.py
+++ b/examples/pyomobook/abstract-ch/param4.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param5.py b/examples/pyomobook/abstract-ch/param5.py
index 488e1debda8..7e0020f70b7 100644
--- a/examples/pyomobook/abstract-ch/param5.py
+++ b/examples/pyomobook/abstract-ch/param5.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param5a.py b/examples/pyomobook/abstract-ch/param5a.py
index 7e814b917cc..efdd1855f3f 100644
--- a/examples/pyomobook/abstract-ch/param5a.py
+++ b/examples/pyomobook/abstract-ch/param5a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param6.py b/examples/pyomobook/abstract-ch/param6.py
index d9c49a548b2..f6d60f11e4b 100644
--- a/examples/pyomobook/abstract-ch/param6.py
+++ b/examples/pyomobook/abstract-ch/param6.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param6a.py b/examples/pyomobook/abstract-ch/param6a.py
index e9aca384ee6..280e942d01d 100644
--- a/examples/pyomobook/abstract-ch/param6a.py
+++ b/examples/pyomobook/abstract-ch/param6a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param7a.py b/examples/pyomobook/abstract-ch/param7a.py
index 2a18cceabf6..21839bf3b64 100644
--- a/examples/pyomobook/abstract-ch/param7a.py
+++ b/examples/pyomobook/abstract-ch/param7a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param7b.py b/examples/pyomobook/abstract-ch/param7b.py
index acf02ddd62f..a4d79b6dee9 100644
--- a/examples/pyomobook/abstract-ch/param7b.py
+++ b/examples/pyomobook/abstract-ch/param7b.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/param8a.py b/examples/pyomobook/abstract-ch/param8a.py
index e68378961ed..f00ed649c30 100644
--- a/examples/pyomobook/abstract-ch/param8a.py
+++ b/examples/pyomobook/abstract-ch/param8a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/postprocess_fn.py b/examples/pyomobook/abstract-ch/postprocess_fn.py
index f96a5b4dac1..2f2d114c216 100644
--- a/examples/pyomobook/abstract-ch/postprocess_fn.py
+++ b/examples/pyomobook/abstract-ch/postprocess_fn.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import csv
diff --git a/examples/pyomobook/abstract-ch/set1.py b/examples/pyomobook/abstract-ch/set1.py
index ee281bd10bd..5a23fe683e0 100644
--- a/examples/pyomobook/abstract-ch/set1.py
+++ b/examples/pyomobook/abstract-ch/set1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/set2.py b/examples/pyomobook/abstract-ch/set2.py
index 27af609cead..5ecc0914bee 100644
--- a/examples/pyomobook/abstract-ch/set2.py
+++ b/examples/pyomobook/abstract-ch/set2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/set2a.py b/examples/pyomobook/abstract-ch/set2a.py
index bf8f06dd7a8..7252ec0ad69 100644
--- a/examples/pyomobook/abstract-ch/set2a.py
+++ b/examples/pyomobook/abstract-ch/set2a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/set3.py b/examples/pyomobook/abstract-ch/set3.py
index 7661963d19d..f3e3efc33c7 100644
--- a/examples/pyomobook/abstract-ch/set3.py
+++ b/examples/pyomobook/abstract-ch/set3.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/set4.py b/examples/pyomobook/abstract-ch/set4.py
index c9125dad657..0c29798b816 100644
--- a/examples/pyomobook/abstract-ch/set4.py
+++ b/examples/pyomobook/abstract-ch/set4.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/set5.py b/examples/pyomobook/abstract-ch/set5.py
index 9f79870d3ff..781b956404e 100644
--- a/examples/pyomobook/abstract-ch/set5.py
+++ b/examples/pyomobook/abstract-ch/set5.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/abstract-ch/wl_abstract.py b/examples/pyomobook/abstract-ch/wl_abstract.py
index f35a5327bfb..61eeed6b506 100644
--- a/examples/pyomobook/abstract-ch/wl_abstract.py
+++ b/examples/pyomobook/abstract-ch/wl_abstract.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_abstract.py: AbstractModel version of warehouse location determination problem
import pyomo.environ as pyo
diff --git a/examples/pyomobook/abstract-ch/wl_abstract_script.py b/examples/pyomobook/abstract-ch/wl_abstract_script.py
index 0b042405714..7f0871350fc 100644
--- a/examples/pyomobook/abstract-ch/wl_abstract_script.py
+++ b/examples/pyomobook/abstract-ch/wl_abstract_script.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_abstract_script.py: Scripting using an AbstractModel
import pyomo.environ as pyo
diff --git a/examples/pyomobook/blocks-ch/blocks_gen.py b/examples/pyomobook/blocks-ch/blocks_gen.py
index 109e881cad5..31a4462f7d6 100644
--- a/examples/pyomobook/blocks-ch/blocks_gen.py
+++ b/examples/pyomobook/blocks-ch/blocks_gen.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
time = range(5)
diff --git a/examples/pyomobook/blocks-ch/blocks_gen.txt b/examples/pyomobook/blocks-ch/blocks_gen.txt
index 63d634b3b95..1636f7e4590 100644
--- a/examples/pyomobook/blocks-ch/blocks_gen.txt
+++ b/examples/pyomobook/blocks-ch/blocks_gen.txt
@@ -9,13 +9,8 @@
1 Block Declarations
Generator : Size=2, Index=GEN_UNITS, Active=True
Generator[G_EAST] : Active=True
- 1 Set Declarations
- CostCoef_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {1, 2}
-
3 Param Declarations
- CostCoef : Size=0, Index=Generator[G_EAST].CostCoef_index, Domain=Any, Default=None, Mutable=False
+ CostCoef : Size=0, Index={1, 2}, Domain=Any, Default=None, Mutable=False
Key : Value
MaxPower : Size=1, Index=None, Domain=NonNegativeReals, Default=None, Mutable=False
Key : Value
@@ -27,11 +22,11 @@
2 Var Declarations
Power : Size=5, Index=TIME
Key : Lower : Value : Upper : Fixed : Stale : Domain
- 0 : 0 : 120.0 : 500 : False : False : Reals
- 1 : 0 : 145.0 : 500 : False : False : Reals
- 2 : 0 : 119.0 : 500 : False : False : Reals
- 3 : 0 : 42.0 : 500 : False : False : Reals
- 4 : 0 : 190.0 : 500 : False : False : Reals
+ 0 : 0 : 120.0 : 500.0 : False : False : Reals
+ 1 : 0 : 145.0 : 500.0 : False : False : Reals
+ 2 : 0 : 119.0 : 500.0 : False : False : Reals
+ 3 : 0 : 42.0 : 500.0 : False : False : Reals
+ 4 : 0 : 190.0 : 500.0 : False : False : Reals
UnitOn : Size=5, Index=TIME
Key : Lower : Value : Upper : Fixed : Stale : Domain
0 : 0 : None : 1 : False : True : Binary
@@ -57,15 +52,10 @@
3 : -50.0 : Generator[G_EAST].Power[3] - Generator[G_EAST].Power[2] : Generator[G_EAST].RampLimit : True
4 : -50.0 : Generator[G_EAST].Power[4] - Generator[G_EAST].Power[3] : Generator[G_EAST].RampLimit : True
- 8 Declarations: MaxPower RampLimit Power UnitOn limit_ramp CostCoef_index CostCoef Cost
+ 7 Declarations: MaxPower RampLimit Power UnitOn limit_ramp CostCoef Cost
Generator[G_MAIN] : Active=True
- 1 Set Declarations
- CostCoef_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {1, 2}
-
3 Param Declarations
- CostCoef : Size=0, Index=Generator[G_MAIN].CostCoef_index, Domain=Any, Default=None, Mutable=False
+ CostCoef : Size=0, Index={1, 2}, Domain=Any, Default=None, Mutable=False
Key : Value
MaxPower : Size=1, Index=None, Domain=NonNegativeReals, Default=None, Mutable=False
Key : Value
@@ -77,11 +67,11 @@
2 Var Declarations
Power : Size=5, Index=TIME
Key : Lower : Value : Upper : Fixed : Stale : Domain
- 0 : 0 : 120.0 : 500 : False : False : Reals
- 1 : 0 : 145.0 : 500 : False : False : Reals
- 2 : 0 : 119.0 : 500 : False : False : Reals
- 3 : 0 : 42.0 : 500 : False : False : Reals
- 4 : 0 : 190.0 : 500 : False : False : Reals
+ 0 : 0 : 120.0 : 500.0 : False : False : Reals
+ 1 : 0 : 145.0 : 500.0 : False : False : Reals
+ 2 : 0 : 119.0 : 500.0 : False : False : Reals
+ 3 : 0 : 42.0 : 500.0 : False : False : Reals
+ 4 : 0 : 190.0 : 500.0 : False : False : Reals
UnitOn : Size=5, Index=TIME
Key : Lower : Value : Upper : Fixed : Stale : Domain
0 : 0 : None : 1 : False : True : Binary
@@ -107,7 +97,7 @@
3 : -50.0 : Generator[G_MAIN].Power[3] - Generator[G_MAIN].Power[2] : Generator[G_MAIN].RampLimit : True
4 : -50.0 : Generator[G_MAIN].Power[4] - Generator[G_MAIN].Power[3] : Generator[G_MAIN].RampLimit : True
- 8 Declarations: MaxPower RampLimit Power UnitOn limit_ramp CostCoef_index CostCoef Cost
+ 7 Declarations: MaxPower RampLimit Power UnitOn limit_ramp CostCoef Cost
3 Declarations: TIME GEN_UNITS Generator
2 Set Declarations
@@ -121,13 +111,8 @@
1 Block Declarations
Generator : Size=2, Index=GEN_UNITS, Active=True
Generator[G_EAST] : Active=True
- 1 Set Declarations
- CostCoef_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {1, 2}
-
3 Param Declarations
- CostCoef : Size=0, Index=Generator[G_EAST].CostCoef_index, Domain=Any, Default=None, Mutable=False
+ CostCoef : Size=0, Index={1, 2}, Domain=Any, Default=None, Mutable=False
Key : Value
MaxPower : Size=1, Index=None, Domain=NonNegativeReals, Default=None, Mutable=False
Key : Value
@@ -139,11 +124,11 @@
2 Var Declarations
Power : Size=5, Index=TIME
Key : Lower : Value : Upper : Fixed : Stale : Domain
- 0 : 0 : 120.0 : 500 : False : False : Reals
- 1 : 0 : 145.0 : 500 : False : False : Reals
- 2 : 0 : 119.0 : 500 : False : False : Reals
- 3 : 0 : 42.0 : 500 : False : False : Reals
- 4 : 0 : 190.0 : 500 : False : False : Reals
+ 0 : 0 : 120.0 : 500.0 : False : False : Reals
+ 1 : 0 : 145.0 : 500.0 : False : False : Reals
+ 2 : 0 : 119.0 : 500.0 : False : False : Reals
+ 3 : 0 : 42.0 : 500.0 : False : False : Reals
+ 4 : 0 : 190.0 : 500.0 : False : False : Reals
UnitOn : Size=5, Index=TIME
Key : Lower : Value : Upper : Fixed : Stale : Domain
0 : 0 : None : 1 : False : True : Binary
@@ -169,15 +154,10 @@
3 : -50.0 : Generator[G_EAST].Power[3] - Generator[G_EAST].Power[2] : Generator[G_EAST].RampLimit : True
4 : -50.0 : Generator[G_EAST].Power[4] - Generator[G_EAST].Power[3] : Generator[G_EAST].RampLimit : True
- 8 Declarations: MaxPower RampLimit Power UnitOn limit_ramp CostCoef_index CostCoef Cost
+ 7 Declarations: MaxPower RampLimit Power UnitOn limit_ramp CostCoef Cost
Generator[G_MAIN] : Active=True
- 1 Set Declarations
- CostCoef_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {1, 2}
-
3 Param Declarations
- CostCoef : Size=0, Index=Generator[G_MAIN].CostCoef_index, Domain=Any, Default=None, Mutable=False
+ CostCoef : Size=0, Index={1, 2}, Domain=Any, Default=None, Mutable=False
Key : Value
MaxPower : Size=1, Index=None, Domain=NonNegativeReals, Default=None, Mutable=False
Key : Value
@@ -189,11 +169,11 @@
2 Var Declarations
Power : Size=5, Index=TIME
Key : Lower : Value : Upper : Fixed : Stale : Domain
- 0 : 0 : 120.0 : 500 : False : False : Reals
- 1 : 0 : 145.0 : 500 : False : False : Reals
- 2 : 0 : 119.0 : 500 : False : False : Reals
- 3 : 0 : 42.0 : 500 : False : False : Reals
- 4 : 0 : 190.0 : 500 : False : False : Reals
+ 0 : 0 : 120.0 : 500.0 : False : False : Reals
+ 1 : 0 : 145.0 : 500.0 : False : False : Reals
+ 2 : 0 : 119.0 : 500.0 : False : False : Reals
+ 3 : 0 : 42.0 : 500.0 : False : False : Reals
+ 4 : 0 : 190.0 : 500.0 : False : False : Reals
UnitOn : Size=5, Index=TIME
Key : Lower : Value : Upper : Fixed : Stale : Domain
0 : 0 : None : 1 : False : True : Binary
@@ -219,7 +199,7 @@
3 : -50.0 : Generator[G_MAIN].Power[3] - Generator[G_MAIN].Power[2] : Generator[G_MAIN].RampLimit : True
4 : -50.0 : Generator[G_MAIN].Power[4] - Generator[G_MAIN].Power[3] : Generator[G_MAIN].RampLimit : True
- 8 Declarations: MaxPower RampLimit Power UnitOn limit_ramp CostCoef_index CostCoef Cost
+ 7 Declarations: MaxPower RampLimit Power UnitOn limit_ramp CostCoef Cost
3 Declarations: TIME GEN_UNITS Generator
Generator[G_MAIN].Power[4] = 190.0
diff --git a/examples/pyomobook/blocks-ch/blocks_intro.py b/examples/pyomobook/blocks-ch/blocks_intro.py
index ad3ceaa4349..ba2bd9d3a97 100644
--- a/examples/pyomobook/blocks-ch/blocks_intro.py
+++ b/examples/pyomobook/blocks-ch/blocks_intro.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
# @hierarchy:
diff --git a/examples/pyomobook/blocks-ch/blocks_lotsizing.py b/examples/pyomobook/blocks-ch/blocks_lotsizing.py
index fe0717d8c7c..758ad964dc5 100644
--- a/examples/pyomobook/blocks-ch/blocks_lotsizing.py
+++ b/examples/pyomobook/blocks-ch/blocks_lotsizing.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/blocks-ch/lotsizing.py b/examples/pyomobook/blocks-ch/lotsizing.py
index 47ea265246e..ece4d6b541c 100644
--- a/examples/pyomobook/blocks-ch/lotsizing.py
+++ b/examples/pyomobook/blocks-ch/lotsizing.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/blocks-ch/lotsizing_no_time.py b/examples/pyomobook/blocks-ch/lotsizing_no_time.py
index 901467a0cbb..60e8ba44424 100644
--- a/examples/pyomobook/blocks-ch/lotsizing_no_time.py
+++ b/examples/pyomobook/blocks-ch/lotsizing_no_time.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/blocks-ch/lotsizing_uncertain.py b/examples/pyomobook/blocks-ch/lotsizing_uncertain.py
index 6d16de7e3a7..f72161db5c6 100644
--- a/examples/pyomobook/blocks-ch/lotsizing_uncertain.py
+++ b/examples/pyomobook/blocks-ch/lotsizing_uncertain.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/blocks-ch/lotsizing_uncertain.txt b/examples/pyomobook/blocks-ch/lotsizing_uncertain.txt
index db9eee79cc3..08f92ae9262 100644
--- a/examples/pyomobook/blocks-ch/lotsizing_uncertain.txt
+++ b/examples/pyomobook/blocks-ch/lotsizing_uncertain.txt
@@ -1,20 +1,3 @@
-5 Set Declarations
- i_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : T*S : 25 : {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5)}
- i_neg_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : T*S : 25 : {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5)}
- i_pos_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : T*S : 25 : {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5)}
- x_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : T*S : 25 : {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5)}
- y_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : T*S : 25 : {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5)}
-
2 RangeSet Declarations
S : Dimen=1, Size=5, Bounds=(1, 5)
Key : Finite : Members
@@ -24,7 +7,7 @@
None : True : [1:5]
5 Var Declarations
- i : Size=25, Index=i_index
+ i : Size=25, Index=T*S
Key : Lower : Value : Upper : Fixed : Stale : Domain
(1, 1) : None : None : None : False : True : Reals
(1, 2) : None : None : None : False : True : Reals
@@ -51,7 +34,7 @@
(5, 3) : None : None : None : False : True : Reals
(5, 4) : None : None : None : False : True : Reals
(5, 5) : None : None : None : False : True : Reals
- i_neg : Size=25, Index=i_neg_index
+ i_neg : Size=25, Index=T*S
Key : Lower : Value : Upper : Fixed : Stale : Domain
(1, 1) : 0 : None : None : False : True : NonNegativeReals
(1, 2) : 0 : None : None : False : True : NonNegativeReals
@@ -78,7 +61,7 @@
(5, 3) : 0 : None : None : False : True : NonNegativeReals
(5, 4) : 0 : None : None : False : True : NonNegativeReals
(5, 5) : 0 : None : None : False : True : NonNegativeReals
- i_pos : Size=25, Index=i_pos_index
+ i_pos : Size=25, Index=T*S
Key : Lower : Value : Upper : Fixed : Stale : Domain
(1, 1) : 0 : None : None : False : True : NonNegativeReals
(1, 2) : 0 : None : None : False : True : NonNegativeReals
@@ -105,7 +88,7 @@
(5, 3) : 0 : None : None : False : True : NonNegativeReals
(5, 4) : 0 : None : None : False : True : NonNegativeReals
(5, 5) : 0 : None : None : False : True : NonNegativeReals
- x : Size=25, Index=x_index
+ x : Size=25, Index=T*S
Key : Lower : Value : Upper : Fixed : Stale : Domain
(1, 1) : 0 : None : None : False : True : NonNegativeReals
(1, 2) : 0 : None : None : False : True : NonNegativeReals
@@ -132,7 +115,7 @@
(5, 3) : 0 : None : None : False : True : NonNegativeReals
(5, 4) : 0 : None : None : False : True : NonNegativeReals
(5, 5) : 0 : None : None : False : True : NonNegativeReals
- y : Size=25, Index=y_index
+ y : Size=25, Index=T*S
Key : Lower : Value : Upper : Fixed : Stale : Domain
(1, 1) : 0 : None : 1 : False : True : Binary
(1, 2) : 0 : None : 1 : False : True : Binary
@@ -160,4 +143,4 @@
(5, 4) : 0 : None : 1 : False : True : Binary
(5, 5) : 0 : None : 1 : False : True : Binary
-12 Declarations: T S y_index y x_index x i_index i i_pos_index i_pos i_neg_index i_neg
+7 Declarations: T S y x i i_pos i_neg
diff --git a/examples/pyomobook/dae-ch/dae_tester_model.py b/examples/pyomobook/dae-ch/dae_tester_model.py
index 9e0da9f4a62..396b8a53db1 100644
--- a/examples/pyomobook/dae-ch/dae_tester_model.py
+++ b/examples/pyomobook/dae-ch/dae_tester_model.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# This is a file for testing miscellaneous code snippets from the DAE chapter
import pyomo.environ as pyo
import pyomo.dae as dae
diff --git a/examples/pyomobook/dae-ch/path_constraint.py b/examples/pyomobook/dae-ch/path_constraint.py
index 5fe41dd132d..5e252d1b99f 100644
--- a/examples/pyomobook/dae-ch/path_constraint.py
+++ b/examples/pyomobook/dae-ch/path_constraint.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/examples/pyomobook/dae-ch/path_constraint.txt b/examples/pyomobook/dae-ch/path_constraint.txt
index 421692b33e9..97e56ab8816 100644
--- a/examples/pyomobook/dae-ch/path_constraint.txt
+++ b/examples/pyomobook/dae-ch/path_constraint.txt
@@ -1,8 +1,3 @@
-1 RangeSet Declarations
- t_domain : Dimen=1, Size=Inf, Bounds=(0, 1)
- Key : Finite : Members
- None : False : [0..1]
-
1 Param Declarations
tf : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
Key : Value
@@ -68,4 +63,4 @@
0 : None : None : None : False : True : Reals
1 : None : None : None : False : True : Reals
-15 Declarations: tf t_domain t u x1 x2 x3 dx1 dx2 dx3 x1dotcon x2dotcon x3dotcon obj con
+14 Declarations: tf t u x1 x2 x3 dx1 dx2 dx3 x1dotcon x2dotcon x3dotcon obj con
diff --git a/examples/pyomobook/dae-ch/plot_path_constraint.py b/examples/pyomobook/dae-ch/plot_path_constraint.py
index 4c04bc1b6b6..be86f13cbc0 100644
--- a/examples/pyomobook/dae-ch/plot_path_constraint.py
+++ b/examples/pyomobook/dae-ch/plot_path_constraint.py
@@ -1,3 +1,15 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+
# @plot_path:
def plotter(subplot, x, *y, **kwds):
plt.subplot(subplot)
diff --git a/examples/pyomobook/dae-ch/run_path_constraint.py b/examples/pyomobook/dae-ch/run_path_constraint.py
index b819d6a7127..fc115f5649c 100644
--- a/examples/pyomobook/dae-ch/run_path_constraint.py
+++ b/examples/pyomobook/dae-ch/run_path_constraint.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
from pyomo.dae import *
from path_constraint import m
diff --git a/examples/pyomobook/dae-ch/run_path_constraint_tester.py b/examples/pyomobook/dae-ch/run_path_constraint_tester.py
index bbcd83f5da5..22d887e9b11 100644
--- a/examples/pyomobook/dae-ch/run_path_constraint_tester.py
+++ b/examples/pyomobook/dae-ch/run_path_constraint_tester.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.common.tee import capture_output
from six import StringIO
diff --git a/examples/pyomobook/gdp-ch/gdp_uc.py b/examples/pyomobook/gdp-ch/gdp_uc.py
index 2495ed9bef1..6268bcce068 100644
--- a/examples/pyomobook/gdp-ch/gdp_uc.py
+++ b/examples/pyomobook/gdp-ch/gdp_uc.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# gdp_uc.py
import pyomo.environ as pyo
from pyomo.gdp import *
diff --git a/examples/pyomobook/gdp-ch/scont.py b/examples/pyomobook/gdp-ch/scont.py
index 76597326700..d1cf4b172bd 100644
--- a/examples/pyomobook/gdp-ch/scont.py
+++ b/examples/pyomobook/gdp-ch/scont.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# scont.py
import pyomo.environ as pyo
from pyomo.gdp import Disjunct, Disjunction
diff --git a/examples/pyomobook/gdp-ch/scont2.py b/examples/pyomobook/gdp-ch/scont2.py
index 94e510b358a..2c77fe670d5 100644
--- a/examples/pyomobook/gdp-ch/scont2.py
+++ b/examples/pyomobook/gdp-ch/scont2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
import scont
diff --git a/examples/pyomobook/gdp-ch/scont_script.py b/examples/pyomobook/gdp-ch/scont_script.py
index 22c9b88ad0c..fe0702dc262 100644
--- a/examples/pyomobook/gdp-ch/scont_script.py
+++ b/examples/pyomobook/gdp-ch/scont_script.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
import scont
diff --git a/examples/pyomobook/gdp-ch/verify_scont.py b/examples/pyomobook/gdp-ch/verify_scont.py
index db44024fe66..222453560b6 100644
--- a/examples/pyomobook/gdp-ch/verify_scont.py
+++ b/examples/pyomobook/gdp-ch/verify_scont.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import os
diff --git a/examples/pyomobook/intro-ch/abstract5.py b/examples/pyomobook/intro-ch/abstract5.py
index 2184ed7b3aa..2caad5f9351 100644
--- a/examples/pyomobook/intro-ch/abstract5.py
+++ b/examples/pyomobook/intro-ch/abstract5.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/intro-ch/coloring_concrete.py b/examples/pyomobook/intro-ch/coloring_concrete.py
index 107a31668c4..9931b5d80de 100644
--- a/examples/pyomobook/intro-ch/coloring_concrete.py
+++ b/examples/pyomobook/intro-ch/coloring_concrete.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
#
# Graph coloring example adapted from
#
diff --git a/examples/pyomobook/intro-ch/concrete1.py b/examples/pyomobook/intro-ch/concrete1.py
index a39ca1d41cd..169fbeb281c 100644
--- a/examples/pyomobook/intro-ch/concrete1.py
+++ b/examples/pyomobook/intro-ch/concrete1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/intro-ch/concrete1_generic.py b/examples/pyomobook/intro-ch/concrete1_generic.py
index de648470469..9a2d26bded8 100644
--- a/examples/pyomobook/intro-ch/concrete1_generic.py
+++ b/examples/pyomobook/intro-ch/concrete1_generic.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
import mydata
diff --git a/examples/pyomobook/intro-ch/mydata.py b/examples/pyomobook/intro-ch/mydata.py
index 83aa26bacd9..209546ebeaf 100644
--- a/examples/pyomobook/intro-ch/mydata.py
+++ b/examples/pyomobook/intro-ch/mydata.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
N = [1, 2]
M = [1, 2]
c = {1: 1, 2: 2}
diff --git a/examples/pyomobook/mpec-ch/ex1a.py b/examples/pyomobook/mpec-ch/ex1a.py
index 30cd2842556..e6f1c33fbbc 100644
--- a/examples/pyomobook/mpec-ch/ex1a.py
+++ b/examples/pyomobook/mpec-ch/ex1a.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ex1a.py
import pyomo.environ as pyo
from pyomo.mpec import Complementarity, complements
diff --git a/examples/pyomobook/mpec-ch/ex1b.py b/examples/pyomobook/mpec-ch/ex1b.py
index 9592c81c4f6..2b0ac2ce1b7 100644
--- a/examples/pyomobook/mpec-ch/ex1b.py
+++ b/examples/pyomobook/mpec-ch/ex1b.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ex1b.py
import pyomo.environ as pyo
from pyomo.mpec import ComplementarityList, complements
diff --git a/examples/pyomobook/mpec-ch/ex1c.py b/examples/pyomobook/mpec-ch/ex1c.py
index aad9c9b0d47..eaf0292b50d 100644
--- a/examples/pyomobook/mpec-ch/ex1c.py
+++ b/examples/pyomobook/mpec-ch/ex1c.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ex1c.py
import pyomo.environ as pyo
from pyomo.mpec import ComplementarityList, complements
diff --git a/examples/pyomobook/mpec-ch/ex1d.py b/examples/pyomobook/mpec-ch/ex1d.py
index fa5247ff831..4c0e0d9fd0f 100644
--- a/examples/pyomobook/mpec-ch/ex1d.py
+++ b/examples/pyomobook/mpec-ch/ex1d.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ex1d.py
import pyomo.environ as pyo
from pyomo.mpec import Complementarity, complements
diff --git a/examples/pyomobook/mpec-ch/ex1e.py b/examples/pyomobook/mpec-ch/ex1e.py
index bf714411396..c552847fcfb 100644
--- a/examples/pyomobook/mpec-ch/ex1e.py
+++ b/examples/pyomobook/mpec-ch/ex1e.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ex1e.py
import pyomo.environ as pyo
from pyomo.mpec import ComplementarityList, complements
diff --git a/examples/pyomobook/mpec-ch/ex2.py b/examples/pyomobook/mpec-ch/ex2.py
index c192ccc7a34..6981af33376 100644
--- a/examples/pyomobook/mpec-ch/ex2.py
+++ b/examples/pyomobook/mpec-ch/ex2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ex2.py
import pyomo.environ as pyo
from pyomo.mpec import *
diff --git a/examples/pyomobook/mpec-ch/munson1.py b/examples/pyomobook/mpec-ch/munson1.py
index c7d171eb416..e85d9359768 100644
--- a/examples/pyomobook/mpec-ch/munson1.py
+++ b/examples/pyomobook/mpec-ch/munson1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# munson1.py
import pyomo.environ as pyo
from pyomo.mpec import Complementarity, complements
diff --git a/examples/pyomobook/mpec-ch/ralph1.py b/examples/pyomobook/mpec-ch/ralph1.py
index 1d44a303b84..b6a8b45e8df 100644
--- a/examples/pyomobook/mpec-ch/ralph1.py
+++ b/examples/pyomobook/mpec-ch/ralph1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ralph1.py
import pyomo.environ as pyo
from pyomo.mpec import Complementarity, complements
diff --git a/examples/pyomobook/nonlinear-ch/deer/DeerProblem.py b/examples/pyomobook/nonlinear-ch/deer/DeerProblem.py
index c076a7f4687..dc3ca179a58 100644
--- a/examples/pyomobook/nonlinear-ch/deer/DeerProblem.py
+++ b/examples/pyomobook/nonlinear-ch/deer/DeerProblem.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# DeerProblem.py
import pyomo.environ as pyo
diff --git a/examples/pyomobook/nonlinear-ch/disease_est/disease_estimation.py b/examples/pyomobook/nonlinear-ch/disease_est/disease_estimation.py
index 4eb859dc349..5675d7a715b 100644
--- a/examples/pyomobook/nonlinear-ch/disease_est/disease_estimation.py
+++ b/examples/pyomobook/nonlinear-ch/disease_est/disease_estimation.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# disease_estimation.py
import pyomo.environ as pyo
diff --git a/examples/pyomobook/nonlinear-ch/multimodal/multimodal_init1.py b/examples/pyomobook/nonlinear-ch/multimodal/multimodal_init1.py
index c435cafc3d5..a50bf3321d6 100644
--- a/examples/pyomobook/nonlinear-ch/multimodal/multimodal_init1.py
+++ b/examples/pyomobook/nonlinear-ch/multimodal/multimodal_init1.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# multimodal_init1.py
import pyomo.environ as pyo
from math import pi
diff --git a/examples/pyomobook/nonlinear-ch/multimodal/multimodal_init2.py b/examples/pyomobook/nonlinear-ch/multimodal/multimodal_init2.py
index aa0dbae1e66..6a209334521 100644
--- a/examples/pyomobook/nonlinear-ch/multimodal/multimodal_init2.py
+++ b/examples/pyomobook/nonlinear-ch/multimodal/multimodal_init2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
from math import pi
diff --git a/examples/pyomobook/nonlinear-ch/react_design/ReactorDesign.py b/examples/pyomobook/nonlinear-ch/react_design/ReactorDesign.py
index 90822c153a5..1cfe3b7193f 100644
--- a/examples/pyomobook/nonlinear-ch/react_design/ReactorDesign.py
+++ b/examples/pyomobook/nonlinear-ch/react_design/ReactorDesign.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ
import pyomo.environ as pyo
diff --git a/examples/pyomobook/nonlinear-ch/react_design/ReactorDesignTable.py b/examples/pyomobook/nonlinear-ch/react_design/ReactorDesignTable.py
index a242c85fbc2..2bd9574b427 100644
--- a/examples/pyomobook/nonlinear-ch/react_design/ReactorDesignTable.py
+++ b/examples/pyomobook/nonlinear-ch/react_design/ReactorDesignTable.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
from ReactorDesign import create_model
diff --git a/examples/pyomobook/nonlinear-ch/rosen/rosenbrock.py b/examples/pyomobook/nonlinear-ch/rosen/rosenbrock.py
index e1633e2df69..bec1d04c12c 100644
--- a/examples/pyomobook/nonlinear-ch/rosen/rosenbrock.py
+++ b/examples/pyomobook/nonlinear-ch/rosen/rosenbrock.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# rosenbrock.py
# A Pyomo model for the Rosenbrock problem
import pyomo.environ as pyo
diff --git a/examples/pyomobook/optimization-ch/ConcHLinScript.py b/examples/pyomobook/optimization-ch/ConcHLinScript.py
index 8481a83afbf..b94903585dc 100644
--- a/examples/pyomobook/optimization-ch/ConcHLinScript.py
+++ b/examples/pyomobook/optimization-ch/ConcHLinScript.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ConcHLinScript.py - Linear (H) as a script
import pyomo.environ as pyo
diff --git a/examples/pyomobook/optimization-ch/ConcHLinScript.txt b/examples/pyomobook/optimization-ch/ConcHLinScript.txt
index c04591c94dc..0d34868ed99 100644
--- a/examples/pyomobook/optimization-ch/ConcHLinScript.txt
+++ b/examples/pyomobook/optimization-ch/ConcHLinScript.txt
@@ -1,7 +1,7 @@
Model 'Linear (H)'
Variables:
- x : Size=2, Index=x_index
+ x : Size=2, Index={I_C_Scoops, Peanuts}
Key : Lower : Value : Upper : Fixed : Stale : Domain
I_C_Scoops : 0 : 0.0 : 100 : False : False : Reals
Peanuts : 0 : 40.6 : 40.6 : False : False : Reals
@@ -9,7 +9,7 @@ Model 'Linear (H)'
Objectives:
z : Size=1, Index=None, Active=True
Key : Active : Value
- None : True : 3.83388751715
+ None : True : 3.8338875171467763
Constraints:
budgetconstr : Size=1
diff --git a/examples/pyomobook/optimization-ch/ConcreteH.py b/examples/pyomobook/optimization-ch/ConcreteH.py
index 1bf2a9446c1..d7474291d0d 100644
--- a/examples/pyomobook/optimization-ch/ConcreteH.py
+++ b/examples/pyomobook/optimization-ch/ConcreteH.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ConcreteH.py - Implement a particular instance of (H)
# @fct:
diff --git a/examples/pyomobook/optimization-ch/ConcreteH.txt b/examples/pyomobook/optimization-ch/ConcreteH.txt
index 5e669ff71e0..04bbbdab857 100644
--- a/examples/pyomobook/optimization-ch/ConcreteH.txt
+++ b/examples/pyomobook/optimization-ch/ConcreteH.txt
@@ -1,10 +1,5 @@
-1 Set Declarations
- x_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {'I_C_Scoops', 'Peanuts'}
-
1 Var Declarations
- x : Size=2, Index=x_index
+ x : Size=2, Index={I_C_Scoops, Peanuts}
Key : Lower : Value : Upper : Fixed : Stale : Domain
I_C_Scoops : 0 : None : 100 : False : True : Reals
Peanuts : 0 : None : 40.6 : False : True : Reals
@@ -19,4 +14,4 @@
Key : Lower : Body : Upper : Active
None : -Inf : 3.14*x[I_C_Scoops] + 0.2718*x[Peanuts] : 12.0 : True
-4 Declarations: x_index x z budgetconstr
+3 Declarations: x z budgetconstr
diff --git a/examples/pyomobook/optimization-ch/ConcreteHLinear.py b/examples/pyomobook/optimization-ch/ConcreteHLinear.py
index 0b42d5e2187..772c18cb6d5 100644
--- a/examples/pyomobook/optimization-ch/ConcreteHLinear.py
+++ b/examples/pyomobook/optimization-ch/ConcreteHLinear.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# ConcreteHLinear.py - Linear (H)
import pyomo.environ as pyo
diff --git a/examples/pyomobook/optimization-ch/ConcreteHLinear.txt b/examples/pyomobook/optimization-ch/ConcreteHLinear.txt
index 2e778c2bd1b..7f19aca87ec 100644
--- a/examples/pyomobook/optimization-ch/ConcreteHLinear.txt
+++ b/examples/pyomobook/optimization-ch/ConcreteHLinear.txt
@@ -1,10 +1,5 @@
-1 Set Declarations
- x_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {'I_C_Scoops', 'Peanuts'}
-
1 Var Declarations
- x : Size=2, Index=x_index
+ x : Size=2, Index={I_C_Scoops, Peanuts}
Key : Lower : Value : Upper : Fixed : Stale : Domain
I_C_Scoops : 0 : None : 100 : False : True : Reals
Peanuts : 0 : None : 40.6 : False : True : Reals
@@ -19,4 +14,4 @@
Key : Lower : Body : Upper : Active
None : -Inf : 3.14*x[I_C_Scoops] + 0.2718*x[Peanuts] : 12.0 : True
-4 Declarations: x_index x z budgetconstr
+3 Declarations: x z budgetconstr
diff --git a/examples/pyomobook/optimization-ch/IC_model_dict.py b/examples/pyomobook/optimization-ch/IC_model_dict.py
index 4c54ef83701..b7e359777c7 100644
--- a/examples/pyomobook/optimization-ch/IC_model_dict.py
+++ b/examples/pyomobook/optimization-ch/IC_model_dict.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# IC_model_dict.py - Implement a particular instance of (H)
# @fct:
diff --git a/examples/pyomobook/overview-ch/var_obj_con_snippet.py b/examples/pyomobook/overview-ch/var_obj_con_snippet.py
index 49bb7c1276b..22524b5815a 100644
--- a/examples/pyomobook/overview-ch/var_obj_con_snippet.py
+++ b/examples/pyomobook/overview-ch/var_obj_con_snippet.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/overview-ch/wl_abstract.py b/examples/pyomobook/overview-ch/wl_abstract.py
index f35a5327bfb..61eeed6b506 100644
--- a/examples/pyomobook/overview-ch/wl_abstract.py
+++ b/examples/pyomobook/overview-ch/wl_abstract.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_abstract.py: AbstractModel version of warehouse location determination problem
import pyomo.environ as pyo
diff --git a/examples/pyomobook/overview-ch/wl_abstract_script.py b/examples/pyomobook/overview-ch/wl_abstract_script.py
index 0b042405714..7f0871350fc 100644
--- a/examples/pyomobook/overview-ch/wl_abstract_script.py
+++ b/examples/pyomobook/overview-ch/wl_abstract_script.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_abstract_script.py: Scripting using an AbstractModel
import pyomo.environ as pyo
diff --git a/examples/pyomobook/overview-ch/wl_concrete.py b/examples/pyomobook/overview-ch/wl_concrete.py
index 29316304f0a..c1bf70b07f1 100644
--- a/examples/pyomobook/overview-ch/wl_concrete.py
+++ b/examples/pyomobook/overview-ch/wl_concrete.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_concrete.py
# ConcreteModel version of warehouse location problem
import pyomo.environ as pyo
diff --git a/examples/pyomobook/overview-ch/wl_concrete_script.py b/examples/pyomobook/overview-ch/wl_concrete_script.py
index 278937f5aed..b369521994c 100644
--- a/examples/pyomobook/overview-ch/wl_concrete_script.py
+++ b/examples/pyomobook/overview-ch/wl_concrete_script.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_concrete_script.py
# Solve an instance of the warehouse location problem
diff --git a/examples/pyomobook/overview-ch/wl_concrete_script.txt b/examples/pyomobook/overview-ch/wl_concrete_script.txt
index dae31e1a035..165289552d3 100644
--- a/examples/pyomobook/overview-ch/wl_concrete_script.txt
+++ b/examples/pyomobook/overview-ch/wl_concrete_script.txt
@@ -1,4 +1,4 @@
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 1.0 : 1 : False : False : Binary
Harlingen : 0 : 1.0 : 1 : False : False : Binary
diff --git a/examples/pyomobook/overview-ch/wl_excel.py b/examples/pyomobook/overview-ch/wl_excel.py
index 1c4ad997225..180e36422fe 100644
--- a/examples/pyomobook/overview-ch/wl_excel.py
+++ b/examples/pyomobook/overview-ch/wl_excel.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_excel.py: Loading Excel data using Pandas
import pandas
import pyomo.environ as pyo
diff --git a/examples/pyomobook/overview-ch/wl_excel.txt b/examples/pyomobook/overview-ch/wl_excel.txt
index dae31e1a035..165289552d3 100644
--- a/examples/pyomobook/overview-ch/wl_excel.txt
+++ b/examples/pyomobook/overview-ch/wl_excel.txt
@@ -1,4 +1,4 @@
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 1.0 : 1 : False : False : Binary
Harlingen : 0 : 1.0 : 1 : False : False : Binary
diff --git a/examples/pyomobook/overview-ch/wl_list.py b/examples/pyomobook/overview-ch/wl_list.py
index 64db76be548..37cba5a9595 100644
--- a/examples/pyomobook/overview-ch/wl_list.py
+++ b/examples/pyomobook/overview-ch/wl_list.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_list.py: Warehouse location problem using constraint lists
import pyomo.environ as pyo
diff --git a/examples/pyomobook/overview-ch/wl_list.txt b/examples/pyomobook/overview-ch/wl_list.txt
index 2054efe153d..c0d44f1a0c9 100644
--- a/examples/pyomobook/overview-ch/wl_list.txt
+++ b/examples/pyomobook/overview-ch/wl_list.txt
@@ -1,25 +1,5 @@
-6 Set Declarations
- demand_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 4 : {1, 2, 3, 4}
- warehouse_active_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 12 : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
- x_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : x_index_0*x_index_1 : 12 : {('Harlingen', 'NYC'), ('Harlingen', 'LA'), ('Harlingen', 'Chicago'), ('Harlingen', 'Houston'), ('Memphis', 'NYC'), ('Memphis', 'LA'), ('Memphis', 'Chicago'), ('Memphis', 'Houston'), ('Ashland', 'NYC'), ('Ashland', 'LA'), ('Ashland', 'Chicago'), ('Ashland', 'Houston')}
- x_index_0 : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {'Harlingen', 'Memphis', 'Ashland'}
- x_index_1 : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 4 : {'NYC', 'LA', 'Chicago', 'Houston'}
- y_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {'Harlingen', 'Memphis', 'Ashland'}
-
2 Var Declarations
- x : Size=12, Index=x_index
+ x : Size=12, Index={Harlingen, Memphis, Ashland}*{NYC, LA, Chicago, Houston}
Key : Lower : Value : Upper : Fixed : Stale : Domain
('Ashland', 'Chicago') : 0 : None : 1 : False : True : Reals
('Ashland', 'Houston') : 0 : None : 1 : False : True : Reals
@@ -33,7 +13,7 @@
('Memphis', 'Houston') : 0 : None : 1 : False : True : Reals
('Memphis', 'LA') : 0 : None : 1 : False : True : Reals
('Memphis', 'NYC') : 0 : None : 1 : False : True : Reals
- y : Size=3, Index=y_index
+ y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : None : 1 : False : True : Binary
Harlingen : 0 : None : 1 : False : True : Binary
@@ -45,7 +25,7 @@
None : True : minimize : 1956*x[Harlingen,NYC] + 1606*x[Harlingen,LA] + 1410*x[Harlingen,Chicago] + 330*x[Harlingen,Houston] + 1096*x[Memphis,NYC] + 1792*x[Memphis,LA] + 531*x[Memphis,Chicago] + 567*x[Memphis,Houston] + 485*x[Ashland,NYC] + 2322*x[Ashland,LA] + 324*x[Ashland,Chicago] + 1236*x[Ashland,Houston]
3 Constraint Declarations
- demand : Size=4, Index=demand_index, Active=True
+ demand : Size=4, Index={1, 2, 3, 4}, Active=True
Key : Lower : Body : Upper : Active
1 : 1.0 : x[Harlingen,NYC] + x[Memphis,NYC] + x[Ashland,NYC] : 1.0 : True
2 : 1.0 : x[Harlingen,LA] + x[Memphis,LA] + x[Ashland,LA] : 1.0 : True
@@ -54,7 +34,7 @@
num_warehouses : Size=1, Index=None, Active=True
Key : Lower : Body : Upper : Active
None : -Inf : y[Harlingen] + y[Memphis] + y[Ashland] : 2.0 : True
- warehouse_active : Size=12, Index=warehouse_active_index, Active=True
+ warehouse_active : Size=12, Index={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, Active=True
Key : Lower : Body : Upper : Active
1 : -Inf : x[Harlingen,NYC] - y[Harlingen] : 0.0 : True
2 : -Inf : x[Harlingen,LA] - y[Harlingen] : 0.0 : True
@@ -69,4 +49,4 @@
11 : -Inf : x[Ashland,Chicago] - y[Ashland] : 0.0 : True
12 : -Inf : x[Ashland,Houston] - y[Ashland] : 0.0 : True
-12 Declarations: x_index_0 x_index_1 x_index x y_index y obj demand_index demand warehouse_active_index warehouse_active num_warehouses
+6 Declarations: x y obj demand warehouse_active num_warehouses
diff --git a/examples/pyomobook/overview-ch/wl_mutable.py b/examples/pyomobook/overview-ch/wl_mutable.py
index e5c4f5e9dbb..8e129dd3c49 100644
--- a/examples/pyomobook/overview-ch/wl_mutable.py
+++ b/examples/pyomobook/overview-ch/wl_mutable.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_mutable.py: warehouse location problem with mutable param
import pyomo.environ as pyo
diff --git a/examples/pyomobook/overview-ch/wl_mutable_excel.py b/examples/pyomobook/overview-ch/wl_mutable_excel.py
index 0906fbb25b3..935fa4963e5 100644
--- a/examples/pyomobook/overview-ch/wl_mutable_excel.py
+++ b/examples/pyomobook/overview-ch/wl_mutable_excel.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_mutable_excel.py: solve problem with different values for P
import pandas
import pyomo.environ as pyo
diff --git a/examples/pyomobook/overview-ch/wl_scalar.py b/examples/pyomobook/overview-ch/wl_scalar.py
index ac10fbe8265..6f538baedb8 100644
--- a/examples/pyomobook/overview-ch/wl_scalar.py
+++ b/examples/pyomobook/overview-ch/wl_scalar.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl_scalar.py: snippets that show the warehouse location problem implemented as scalar quantities
import pyomo.environ as pyo
diff --git a/examples/pyomobook/performance-ch/SparseSets.py b/examples/pyomobook/performance-ch/SparseSets.py
index 90d097b53aa..519808306de 100644
--- a/examples/pyomobook/performance-ch/SparseSets.py
+++ b/examples/pyomobook/performance-ch/SparseSets.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/performance-ch/lin_expr.py b/examples/pyomobook/performance-ch/lin_expr.py
index 75f4e70ec2a..af50ddd6228 100644
--- a/examples/pyomobook/performance-ch/lin_expr.py
+++ b/examples/pyomobook/performance-ch/lin_expr.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
from pyomo.common.timing import TicTocTimer
from pyomo.core.expr.numeric_expr import LinearExpression
diff --git a/examples/pyomobook/performance-ch/persistent.py b/examples/pyomobook/performance-ch/persistent.py
index 98207909cb6..67f8c656cfe 100644
--- a/examples/pyomobook/performance-ch/persistent.py
+++ b/examples/pyomobook/performance-ch/persistent.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# @model:
import pyomo.environ as pyo
diff --git a/examples/pyomobook/performance-ch/wl.py b/examples/pyomobook/performance-ch/wl.py
index 34c8a73f36e..000f81272a1 100644
--- a/examples/pyomobook/performance-ch/wl.py
+++ b/examples/pyomobook/performance-ch/wl.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# wl.py # define a script to demonstrate performance profiling and improvements
# @imports:
import pyomo.environ as pyo # import pyomo environment
diff --git a/examples/pyomobook/performance-ch/wl.txt b/examples/pyomobook/performance-ch/wl.txt
index f7d2e0ada19..b762acf55cf 100644
--- a/examples/pyomobook/performance-ch/wl.txt
+++ b/examples/pyomobook/performance-ch/wl.txt
@@ -3,94 +3,102 @@ Building model
0 seconds to construct Block ConcreteModel; 1 index total
0 seconds to construct Set Any; 1 index total
0 seconds to construct Param P; 1 index total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
0 seconds to construct Set SetProduct_OrderedSet; 1 index total
- 0 seconds to construct Set SetProduct_OrderedSet; 1 index total
0.02 seconds to construct Var x; 40000 indices total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
0 seconds to construct Var y; 200 indices total
- 0.13 seconds to construct Objective obj; 1 index total
+ 0.14 seconds to construct Objective obj; 1 index total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
0.13 seconds to construct Constraint demand; 200 indices total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
0 seconds to construct Set SetProduct_OrderedSet; 1 index total
- 0 seconds to construct Set SetProduct_OrderedSet; 1 index total
- 0.48 seconds to construct Constraint warehouse_active; 40000 indices total
+ 0.50 seconds to construct Constraint warehouse_active; 40000 indices total
0 seconds to construct Constraint num_warehouses; 1 index total
Building model with LinearExpression
------------------------------------
0 seconds to construct Block ConcreteModel; 1 index total
0 seconds to construct Set Any; 1 index total
0 seconds to construct Param P; 1 index total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
0 seconds to construct Set SetProduct_OrderedSet; 1 index total
- 0 seconds to construct Set SetProduct_OrderedSet; 1 index total
0.02 seconds to construct Var x; 40000 indices total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
0 seconds to construct Var y; 200 indices total
- 0.06 seconds to construct Objective obj; 1 index total
+ 0.20 seconds to construct Objective obj; 1 index total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
- 0.18 seconds to construct Constraint demand; 200 indices total
+ 0.05 seconds to construct Constraint demand; 200 indices total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
+ 0 seconds to construct SetOf OrderedSetOf
0 seconds to construct Set OrderedScalarSet; 1 index total
0 seconds to construct Set SetProduct_OrderedSet; 1 index total
- 0 seconds to construct Set SetProduct_OrderedSet; 1 index total
- 0.33 seconds to construct Constraint warehouse_active; 40000 indices total
+ 0.34 seconds to construct Constraint warehouse_active; 40000 indices total
0 seconds to construct Constraint num_warehouses; 1 index total
[ 0.00] start
-[+ 0.79] Built model
-[+ 2.56] Wrote LP file and solved
-[+ 10.96] Finished parameter sweep
- 7372057 function calls (7368345 primitive calls) in 13.627 seconds
+[+ 1.00] Built model
+[+ 2.28] Wrote LP file and solved
+[+ 9.06] Finished parameter sweep
+ 7294708 function calls (7291012 primitive calls) in 10.989 seconds
Ordered by: cumulative time
List reduced from 673 to 15 due to restriction <15>
ncalls tottime percall cumtime percall filename:lineno(function)
- 1 0.001 0.001 13.627 13.627 /home/jdsiiro/Research/pyomo/examples/pyomobook/performance-ch/wl.py:132(solve_parametric)
- 30 0.002 0.000 13.551 0.452 /home/jdsiiro/Research/pyomo/pyomo/opt/base/solvers.py:530(solve)
- 30 0.001 0.000 10.383 0.346 /home/jdsiiro/Research/pyomo/pyomo/opt/solver/shellcmd.py:247(_apply_solver)
- 30 0.002 0.000 10.381 0.346 /home/jdsiiro/Research/pyomo/pyomo/opt/solver/shellcmd.py:310(_execute_command)
- 30 0.001 0.000 10.360 0.345 /projects/sems/install/rhel7-x86_64/pyomo/compiler/python/3.11.6/lib/python3.11/subprocess.py:506(run)
- 30 0.000 0.000 10.288 0.343 /projects/sems/install/rhel7-x86_64/pyomo/compiler/python/3.11.6/lib/python3.11/subprocess.py:1165(communicate)
- 60 0.000 0.000 10.287 0.171 /projects/sems/install/rhel7-x86_64/pyomo/compiler/python/3.11.6/lib/python3.11/subprocess.py:1259(wait)
- 60 0.001 0.000 10.287 0.171 /projects/sems/install/rhel7-x86_64/pyomo/compiler/python/3.11.6/lib/python3.11/subprocess.py:2014(_wait)
- 30 0.000 0.000 10.286 0.343 /projects/sems/install/rhel7-x86_64/pyomo/compiler/python/3.11.6/lib/python3.11/subprocess.py:2001(_try_wait)
- 30 10.286 0.343 10.286 0.343 {built-in method posix.waitpid}
- 30 0.000 0.000 2.123 0.071 /home/jdsiiro/Research/pyomo/pyomo/solvers/plugins/solvers/GUROBI.py:214(_presolve)
- 30 0.000 0.000 2.122 0.071 /home/jdsiiro/Research/pyomo/pyomo/opt/solver/shellcmd.py:215(_presolve)
- 30 0.000 0.000 2.114 0.070 /home/jdsiiro/Research/pyomo/pyomo/opt/base/solvers.py:687(_presolve)
- 30 0.000 0.000 2.114 0.070 /home/jdsiiro/Research/pyomo/pyomo/opt/base/solvers.py:756(_convert_problem)
- 30 0.001 0.000 2.114 0.070 /home/jdsiiro/Research/pyomo/pyomo/opt/base/convert.py:27(convert_problem)
+ 1 0.001 0.001 10.989 10.989 pyomo/examples/pyomobook/performance-ch/wl.py:132(solve_parametric)
+ 30 0.002 0.000 10.913 0.364 pyomo/pyomo/opt/base/solvers.py:530(solve)
+ 30 0.001 0.000 7.816 0.261 pyomo/pyomo/opt/solver/shellcmd.py:247(_apply_solver)
+ 30 0.002 0.000 7.814 0.260 pyomo/pyomo/opt/solver/shellcmd.py:310(_execute_command)
+ 30 0.001 0.000 7.793 0.260 /lib/python3.11/subprocess.py:506(run)
+ 30 0.000 0.000 7.609 0.254 /lib/python3.11/subprocess.py:1165(communicate)
+ 60 0.000 0.000 7.608 0.127 /lib/python3.11/subprocess.py:1259(wait)
+ 60 0.000 0.000 7.608 0.127 /lib/python3.11/subprocess.py:2014(_wait)
+ 30 0.000 0.000 7.608 0.254 /lib/python3.11/subprocess.py:2001(_try_wait)
+ 30 7.607 0.254 7.607 0.254 {built-in method posix.waitpid}
+ 30 0.000 0.000 2.166 0.072 pyomo/pyomo/solvers/plugins/solvers/GUROBI.py:214(_presolve)
+ 30 0.000 0.000 2.166 0.072 pyomo/pyomo/opt/solver/shellcmd.py:215(_presolve)
+ 30 0.000 0.000 2.156 0.072 pyomo/pyomo/opt/base/solvers.py:687(_presolve)
+ 30 0.000 0.000 2.156 0.072 pyomo/pyomo/opt/base/solvers.py:754(_convert_problem)
+ 30 0.001 0.000 2.156 0.072 pyomo/pyomo/opt/base/convert.py:27(convert_problem)
- 7372057 function calls (7368345 primitive calls) in 13.627 seconds
+ 7294708 function calls (7291012 primitive calls) in 10.989 seconds
Ordered by: internal time
List reduced from 673 to 15 due to restriction <15>
ncalls tottime percall cumtime percall filename:lineno(function)
- 30 10.286 0.343 10.286 0.343 {built-in method posix.waitpid}
- 30 0.325 0.011 2.078 0.069 /home/jdsiiro/Research/pyomo/pyomo/repn/plugins/lp_writer.py:250(write)
- 76560 0.278 0.000 0.668 0.000 /home/jdsiiro/Research/pyomo/pyomo/repn/plugins/lp_writer.py:576(write_expression)
- 30 0.248 0.008 0.508 0.017 /home/jdsiiro/Research/pyomo/pyomo/solvers/plugins/solvers/GUROBI.py:394(process_soln_file)
- 76560 0.221 0.000 0.395 0.000 /home/jdsiiro/Research/pyomo/pyomo/repn/linear.py:664(_before_linear)
- 301530 0.131 0.000 0.178 0.000 /home/jdsiiro/Research/pyomo/pyomo/core/expr/symbol_map.py:133(getSymbol)
- 30 0.119 0.004 0.192 0.006 /home/jdsiiro/Research/pyomo/pyomo/core/base/PyomoModel.py:461(select)
- 77190 0.117 0.000 0.161 0.000 /home/jdsiiro/Research/pyomo/pyomo/solvers/plugins/solvers/GUROBI.py:451()
- 30 0.116 0.004 0.285 0.010 /home/jdsiiro/Research/pyomo/pyomo/core/base/PyomoModel.py:337(add_solution)
- 76530 0.080 0.000 0.106 0.000 /home/jdsiiro/Research/pyomo/pyomo/core/expr/symbol_map.py:63(addSymbol)
- 239550 0.079 0.000 0.079 0.000 /home/jdsiiro/Research/pyomo/pyomo/core/base/indexed_component.py:611(__getitem__)
- 1062450 0.078 0.000 0.078 0.000 {built-in method builtins.id}
- 163050 0.074 0.000 0.128 0.000 /home/jdsiiro/Research/pyomo/pyomo/core/base/var.py:1045(__getitem__)
- 76560 0.074 0.000 0.080 0.000 /home/jdsiiro/Research/pyomo/pyomo/repn/linear.py:834(finalizeResult)
- 153150 0.073 0.000 0.191 0.000 /home/jdsiiro/Research/pyomo/pyomo/core/base/block.py:1505(_component_data_itervalues)
+ 30 7.607 0.254 7.607 0.254 {built-in method posix.waitpid}
+ 30 0.328 0.011 2.101 0.070 pyomo/pyomo/repn/plugins/lp_writer.py:250(write)
+ 76560 0.284 0.000 0.680 0.000 pyomo/pyomo/repn/plugins/lp_writer.py:576(write_expression)
+ 76560 0.220 0.000 0.388 0.000 pyomo/pyomo/repn/linear.py:664(_before_linear)
+ 30 0.209 0.007 0.438 0.015 pyomo/pyomo/solvers/plugins/solvers/GUROBI.py:394(process_soln_file)
+ 30 0.175 0.006 0.175 0.006 {built-in method _posixsubprocess.fork_exec}
+ 301530 0.134 0.000 0.181 0.000 pyomo/pyomo/core/expr/symbol_map.py:133(getSymbol)
+ 30 0.109 0.004 0.178 0.006 pyomo/pyomo/core/base/PyomoModel.py:461(select)
+ 77190 0.105 0.000 0.145 0.000 pyomo/pyomo/solvers/plugins/solvers/GUROBI.py:451()
+ 30 0.104 0.003 0.257 0.009 pyomo/pyomo/core/base/PyomoModel.py:337(add_solution)
+ 76530 0.081 0.000 0.109 0.000 pyomo/pyomo/core/expr/symbol_map.py:63(addSymbol)
+ 1062470 0.079 0.000 0.079 0.000 {built-in method builtins.id}
+ 76560 0.073 0.000 0.079 0.000 pyomo/pyomo/repn/linear.py:834(finalizeResult)
+ 239550 0.073 0.000 0.073 0.000 pyomo/pyomo/core/base/indexed_component.py:612(__getitem__)
+ 153150 0.070 0.000 0.179 0.000 pyomo/pyomo/core/base/block.py:1463(_component_data_itervalues)
[ 0.00] Resetting the tic/toc delta timer
-[+ 0.66] Finished parameter sweep with persistent interface
+[+ 0.49] Finished parameter sweep with persistent interface
diff --git a/examples/pyomobook/pyomo-components-ch/con_declaration.py b/examples/pyomobook/pyomo-components-ch/con_declaration.py
index 7775c1b26a0..0890ba4771b 100644
--- a/examples/pyomobook/pyomo-components-ch/con_declaration.py
+++ b/examples/pyomobook/pyomo-components-ch/con_declaration.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/pyomo-components-ch/con_declaration.txt b/examples/pyomobook/pyomo-components-ch/con_declaration.txt
index 019cd448eb0..b4709bd5490 100644
--- a/examples/pyomobook/pyomo-components-ch/con_declaration.txt
+++ b/examples/pyomobook/pyomo-components-ch/con_declaration.txt
@@ -1,10 +1,5 @@
-1 Set Declarations
- x_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {1, 2}
-
1 Var Declarations
- x : Size=2, Index=x_index
+ x : Size=2, Index={1, 2}
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : None : 1.0 : None : False : False : Reals
2 : None : 1.0 : None : False : False : Reals
@@ -14,14 +9,9 @@
Key : Lower : Body : Upper : Active
None : -Inf : x[2] - x[1] : 7.5 : True
-3 Declarations: x_index x diff
-1 Set Declarations
- x_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 2 : {1, 2}
-
+2 Declarations: x diff
1 Var Declarations
- x : Size=2, Index=x_index
+ x : Size=2, Index={1, 2}
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : None : 1.0 : None : False : False : Reals
2 : None : 1.0 : None : False : False : Reals
@@ -31,40 +21,24 @@
Key : Lower : Body : Upper : Active
None : -Inf : x[2] - x[1] : 7.5 : True
-3 Declarations: x_index x diff
-2 Set Declarations
- CoverConstr_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
- y_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
-
+2 Declarations: x diff
1 Var Declarations
- y : Size=3, Index=y_index
+ y : Size=3, Index={1, 2, 3}
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : 0 : 0.0 : None : False : False : NonNegativeReals
2 : 0 : 0.0 : None : False : False : NonNegativeReals
3 : 0 : 0.0 : None : False : False : NonNegativeReals
1 Constraint Declarations
- CoverConstr : Size=3, Index=CoverConstr_index, Active=True
+ CoverConstr : Size=3, Index={1, 2, 3}, Active=True
Key : Lower : Body : Upper : Active
1 : 1.0 : y[1] : +Inf : True
2 : 2.9 : 3.1*y[2] : +Inf : True
3 : 3.1 : 4.5*y[3] : +Inf : True
-4 Declarations: y_index y CoverConstr_index CoverConstr
-2 Set Declarations
- Pred_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 5 : {1, 2, 3, 4, 5}
- StartTime_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 5 : {1, 2, 3, 4, 5}
-
+2 Declarations: y CoverConstr
1 Var Declarations
- StartTime : Size=5, Index=StartTime_index
+ StartTime : Size=5, Index={1, 2, 3, 4, 5}
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : None : 1.0 : None : False : False : Reals
2 : None : 1.0 : None : False : False : Reals
@@ -73,14 +47,14 @@
5 : None : 1.0 : None : False : False : Reals
1 Constraint Declarations
- Pred : Size=4, Index=Pred_index, Active=True
+ Pred : Size=4, Index={1, 2, 3, 4, 5}, Active=True
Key : Lower : Body : Upper : Active
1 : -Inf : StartTime[1] - StartTime[2] : 0.0 : True
2 : -Inf : StartTime[2] - StartTime[3] : 0.0 : True
3 : -Inf : StartTime[3] - StartTime[4] : 0.0 : True
4 : -Inf : StartTime[4] - StartTime[5] : 0.0 : True
-4 Declarations: StartTime_index StartTime Pred_index Pred
+2 Declarations: StartTime Pred
0.0
inf
7.5
diff --git a/examples/pyomobook/pyomo-components-ch/examples.py b/examples/pyomobook/pyomo-components-ch/examples.py
index 6ba96792e28..1a59e9e308e 100644
--- a/examples/pyomobook/pyomo-components-ch/examples.py
+++ b/examples/pyomobook/pyomo-components-ch/examples.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
print("indexed1")
diff --git a/examples/pyomobook/pyomo-components-ch/examples.txt b/examples/pyomobook/pyomo-components-ch/examples.txt
index 635b988cbcd..27ea1ba130b 100644
--- a/examples/pyomobook/pyomo-components-ch/examples.txt
+++ b/examples/pyomobook/pyomo-components-ch/examples.txt
@@ -1,20 +1,17 @@
indexed1
-3 Set Declarations
+2 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {1, 2, 3}
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 2 : {'Q', 'R'}
- y_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 6 : {(1, 'Q'), (1, 'R'), (2, 'Q'), (2, 'R'), (3, 'Q'), (3, 'R')}
2 Var Declarations
x : Size=1, Index=None
Key : Lower : Value : Upper : Fixed : Stale : Domain
None : None : None : None : False : True : Reals
- y : Size=6, Index=y_index
+ y : Size=6, Index=A*B
Key : Lower : Value : Upper : Fixed : Stale : Domain
(1, 'Q') : None : None : None : False : True : Reals
(1, 'R') : None : None : None : False : True : Reals
@@ -38,4 +35,4 @@ indexed1
2 : -Inf : 2*x : 0.0 : True
3 : -Inf : 3*x : 0.0 : True
-8 Declarations: A B x y_index y o c d
+7 Declarations: A B x y o c d
diff --git a/examples/pyomobook/pyomo-components-ch/expr_declaration.py b/examples/pyomobook/pyomo-components-ch/expr_declaration.py
index 8974a4d406a..da0d854e513 100644
--- a/examples/pyomobook/pyomo-components-ch/expr_declaration.py
+++ b/examples/pyomobook/pyomo-components-ch/expr_declaration.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/pyomo-components-ch/expr_declaration.txt b/examples/pyomobook/pyomo-components-ch/expr_declaration.txt
index 66c99f6502a..86e0feac27f 100644
--- a/examples/pyomobook/pyomo-components-ch/expr_declaration.txt
+++ b/examples/pyomobook/pyomo-components-ch/expr_declaration.txt
@@ -18,28 +18,20 @@
None : x + 2
3 Declarations: x e1 e2
-2 Set Declarations
- e_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
- x_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
-
1 Var Declarations
- x : Size=3, Index=x_index
+ x : Size=3, Index={1, 2, 3}
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : None : None : None : False : True : Reals
2 : None : None : None : False : True : Reals
3 : None : None : None : False : True : Reals
1 Expression Declarations
- e : Size=2, Index=e_index
+ e : Size=2, Index={1, 2, 3}
Key : Expression
2 : x[2]**2
3 : x[3]**2
-4 Declarations: x_index x e_index e
+2 Declarations: x e
1 Var Declarations
x : Size=1, Index=None
Key : Lower : Value : Upper : Fixed : Stale : Domain
diff --git a/examples/pyomobook/pyomo-components-ch/obj_declaration.py b/examples/pyomobook/pyomo-components-ch/obj_declaration.py
index 2c26c2b3363..a63fc441206 100644
--- a/examples/pyomobook/pyomo-components-ch/obj_declaration.py
+++ b/examples/pyomobook/pyomo-components-ch/obj_declaration.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/pyomo-components-ch/obj_declaration.txt b/examples/pyomobook/pyomo-components-ch/obj_declaration.txt
index e43134b8d92..e4d4b02a252 100644
--- a/examples/pyomobook/pyomo-components-ch/obj_declaration.txt
+++ b/examples/pyomobook/pyomo-components-ch/obj_declaration.txt
@@ -14,7 +14,7 @@ declexprrule
Model unknown
Variables:
- x : Size=2, Index=x_index
+ x : Size=2, Index={1, 2}
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : None : 1.0 : None : False : False : Reals
2 : None : 1.0 : None : False : False : Reals
@@ -34,19 +34,19 @@ declskip
Model unknown
Variables:
- x : Size=3, Index=x_index
+ x : Size=3, Index={Q, R, S}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Q : None : 1.0 : None : False : False : Reals
R : None : 1.0 : None : False : False : Reals
S : None : 1.0 : None : False : False : Reals
Objectives:
- d : Size=3, Index=d_index, Active=True
+ d : Size=3, Index={Q, R, S}, Active=True
Key : Active : Value
Q : True : 1.0
R : True : 1.0
S : True : 1.0
- e : Size=2, Index=e_index, Active=True
+ e : Size=2, Index={Q, R, S}, Active=True
Key : Active : Value
Q : True : 1.0
S : True : 1.0
@@ -55,12 +55,12 @@ Model unknown
None
value
x[Q] + 2*x[R]
-1
+minimize
6.5
Model unknown
Variables:
- x : Size=2, Index=x_index
+ x : Size=2, Index={Q, R}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Q : None : 1.5 : None : False : False : Reals
R : None : 2.5 : None : False : False : Reals
diff --git a/examples/pyomobook/pyomo-components-ch/param_declaration.py b/examples/pyomobook/pyomo-components-ch/param_declaration.py
index a9d3256abfe..98b16548c28 100644
--- a/examples/pyomobook/pyomo-components-ch/param_declaration.py
+++ b/examples/pyomobook/pyomo-components-ch/param_declaration.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/pyomo-components-ch/param_declaration.txt b/examples/pyomobook/pyomo-components-ch/param_declaration.txt
index 9b8ce9cacdb..8c8a49eedc6 100644
--- a/examples/pyomobook/pyomo-components-ch/param_declaration.txt
+++ b/examples/pyomobook/pyomo-components-ch/param_declaration.txt
@@ -1,16 +1,13 @@
-3 Set Declarations
+2 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {1, 2, 3}
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 2 : {'A', 'B'}
- T_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 6 : {(1, 'A'), (1, 'B'), (2, 'A'), (2, 'B'), (3, 'A'), (3, 'B')}
3 Param Declarations
- T : Size=3, Index=T_index, Domain=Any, Default=None, Mutable=False
+ T : Size=3, Index=A*B, Domain=Any, Default=None, Mutable=False
Key : Value
(1, 'A') : 10
(2, 'B') : 20
@@ -24,4 +21,4 @@
Key : Value
None : 32
-6 Declarations: Z A B U T_index T
+5 Declarations: Z A B U T
diff --git a/examples/pyomobook/pyomo-components-ch/param_initialization.py b/examples/pyomobook/pyomo-components-ch/param_initialization.py
index 11c257d2c31..88da8a68354 100644
--- a/examples/pyomobook/pyomo-components-ch/param_initialization.py
+++ b/examples/pyomobook/pyomo-components-ch/param_initialization.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/pyomo-components-ch/param_initialization.txt b/examples/pyomobook/pyomo-components-ch/param_initialization.txt
index d1ac6aba989..e0bcdf11a71 100644
--- a/examples/pyomobook/pyomo-components-ch/param_initialization.txt
+++ b/examples/pyomobook/pyomo-components-ch/param_initialization.txt
@@ -1,27 +1,15 @@
-6 Set Declarations
+2 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {1, 2, 3}
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {1, 2, 3}
- T_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*B : 9 : {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}
- U_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*A : 9 : {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}
- XX_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*A : 9 : {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}
- X_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : A*A : 9 : {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}
5 Param Declarations
- T : Size=0, Index=T_index, Domain=Any, Default=None, Mutable=False
+ T : Size=0, Index=A*B, Domain=Any, Default=None, Mutable=False
Key : Value
- U : Size=9, Index=U_index, Domain=Any, Default=0, Mutable=False
+ U : Size=9, Index=A*A, Domain=Any, Default=0, Mutable=False
Key : Value
(1, 1) : 10
(2, 2) : 20
@@ -30,7 +18,7 @@
Key : Value
1 : 10
3 : 30
- X : Size=9, Index=X_index, Domain=Any, Default=None, Mutable=False
+ X : Size=9, Index=A*A, Domain=Any, Default=None, Mutable=False
Key : Value
(1, 1) : 1
(1, 2) : 2
@@ -41,7 +29,7 @@
(3, 1) : 3
(3, 2) : 6
(3, 3) : 9
- XX : Size=9, Index=XX_index, Domain=Any, Default=None, Mutable=False
+ XX : Size=9, Index=A*A, Domain=Any, Default=None, Mutable=False
Key : Value
(1, 1) : 1
(1, 2) : 2
@@ -53,7 +41,7 @@
(3, 2) : 8
(3, 3) : 14
-11 Declarations: A X_index X XX_index XX B W U_index U T_index T
+7 Declarations: A X XX B W U T
2
3
False
diff --git a/examples/pyomobook/pyomo-components-ch/param_misc.py b/examples/pyomobook/pyomo-components-ch/param_misc.py
index baf76cc7c03..72fca60f787 100644
--- a/examples/pyomobook/pyomo-components-ch/param_misc.py
+++ b/examples/pyomobook/pyomo-components-ch/param_misc.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
# @mutable1:
diff --git a/examples/pyomobook/pyomo-components-ch/param_validation.py b/examples/pyomobook/pyomo-components-ch/param_validation.py
index c82657c8d0f..baf5f0ac1e2 100644
--- a/examples/pyomobook/pyomo-components-ch/param_validation.py
+++ b/examples/pyomobook/pyomo-components-ch/param_validation.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/pyomo-components-ch/rangeset.py b/examples/pyomobook/pyomo-components-ch/rangeset.py
index d5e1015064c..169060e9ab2 100644
--- a/examples/pyomobook/pyomo-components-ch/rangeset.py
+++ b/examples/pyomobook/pyomo-components-ch/rangeset.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/pyomo-components-ch/set_declaration.py b/examples/pyomobook/pyomo-components-ch/set_declaration.py
index 1a507d4f588..bf3cfa1be15 100644
--- a/examples/pyomobook/pyomo-components-ch/set_declaration.py
+++ b/examples/pyomobook/pyomo-components-ch/set_declaration.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/pyomo-components-ch/set_declaration.txt b/examples/pyomobook/pyomo-components-ch/set_declaration.txt
index bdbb7376de4..a588e5601b6 100644
--- a/examples/pyomobook/pyomo-components-ch/set_declaration.txt
+++ b/examples/pyomobook/pyomo-components-ch/set_declaration.txt
@@ -5,22 +5,16 @@
1 Declarations: A
0 Declarations:
-4 Set Declarations
- E : Size=1, Index=E_index, Ordered=Insertion
+2 Set Declarations
+ E : Size=1, Index={1, 2, 3}, Ordered=Insertion
Key : Dimen : Domain : Size : Members
2 : 1 : Any : 3 : {21, 22, 23}
- E_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
- F : Size=2, Index=F_index, Ordered=Insertion
+ F : Size=2, Index={1, 2, 3}, Ordered=Insertion
Key : Dimen : Domain : Size : Members
1 : 1 : Any : 3 : {11, 12, 13}
3 : 1 : Any : 3 : {31, 32, 33}
- F_index : Size=1, Index=None, Ordered=False
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
-4 Declarations: E_index E F_index F
+2 Declarations: E F
6 Set Declarations
A : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
diff --git a/examples/pyomobook/pyomo-components-ch/set_initialization.py b/examples/pyomobook/pyomo-components-ch/set_initialization.py
index 89dbaa713db..bdfd662c985 100644
--- a/examples/pyomobook/pyomo-components-ch/set_initialization.py
+++ b/examples/pyomobook/pyomo-components-ch/set_initialization.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/pyomo-components-ch/set_initialization.txt b/examples/pyomobook/pyomo-components-ch/set_initialization.txt
index af2ba54a8d2..29900ccb7b2 100644
--- a/examples/pyomobook/pyomo-components-ch/set_initialization.txt
+++ b/examples/pyomobook/pyomo-components-ch/set_initialization.txt
@@ -1,19 +1,16 @@
-10 Set Declarations
+7 Set Declarations
B : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 3 : {2, 3, 4}
C : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 2 : Any : 2 : {(1, 4), (9, 16)}
- F : Size=3, Index=F_index, Ordered=Insertion
+ F : Size=3, Index={2, 3, 4}, Ordered=Insertion
Key : Dimen : Domain : Size : Members
2 : 1 : Any : 3 : {1, 3, 5}
3 : 1 : Any : 3 : {2, 4, 6}
4 : 1 : Any : 3 : {3, 5, 7}
- F_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {2, 3, 4}
- J : Size=9, Index=J_index, Ordered=Insertion
+ J : Size=9, Index=B*B, Ordered=Insertion
Key : Dimen : Domain : Size : Members
(2, 2) : 1 : Any : 4 : {0, 1, 2, 3}
(2, 3) : 1 : Any : 6 : {0, 1, 2, 3, 4, 5}
@@ -24,21 +21,15 @@
(4, 2) : 1 : Any : 8 : {0, 1, 2, 3, 4, 5, 6, 7}
(4, 3) : 1 : Any : 12 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
(4, 4) : 1 : Any : 16 : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
- J_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : B*B : 9 : {(2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4), (4, 2), (4, 3), (4, 4)}
P : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 5 : {1, 2, 3, 5, 7}
Q : Size=1, Index=None, Ordered=Insertion
Key : Dimen : Domain : Size : Members
None : 1 : Any : 4 : {4, 6, 8, 9}
- R : Size=2, Index=R_index, Ordered=Insertion
+ R : Size=2, Index={1, 2, 3}, Ordered=Insertion
Key : Dimen : Domain : Size : Members
1 : 1 : Any : 1 : {1,}
2 : 1 : Any : 2 : {1, 2}
- R_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {1, 2, 3}
-10 Declarations: B C F_index F J_index J P Q R_index R
+7 Declarations: B C F J P Q R
diff --git a/examples/pyomobook/pyomo-components-ch/set_misc.py b/examples/pyomobook/pyomo-components-ch/set_misc.py
index 9a795b196b8..20ed9518f52 100644
--- a/examples/pyomobook/pyomo-components-ch/set_misc.py
+++ b/examples/pyomobook/pyomo-components-ch/set_misc.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/pyomo-components-ch/set_options.py b/examples/pyomobook/pyomo-components-ch/set_options.py
index 8d49882de2f..30c0b49706d 100644
--- a/examples/pyomobook/pyomo-components-ch/set_options.py
+++ b/examples/pyomobook/pyomo-components-ch/set_options.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/pyomo-components-ch/set_validation.py b/examples/pyomobook/pyomo-components-ch/set_validation.py
index a55dfc9ab7c..2300c0be693 100644
--- a/examples/pyomobook/pyomo-components-ch/set_validation.py
+++ b/examples/pyomobook/pyomo-components-ch/set_validation.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.AbstractModel()
diff --git a/examples/pyomobook/pyomo-components-ch/suffix_declaration.py b/examples/pyomobook/pyomo-components-ch/suffix_declaration.py
index 650669ef5a6..619093712f1 100644
--- a/examples/pyomobook/pyomo-components-ch/suffix_declaration.py
+++ b/examples/pyomobook/pyomo-components-ch/suffix_declaration.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
print('')
diff --git a/examples/pyomobook/pyomo-components-ch/var_declaration.py b/examples/pyomobook/pyomo-components-ch/var_declaration.py
index 60d3b00756a..2ee5d7fb749 100644
--- a/examples/pyomobook/pyomo-components-ch/var_declaration.py
+++ b/examples/pyomobook/pyomo-components-ch/var_declaration.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/python-ch/BadIndent.py b/examples/pyomobook/python-ch/BadIndent.py
index 6ab545a6f46..4a00cae12ef 100644
--- a/examples/pyomobook/python-ch/BadIndent.py
+++ b/examples/pyomobook/python-ch/BadIndent.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# This comment is the first line of BadIndent.py,
# which will cause Python to give an error message
# concerning indentation.
diff --git a/examples/pyomobook/python-ch/LineExample.py b/examples/pyomobook/python-ch/LineExample.py
index 0109a64167e..31cface5760 100644
--- a/examples/pyomobook/python-ch/LineExample.py
+++ b/examples/pyomobook/python-ch/LineExample.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# This comment is the first line of LineExample.py
# all characters on a line after the #-character are
# ignored by Python
diff --git a/examples/pyomobook/python-ch/class.py b/examples/pyomobook/python-ch/class.py
index 562cef07ea7..a09f991d37b 100644
--- a/examples/pyomobook/python-ch/class.py
+++ b/examples/pyomobook/python-ch/class.py
@@ -1,25 +1,36 @@
-# class.py
-
-
-# @all:
-class IntLocker:
- sint = None
-
- def __init__(self, i):
- self.set_value(i)
-
- def set_value(self, i):
- if type(i) is not int:
- print("Error: %d is not integer." % i)
- else:
- self.sint = i
-
- def pprint(self):
- print("The Int Locker has " + str(self.sint))
-
-
-a = IntLocker(3)
-a.pprint() # prints: The Int Locker has 3
-a.set_value(5)
-a.pprint() # prints: The Int Locker has 5
-# @:all
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+# class.py
+
+
+# @all:
+class IntLocker:
+ sint = None
+
+ def __init__(self, i):
+ self.set_value(i)
+
+ def set_value(self, i):
+ if type(i) is not int:
+ print("Error: %d is not integer." % i)
+ else:
+ self.sint = i
+
+ def pprint(self):
+ print("The Int Locker has " + str(self.sint))
+
+
+a = IntLocker(3)
+a.pprint() # prints: The Int Locker has 3
+a.set_value(5)
+a.pprint() # prints: The Int Locker has 5
+# @:all
diff --git a/examples/pyomobook/python-ch/ctob.py b/examples/pyomobook/python-ch/ctob.py
index e418d27f103..8945e4863de 100644
--- a/examples/pyomobook/python-ch/ctob.py
+++ b/examples/pyomobook/python-ch/ctob.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# An example of a silly decorator to change 'c' to 'b'
# in the return value of a function.
diff --git a/examples/pyomobook/python-ch/example.py b/examples/pyomobook/python-ch/example.py
index 0a404add58d..184153545a3 100644
--- a/examples/pyomobook/python-ch/example.py
+++ b/examples/pyomobook/python-ch/example.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# This is a comment line, which is ignored by Python
print("Hello World")
diff --git a/examples/pyomobook/python-ch/example2.py b/examples/pyomobook/python-ch/example2.py
index da7d14e24ae..9a6a28bedbd 100644
--- a/examples/pyomobook/python-ch/example2.py
+++ b/examples/pyomobook/python-ch/example2.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# A modified example.py program
print("Hello World")
diff --git a/examples/pyomobook/python-ch/functions.py b/examples/pyomobook/python-ch/functions.py
index 7948c5e55df..97fb77edbe4 100644
--- a/examples/pyomobook/python-ch/functions.py
+++ b/examples/pyomobook/python-ch/functions.py
@@ -1,24 +1,35 @@
-# functions.py
-
-
-# @all:
-def Apply(f, a):
- r = []
- for i in range(len(a)):
- r.append(f(a[i]))
- return r
-
-
-def SqifOdd(x):
- # if x is odd, 2*int(x/2) is not x
- # due to integer divide of x/2
- if 2 * int(x / 2) == x:
- return x
- else:
- return x * x
-
-
-ShortList = range(4)
-B = Apply(SqifOdd, ShortList)
-print(B)
-# @:all
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+# functions.py
+
+
+# @all:
+def Apply(f, a):
+ r = []
+ for i in range(len(a)):
+ r.append(f(a[i]))
+ return r
+
+
+def SqifOdd(x):
+ # if x is odd, 2*int(x/2) is not x
+ # due to integer divide of x/2
+ if 2 * int(x / 2) == x:
+ return x
+ else:
+ return x * x
+
+
+ShortList = range(4)
+B = Apply(SqifOdd, ShortList)
+print(B)
+# @:all
diff --git a/examples/pyomobook/python-ch/iterate.py b/examples/pyomobook/python-ch/iterate.py
index 3a3422b2a09..50d74f93da7 100644
--- a/examples/pyomobook/python-ch/iterate.py
+++ b/examples/pyomobook/python-ch/iterate.py
@@ -1,18 +1,29 @@
-# iterate.py
-
-# @all:
-D = {'Mary': 231}
-D['Bob'] = 123
-D['Alice'] = 331
-D['Ted'] = 987
-
-for i in sorted(D):
- if i == 'Alice':
- continue
- if i == 'John':
- print("Loop ends. Cleese alert!")
- break
- print(i + " " + str(D[i]))
-else:
- print("Cleese is not in the list.")
-# @:all
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+# iterate.py
+
+# @all:
+D = {'Mary': 231}
+D['Bob'] = 123
+D['Alice'] = 331
+D['Ted'] = 987
+
+for i in sorted(D):
+ if i == 'Alice':
+ continue
+ if i == 'John':
+ print("Loop ends. Cleese alert!")
+ break
+ print(i + " " + str(D[i]))
+else:
+ print("Cleese is not in the list.")
+# @:all
diff --git a/examples/pyomobook/python-ch/pythonconditional.py b/examples/pyomobook/python-ch/pythonconditional.py
index 205428e5ad1..a39e148622b 100644
--- a/examples/pyomobook/python-ch/pythonconditional.py
+++ b/examples/pyomobook/python-ch/pythonconditional.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# pythonconditional.py
# @all:
diff --git a/examples/pyomobook/scripts-ch/attributes.py b/examples/pyomobook/scripts-ch/attributes.py
index 643162082b6..c406bbf3e1c 100644
--- a/examples/pyomobook/scripts-ch/attributes.py
+++ b/examples/pyomobook/scripts-ch/attributes.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import json
import pyomo.environ as pyo
from warehouse_model import create_wl_model
diff --git a/examples/pyomobook/scripts-ch/prob_mod_ex.py b/examples/pyomobook/scripts-ch/prob_mod_ex.py
index 6d610e9b44a..dceafe9d4f0 100644
--- a/examples/pyomobook/scripts-ch/prob_mod_ex.py
+++ b/examples/pyomobook/scripts-ch/prob_mod_ex.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/scripts-ch/sudoku/sudoku.py b/examples/pyomobook/scripts-ch/sudoku/sudoku.py
index ea0c0044e1d..8aa39f91203 100644
--- a/examples/pyomobook/scripts-ch/sudoku/sudoku.py
+++ b/examples/pyomobook/scripts-ch/sudoku/sudoku.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
# create a standard python dict for mapping subsquares to
diff --git a/examples/pyomobook/scripts-ch/sudoku/sudoku_run.py b/examples/pyomobook/scripts-ch/sudoku/sudoku_run.py
index 266362308fa..b3f861f86b5 100644
--- a/examples/pyomobook/scripts-ch/sudoku/sudoku_run.py
+++ b/examples/pyomobook/scripts-ch/sudoku/sudoku_run.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from pyomo.opt import SolverFactory, TerminationCondition
from sudoku import create_sudoku_model, print_solution, add_integer_cut
diff --git a/examples/pyomobook/scripts-ch/value_expression.py b/examples/pyomobook/scripts-ch/value_expression.py
index 51c07500ea8..00c79fec501 100644
--- a/examples/pyomobook/scripts-ch/value_expression.py
+++ b/examples/pyomobook/scripts-ch/value_expression.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
model = pyo.ConcreteModel()
diff --git a/examples/pyomobook/scripts-ch/warehouse_cuts.py b/examples/pyomobook/scripts-ch/warehouse_cuts.py
index c6516e796af..345dc5540cb 100644
--- a/examples/pyomobook/scripts-ch/warehouse_cuts.py
+++ b/examples/pyomobook/scripts-ch/warehouse_cuts.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import warnings
warnings.filterwarnings("ignore")
diff --git a/examples/pyomobook/scripts-ch/warehouse_cuts.txt b/examples/pyomobook/scripts-ch/warehouse_cuts.txt
index 9afe6c4e944..1f097e06cea 100644
--- a/examples/pyomobook/scripts-ch/warehouse_cuts.txt
+++ b/examples/pyomobook/scripts-ch/warehouse_cuts.txt
@@ -1,7 +1,7 @@
--- Solver Status: optimal ---
Optimal Obj. Value = 2745.0
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 1.0 : 1 : False : False : Binary
Harlingen : 0 : 1.0 : 1 : False : False : Binary
@@ -9,7 +9,7 @@ y : Size=3, Index=y_index
--- Solver Status: optimal ---
Optimal Obj. Value = 3168.0
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 1.0 : 1 : False : False : Binary
Harlingen : 0 : 0.0 : 1 : False : False : Binary
@@ -17,7 +17,7 @@ y : Size=3, Index=y_index
--- Solver Status: optimal ---
Optimal Obj. Value = 3563.0
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 0.0 : 1 : False : False : Binary
Harlingen : 0 : 1.0 : 1 : False : False : Binary
@@ -25,7 +25,7 @@ y : Size=3, Index=y_index
--- Solver Status: optimal ---
Optimal Obj. Value = 3986.0
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 0.0 : 1 : False : False : Binary
Harlingen : 0 : 0.0 : 1 : False : False : Binary
@@ -33,7 +33,7 @@ y : Size=3, Index=y_index
--- Solver Status: optimal ---
Optimal Obj. Value = 4367.0
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 1.0 : 1 : False : False : Binary
Harlingen : 0 : 0.0 : 1 : False : False : Binary
@@ -41,7 +41,7 @@ y : Size=3, Index=y_index
--- Solver Status: optimal ---
Optimal Obj. Value = 5302.0
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 0.0 : 1 : False : False : Binary
Harlingen : 0 : 1.0 : 1 : False : False : Binary
diff --git a/examples/pyomobook/scripts-ch/warehouse_load_solutions.py b/examples/pyomobook/scripts-ch/warehouse_load_solutions.py
index 790333a0e64..d38412f84df 100644
--- a/examples/pyomobook/scripts-ch/warehouse_load_solutions.py
+++ b/examples/pyomobook/scripts-ch/warehouse_load_solutions.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import json
import pyomo.environ as pyo
from warehouse_model import create_wl_model
diff --git a/examples/pyomobook/scripts-ch/warehouse_model.py b/examples/pyomobook/scripts-ch/warehouse_model.py
index f5983d3cd89..149eb212759 100644
--- a/examples/pyomobook/scripts-ch/warehouse_model.py
+++ b/examples/pyomobook/scripts-ch/warehouse_model.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import pyomo.environ as pyo
diff --git a/examples/pyomobook/scripts-ch/warehouse_print.py b/examples/pyomobook/scripts-ch/warehouse_print.py
index e0e2f961345..8c862506bf0 100644
--- a/examples/pyomobook/scripts-ch/warehouse_print.py
+++ b/examples/pyomobook/scripts-ch/warehouse_print.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import json
import pyomo.environ as pyo
from warehouse_model import create_wl_model
diff --git a/examples/pyomobook/scripts-ch/warehouse_script.py b/examples/pyomobook/scripts-ch/warehouse_script.py
index f2635a45d3d..617b8036abf 100644
--- a/examples/pyomobook/scripts-ch/warehouse_script.py
+++ b/examples/pyomobook/scripts-ch/warehouse_script.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# @script:
import json
import pyomo.environ as pyo
diff --git a/examples/pyomobook/scripts-ch/warehouse_script.txt b/examples/pyomobook/scripts-ch/warehouse_script.txt
index b922643dd2b..fac3aef0880 100644
--- a/examples/pyomobook/scripts-ch/warehouse_script.txt
+++ b/examples/pyomobook/scripts-ch/warehouse_script.txt
@@ -1,36 +1,10 @@
-y : Size=3, Index=y_index
+y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 1.0 : 1 : False : False : Binary
Harlingen : 0 : 1.0 : 1 : False : False : Binary
Memphis : 0 : 0.0 : 1 : False : False : Binary
-8 Set Declarations
- one_per_cust_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 4 : {'NYC', 'LA', 'Chicago', 'Houston'}
- warehouse_active_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : warehouse_active_index_0*warehouse_active_index_1 : 12 : {('Harlingen', 'NYC'), ('Harlingen', 'LA'), ('Harlingen', 'Chicago'), ('Harlingen', 'Houston'), ('Memphis', 'NYC'), ('Memphis', 'LA'), ('Memphis', 'Chicago'), ('Memphis', 'Houston'), ('Ashland', 'NYC'), ('Ashland', 'LA'), ('Ashland', 'Chicago'), ('Ashland', 'Houston')}
- warehouse_active_index_0 : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {'Harlingen', 'Memphis', 'Ashland'}
- warehouse_active_index_1 : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 4 : {'NYC', 'LA', 'Chicago', 'Houston'}
- x_index : Size=1, Index=None, Ordered=True
- Key : Dimen : Domain : Size : Members
- None : 2 : x_index_0*x_index_1 : 12 : {('Harlingen', 'NYC'), ('Harlingen', 'LA'), ('Harlingen', 'Chicago'), ('Harlingen', 'Houston'), ('Memphis', 'NYC'), ('Memphis', 'LA'), ('Memphis', 'Chicago'), ('Memphis', 'Houston'), ('Ashland', 'NYC'), ('Ashland', 'LA'), ('Ashland', 'Chicago'), ('Ashland', 'Houston')}
- x_index_0 : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {'Harlingen', 'Memphis', 'Ashland'}
- x_index_1 : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 4 : {'NYC', 'LA', 'Chicago', 'Houston'}
- y_index : Size=1, Index=None, Ordered=Insertion
- Key : Dimen : Domain : Size : Members
- None : 1 : Any : 3 : {'Harlingen', 'Memphis', 'Ashland'}
-
2 Var Declarations
- x : Size=12, Index=x_index
+ x : Size=12, Index={Harlingen, Memphis, Ashland}*{NYC, LA, Chicago, Houston}
Key : Lower : Value : Upper : Fixed : Stale : Domain
('Ashland', 'Chicago') : 0 : 1.0 : 1 : False : False : Reals
('Ashland', 'Houston') : 0 : 0.0 : 1 : False : False : Reals
@@ -40,11 +14,11 @@ y : Size=3, Index=y_index
('Harlingen', 'Houston') : 0 : 1.0 : 1 : False : False : Reals
('Harlingen', 'LA') : 0 : 1.0 : 1 : False : False : Reals
('Harlingen', 'NYC') : 0 : 0.0 : 1 : False : False : Reals
- ('Memphis', 'Chicago') : 0 : -0.0 : 1 : False : False : Reals
+ ('Memphis', 'Chicago') : 0 : 0.0 : 1 : False : False : Reals
('Memphis', 'Houston') : 0 : 0.0 : 1 : False : False : Reals
('Memphis', 'LA') : 0 : 0.0 : 1 : False : False : Reals
('Memphis', 'NYC') : 0 : 0.0 : 1 : False : False : Reals
- y : Size=3, Index=y_index
+ y : Size=3, Index={Harlingen, Memphis, Ashland}
Key : Lower : Value : Upper : Fixed : Stale : Domain
Ashland : 0 : 1.0 : 1 : False : False : Binary
Harlingen : 0 : 1.0 : 1 : False : False : Binary
@@ -59,13 +33,13 @@ y : Size=3, Index=y_index
num_warehouses : Size=1, Index=None, Active=True
Key : Lower : Body : Upper : Active
None : -Inf : y[Harlingen] + y[Memphis] + y[Ashland] : 2.0 : True
- one_per_cust : Size=4, Index=one_per_cust_index, Active=True
+ one_per_cust : Size=4, Index={NYC, LA, Chicago, Houston}, Active=True
Key : Lower : Body : Upper : Active
Chicago : 1.0 : x[Harlingen,Chicago] + x[Memphis,Chicago] + x[Ashland,Chicago] : 1.0 : True
Houston : 1.0 : x[Harlingen,Houston] + x[Memphis,Houston] + x[Ashland,Houston] : 1.0 : True
LA : 1.0 : x[Harlingen,LA] + x[Memphis,LA] + x[Ashland,LA] : 1.0 : True
NYC : 1.0 : x[Harlingen,NYC] + x[Memphis,NYC] + x[Ashland,NYC] : 1.0 : True
- warehouse_active : Size=12, Index=warehouse_active_index, Active=True
+ warehouse_active : Size=12, Index={Harlingen, Memphis, Ashland}*{NYC, LA, Chicago, Houston}, Active=True
Key : Lower : Body : Upper : Active
('Ashland', 'Chicago') : -Inf : x[Ashland,Chicago] - y[Ashland] : 0.0 : True
('Ashland', 'Houston') : -Inf : x[Ashland,Houston] - y[Ashland] : 0.0 : True
@@ -80,4 +54,4 @@ y : Size=3, Index=y_index
('Memphis', 'LA') : -Inf : x[Memphis,LA] - y[Memphis] : 0.0 : True
('Memphis', 'NYC') : -Inf : x[Memphis,NYC] - y[Memphis] : 0.0 : True
-14 Declarations: x_index_0 x_index_1 x_index x y_index y obj one_per_cust_index one_per_cust warehouse_active_index_0 warehouse_active_index_1 warehouse_active_index warehouse_active num_warehouses
+6 Declarations: x y obj one_per_cust warehouse_active num_warehouses
diff --git a/examples/pyomobook/scripts-ch/warehouse_solver_options.py b/examples/pyomobook/scripts-ch/warehouse_solver_options.py
index c8eaf11a0f3..4e79e158d50 100644
--- a/examples/pyomobook/scripts-ch/warehouse_solver_options.py
+++ b/examples/pyomobook/scripts-ch/warehouse_solver_options.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
# @script:
import json
import pyomo.environ as pyo
diff --git a/examples/pyomobook/strip_examples.py b/examples/pyomobook/strip_examples.py
index 0a65eef7c04..84017299fb6 100644
--- a/examples/pyomobook/strip_examples.py
+++ b/examples/pyomobook/strip_examples.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import glob
import sys
import os
diff --git a/examples/pyomobook/test_book_examples.py b/examples/pyomobook/test_book_examples.py
index e946864c1aa..192330dc1bf 100644
--- a/examples/pyomobook/test_book_examples.py
+++ b/examples/pyomobook/test_book_examples.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/__future__.py b/pyomo/__future__.py
new file mode 100644
index 00000000000..d298e12cab6
--- /dev/null
+++ b/pyomo/__future__.py
@@ -0,0 +1,118 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+import pyomo.environ as _environ
+
+__doc__ = """
+Preview capabilities through ``pyomo.__future__``
+=================================================
+
+This module provides a uniform interface for gaining access to future
+("preview") capabilities that are either slightly incompatible with the
+current official offering, or are still under development with the
+intent to replace the current offering.
+
+Currently supported ``__future__`` offerings include:
+
+.. autosummary::
+
+ solver_factory
+
+.. autofunction:: solver_factory
+
+"""
+
+
+def __getattr__(name):
+ if name in ('solver_factory_v1', 'solver_factory_v2', 'solver_factory_v3'):
+ return solver_factory(int(name[-1]))
+ raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
+
+
+def solver_factory(version=None):
+ """Get (or set) the active implementation of the SolverFactory
+
+ This allows users to query / set the current implementation of the
+ SolverFactory that should be used throughout Pyomo. Valid options are:
+
+ - ``1``: the original Pyomo SolverFactory
+ - ``2``: the SolverFactory from APPSI
+ - ``3``: the SolverFactory from pyomo.contrib.solver
+
+ The current active version can be obtained by calling the method
+ with no arguments
+
+ .. doctest::
+
+ >>> from pyomo.__future__ import solver_factory
+ >>> solver_factory()
+ 1
+
+ The active factory can be set either by passing the appropriate
+ version to this function:
+
+ .. doctest::
+
+ >>> solver_factory(3)
+
+
+ or by importing the "special" name:
+
+ .. doctest::
+
+ >>> from pyomo.__future__ import solver_factory_v3
+
+ .. doctest::
+ :hide:
+
+ >>> from pyomo.__future__ import solver_factory_v1
+
+ """
+ import pyomo.opt.base.solvers as _solvers
+ import pyomo.contrib.solver.factory as _contrib
+ import pyomo.contrib.appsi.base as _appsi
+
+ versions = {
+ 1: _solvers.LegacySolverFactory,
+ 2: _appsi.SolverFactory,
+ 3: _contrib.SolverFactory,
+ }
+
+ current = getattr(solver_factory, '_active_version', None)
+ # First time through, _active_version is not defined. Go look and
+ # see what it was initialized to in pyomo.environ
+ if current is None:
+ for ver, cls in versions.items():
+ if cls._cls is _environ.SolverFactory._cls:
+ solver_factory._active_version = ver
+ break
+ return solver_factory._active_version
+ #
+ # The user is just asking what the current SolverFactory is; tell them.
+ if version is None:
+ return solver_factory._active_version
+ #
+ # Update the current SolverFactory to be a shim around (shallow copy
+ # of) the new active factory
+ src = versions.get(version, None)
+ if version is not None:
+ solver_factory._active_version = version
+ for attr in ('_description', '_cls', '_doc'):
+ setattr(_environ.SolverFactory, attr, getattr(src, attr))
+ else:
+ raise ValueError(
+ "Invalid value for target solver factory version; expected {1, 2, 3}, "
+ f"received {version}"
+ )
+ return src
+
+
+solver_factory._active_version = solver_factory()
diff --git a/pyomo/__init__.py b/pyomo/__init__.py
index 20ee59d48b2..14cc42b626e 100644
--- a/pyomo/__init__.py
+++ b/pyomo/__init__.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/__init__.py b/pyomo/common/__init__.py
index 563974b5617..d7297c067c9 100644
--- a/pyomo/common/__init__.py
+++ b/pyomo/common/__init__.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/_command.py b/pyomo/common/_command.py
index ae633648ace..ad521659aa7 100644
--- a/pyomo/common/_command.py
+++ b/pyomo/common/_command.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -13,8 +13,6 @@
Management of Pyomo commands
"""
-__all__ = ['pyomo_command', 'get_pyomo_commands']
-
import logging
logger = logging.getLogger('pyomo.common')
diff --git a/pyomo/common/_common.py b/pyomo/common/_common.py
index 21a5ddcc7bc..0d50f74537a 100644
--- a/pyomo/common/_common.py
+++ b/pyomo/common/_common.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/autoslots.py b/pyomo/common/autoslots.py
index 1b55a818b83..89fefaf4f21 100644
--- a/pyomo/common/autoslots.py
+++ b/pyomo/common/autoslots.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -29,7 +29,7 @@ def _deepcopy_tuple(obj, memo, _id):
unchanged = False
if unchanged:
# Python does not duplicate "unchanged" tuples (i.e. allows the
- # original objecct to be returned from deepcopy()). We will
+ # original object to be returned from deepcopy()). We will
# preserve that behavior here.
#
# It also appears to be faster *not* to cache the fact that this
diff --git a/pyomo/common/backports.py b/pyomo/common/backports.py
index 36f2dac87ab..e70b0f6d267 100644
--- a/pyomo/common/backports.py
+++ b/pyomo/common/backports.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/cmake_builder.py b/pyomo/common/cmake_builder.py
index bb612b43b72..523dbf64c91 100644
--- a/pyomo/common/cmake_builder.py
+++ b/pyomo/common/cmake_builder.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/collections/__init__.py b/pyomo/common/collections/__init__.py
index 9ffd1e931f6..717caf87b2c 100644
--- a/pyomo/common/collections/__init__.py
+++ b/pyomo/common/collections/__init__.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -14,6 +14,6 @@
from collections import UserDict
from .orderedset import OrderedDict, OrderedSet
-from .component_map import ComponentMap
+from .component_map import ComponentMap, DefaultComponentMap
from .component_set import ComponentSet
from .bunch import Bunch
diff --git a/pyomo/common/collections/bunch.py b/pyomo/common/collections/bunch.py
index f19e4ad64e3..2ae9cf8c517 100644
--- a/pyomo/common/collections/bunch.py
+++ b/pyomo/common/collections/bunch.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/collections/component_map.py b/pyomo/common/collections/component_map.py
index 41796876d7c..8dcfdb6c837 100644
--- a/pyomo/common/collections/component_map.py
+++ b/pyomo/common/collections/component_map.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -9,21 +9,49 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
-from collections.abc import MutableMapping as collections_MutableMapping
+import collections
from collections.abc import Mapping as collections_Mapping
from pyomo.common.autoslots import AutoSlots
-def _rebuild_ids(encode, val):
+def _rehash_keys(encode, val):
if encode:
return val
else:
# object id() may have changed after unpickling,
# so we rebuild the dictionary keys
- return {id(obj): (obj, v) for obj, v in val.values()}
+ return {_hasher[obj.__class__](obj): (obj, v) for obj, v in val.values()}
-class ComponentMap(AutoSlots.Mixin, collections_MutableMapping):
+class _Hasher(collections.defaultdict):
+ def __init__(self, *args, **kwargs):
+ super().__init__(lambda: self._missing_impl, *args, **kwargs)
+ self[tuple] = self._tuple
+
+ def _missing_impl(self, val):
+ try:
+ hash(val)
+ self[val.__class__] = self._hashable
+ except:
+ self[val.__class__] = self._unhashable
+ return self[val.__class__](val)
+
+ @staticmethod
+ def _hashable(val):
+ return val
+
+ @staticmethod
+ def _unhashable(val):
+ return id(val)
+
+ def _tuple(self, val):
+ return tuple(self[i.__class__](i) for i in val)
+
+
+_hasher = _Hasher()
+
+
+class ComponentMap(AutoSlots.Mixin, collections.abc.MutableMapping):
"""
This class is a replacement for dict that allows Pyomo
modeling components to be used as entry keys. The
@@ -49,18 +77,18 @@ class ComponentMap(AutoSlots.Mixin, collections_MutableMapping):
"""
__slots__ = ("_dict",)
- __autoslot_mappers__ = {'_dict': _rebuild_ids}
+ __autoslot_mappers__ = {'_dict': _rehash_keys}
def __init__(self, *args, **kwds):
- # maps id(obj) -> (obj,val)
+ # maps id_hash(obj) -> (obj,val)
self._dict = {}
# handle the dict-style initialization scenarios
self.update(*args, **kwds)
def __str__(self):
"""String representation of the mapping."""
- tmp = {str(c) + " (id=" + str(id(c)) + ")": v for c, v in self.items()}
- return "ComponentMap(" + str(tmp) + ")"
+ tmp = {f"{v[0]} (key={k})": v[1] for k, v in self._dict.items()}
+ return f"ComponentMap({tmp})"
#
# Implement MutableMapping abstract methods
@@ -68,18 +96,20 @@ def __str__(self):
def __getitem__(self, obj):
try:
- return self._dict[id(obj)][1]
+ return self._dict[_hasher[obj.__class__](obj)][1]
except KeyError:
- raise KeyError("Component with id '%s': %s" % (id(obj), str(obj)))
+ _id = _hasher[obj.__class__](obj)
+ raise KeyError(f"{obj} (key={_id})") from None
def __setitem__(self, obj, val):
- self._dict[id(obj)] = (obj, val)
+ self._dict[_hasher[obj.__class__](obj)] = (obj, val)
def __delitem__(self, obj):
try:
- del self._dict[id(obj)]
+ del self._dict[_hasher[obj.__class__](obj)]
except KeyError:
- raise KeyError("Component with id '%s': %s" % (id(obj), str(obj)))
+ _id = _hasher[obj.__class__](obj)
+ raise KeyError(f"{obj} (key={_id})") from None
def __iter__(self):
return (obj for obj, val in self._dict.values())
@@ -107,7 +137,7 @@ def __eq__(self, other):
return False
# Note we have already verified the dicts are the same size
for key, val in other.items():
- other_id = id(key)
+ other_id = _hasher[key.__class__](key)
if other_id not in self._dict:
return False
self_val = self._dict[other_id][1]
@@ -130,7 +160,7 @@ def __ne__(self, other):
#
def __contains__(self, obj):
- return id(obj) in self._dict
+ return _hasher[obj.__class__](obj) in self._dict
def clear(self):
'D.clear() -> None. Remove all items from D.'
@@ -149,3 +179,32 @@ def setdefault(self, key, default=None):
else:
self[key] = default
return default
+
+
+class DefaultComponentMap(ComponentMap):
+ """A :py:class:`defaultdict` admitting Pyomo Components as keys
+
+ This class is a replacement for defaultdict that allows Pyomo
+ modeling components to be used as entry keys. The base
+ implementation builds on :py:class:`ComponentMap`.
+
+ """
+
+ __slots__ = ('default_factory',)
+
+ def __init__(self, default_factory=None, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.default_factory = default_factory
+
+ def __missing__(self, key):
+ if self.default_factory is None:
+ raise KeyError(key)
+ self[key] = ans = self.default_factory()
+ return ans
+
+ def __getitem__(self, obj):
+ _key = _hasher[obj.__class__](obj)
+ if _key in self._dict:
+ return self._dict[_key][1]
+ else:
+ return self.__missing__(obj)
diff --git a/pyomo/common/collections/component_set.py b/pyomo/common/collections/component_set.py
index e205773220f..6e12bad7277 100644
--- a/pyomo/common/collections/component_set.py
+++ b/pyomo/common/collections/component_set.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -12,8 +12,30 @@
from collections.abc import MutableSet as collections_MutableSet
from collections.abc import Set as collections_Set
+from pyomo.common.autoslots import AutoSlots
+from pyomo.common.collections.component_map import _hasher
+
+
+def _rehash_keys(encode, val):
+ if encode:
+ # TBD [JDS 2/2024]: if we
+ #
+ # return list(val.values())
+ #
+ # here, then we get a strange failure when deepcopying
+ # ComponentSets containing an _ImplicitAny domain. We could
+ # track it down to the implementation of
+ # autoslots.fast_deepcopy, but couldn't find an obvious bug.
+ # There is no error if we just return the original dict, or if
+ # we return a tuple(val.values)
+ return val
+ else:
+ # object id() may have changed after unpickling,
+ # so we rebuild the dictionary keys
+ return {_hasher[obj.__class__](obj): obj for obj in val.values()}
+
-class ComponentSet(collections_MutableSet):
+class ComponentSet(AutoSlots.Mixin, collections_MutableSet):
"""
This class is a replacement for set that allows Pyomo
modeling components to be used as entries. The
@@ -38,47 +60,32 @@ class ComponentSet(collections_MutableSet):
"""
__slots__ = ("_data",)
+ __autoslot_mappers__ = {'_data': _rehash_keys}
- def __init__(self, *args):
- self._data = dict()
- if len(args) > 0:
- if len(args) > 1:
- raise TypeError(
- "%s expected at most 1 arguments, "
- "got %s" % (self.__class__.__name__, len(args))
- )
- self.update(args[0])
+ def __init__(self, iterable=None):
+ # maps id_hash(obj) -> obj
+ self._data = {}
+ if iterable is not None:
+ self.update(iterable)
def __str__(self):
"""String representation of the mapping."""
- tmp = []
- for objid, obj in self._data.items():
- tmp.append(str(obj) + " (id=" + str(objid) + ")")
- return "ComponentSet(" + str(tmp) + ")"
+ tmp = [f"{v} (key={k})" for k, v in self._data.items()]
+ return f"ComponentSet({tmp})"
- def update(self, args):
+ def update(self, iterable):
"""Update a set with the union of itself and others."""
- self._data.update((id(obj), obj) for obj in args)
-
- #
- # This method must be defined for deepcopy/pickling
- # because this class relies on Python ids.
- #
- def __setstate__(self, state):
- # object id() may have changed after unpickling,
- # so we rebuild the dictionary keys
- assert len(state) == 1
- self._data = {id(obj): obj for obj in state['_data']}
-
- def __getstate__(self):
- return {'_data': tuple(self._data.values())}
+ if isinstance(iterable, ComponentSet):
+ self._data.update(iterable._data)
+ else:
+ self._data.update((_hasher[val.__class__](val), val) for val in iterable)
#
# Implement MutableSet abstract methods
#
def __contains__(self, val):
- return self._data.__contains__(id(val))
+ return _hasher[val.__class__](val) in self._data
def __iter__(self):
return iter(self._data.values())
@@ -88,27 +95,26 @@ def __len__(self):
def add(self, val):
"""Add an element."""
- self._data[id(val)] = val
+ self._data[_hasher[val.__class__](val)] = val
def discard(self, val):
"""Remove an element. Do not raise an exception if absent."""
- if id(val) in self._data:
- del self._data[id(val)]
+ _id = _hasher[val.__class__](val)
+ if _id in self._data:
+ del self._data[_id]
#
# Overload MutableSet default implementations
#
- # We want to avoid generating Pyomo expressions due to
- # comparison of values, so we convert both objects to a
- # plain dictionary mapping key->(type(val), id(val)) and
- # compare that instead.
def __eq__(self, other):
if self is other:
return True
if not isinstance(other, collections_Set):
return False
- return len(self) == len(other) and all(id(key) in self._data for key in other)
+ return len(self) == len(other) and all(
+ _hasher[val.__class__](val) in self._data for val in other
+ )
def __ne__(self, other):
return not (self == other)
@@ -125,6 +131,7 @@ def clear(self):
def remove(self, val):
"""Remove an element. If not a member, raise a KeyError."""
try:
- del self._data[id(val)]
+ del self._data[_hasher[val.__class__](val)]
except KeyError:
- raise KeyError("Component with id '%s': %s" % (id(val), str(val)))
+ _id = _hasher[val.__class__](val)
+ raise KeyError(f"{val} (key={_id})") from None
diff --git a/pyomo/common/collections/orderedset.py b/pyomo/common/collections/orderedset.py
index 448939c8822..834101e3896 100644
--- a/pyomo/common/collections/orderedset.py
+++ b/pyomo/common/collections/orderedset.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -9,42 +9,30 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
-from collections.abc import MutableSet
from collections import OrderedDict
+from collections.abc import MutableSet
+from pyomo.common.autoslots import AutoSlots
-class OrderedSet(MutableSet):
+class OrderedSet(AutoSlots.Mixin, MutableSet):
__slots__ = ('_dict',)
def __init__(self, iterable=None):
- # TODO: Starting in Python 3.7, dict is ordered (and is faster
- # than OrderedDict). dict began supporting reversed() in 3.8.
- # We should consider changing the underlying data type here from
- # OrderedDict to dict.
- self._dict = OrderedDict()
+ # Starting in Python 3.7, dict is ordered (and is faster than
+ # OrderedDict). dict began supporting reversed() in 3.8.
+ self._dict = {}
if iterable is not None:
- if iterable.__class__ is OrderedSet:
- self._dict.update(iterable._dict)
- else:
- self.update(iterable)
+ self.update(iterable)
def __str__(self):
"""String representation of the mapping."""
return "OrderedSet(%s)" % (', '.join(repr(x) for x in self))
def update(self, iterable):
- for val in iterable:
- self.add(val)
-
- #
- # This method must be defined for deepcopy/pickling
- # because this class is slotized.
- #
- def __setstate__(self, state):
- self._dict = state
-
- def __getstate__(self):
- return self._dict
+ if isinstance(iterable, OrderedSet):
+ self._dict.update(iterable._dict)
+ else:
+ self._dict.update((val, None) for val in iterable)
#
# Implement MutableSet abstract methods
diff --git a/pyomo/common/config.py b/pyomo/common/config.py
index 15f15872fc6..ebba2f2732a 100644
--- a/pyomo/common/config.py
+++ b/pyomo/common/config.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -39,7 +39,6 @@
deprecation_warning,
relocated_module_attribute,
)
-from pyomo.common.errors import DeveloperError
from pyomo.common.fileutils import import_file
from pyomo.common.formatting import wrap_reStructuredText
from pyomo.common.modeling import NOTSET
@@ -302,6 +301,70 @@ def domain_name(self):
return f'InEnum[{self._domain.__name__}]'
+class IsInstance(object):
+ """
+ Domain validator for type checking.
+
+ Parameters
+ ----------
+ *bases : tuple of type
+ Valid types.
+ document_full_base_names : bool, optional
+ True to prepend full module qualifier to the name of each
+ member of `bases` in ``self.domain_name()`` and/or any
+ error messages generated by this object, False otherwise.
+ """
+
+ def __init__(self, *bases, document_full_base_names=False):
+ assert bases
+ self.baseClasses = bases
+ self.document_full_base_names = document_full_base_names
+
+ @staticmethod
+ def _fullname(klass):
+ """
+ Get full name of class, including appropriate module qualifier.
+ """
+ module_name = klass.__module__
+ module_qual = "" if module_name == "builtins" else f"{module_name}."
+ return f"{module_qual}{klass.__name__}"
+
+ def _get_class_name(self, klass):
+ """
+ Get name of class. Module qualifier may be included,
+ depending on value of `self.document_full_base_names`.
+ """
+ if self.document_full_base_names:
+ return self._fullname(klass)
+ else:
+ return klass.__name__
+
+ def __call__(self, obj):
+ if isinstance(obj, self.baseClasses):
+ return obj
+ if len(self.baseClasses) > 1:
+ class_names = ", ".join(
+ f"{self._get_class_name(kls)!r}" for kls in self.baseClasses
+ )
+ msg = (
+ "Expected an instance of one of these types: "
+ f"{class_names}, but received value {obj!r} of type "
+ f"{self._get_class_name(type(obj))!r}"
+ )
+ else:
+ msg = (
+ f"Expected an instance of "
+ f"{self._get_class_name(self.baseClasses[0])!r}, "
+ f"but received value {obj!r} of type "
+ f"{self._get_class_name(type(obj))!r}"
+ )
+ raise ValueError(msg)
+
+ def domain_name(self):
+ class_names = (self._get_class_name(kls) for kls in self.baseClasses)
+ return f"IsInstance({', '.join(class_names)})"
+
+
class ListOf(object):
"""Domain validator for lists of a specified type
@@ -424,9 +487,14 @@ def __call__(self, module_id):
class Path(object):
- """Domain validator for path-like options.
+ """
+ Domain validator for a
+ :py:term:`path-like object `.
- This will admit any object and convert it to a string. It will then
+ This will admit a path-like object
+ and get the object's file system representation
+ through :py:obj:`os.fsdecode`.
+ It will then
expand any environment variables and leading usernames (e.g.,
"~myuser" or "~/") appearing in either the value or the base path
before concatenating the base path and value, expanding the path to
@@ -454,7 +522,7 @@ def __init__(self, basePath=None, expandPath=None):
self.expandPath = expandPath
def __call__(self, path):
- path = str(path)
+ path = os.fsdecode(path)
_expand = self.expandPath
if _expand is None:
_expand = not Path.SuppressPathExpansion
@@ -489,14 +557,21 @@ def __call__(self, path):
)
return ans
+ def domain_name(self):
+ return type(self).__name__
+
class PathList(Path):
- """Domain validator for a list of path-like objects.
+ """
+ Domain validator for a list of
+ :py:term:`path-like objects `.
- This will admit any iterable or object convertible to a string.
- Iterable objects (other than strings) will have each member
- normalized using :py:class:`Path`. Other types will be passed to
- :py:class:`Path`, returning a list with the single resulting path.
+ This admits a path-like object or iterable of such.
+ If a path-like object is passed, then
+ a singleton list containing the object normalized through
+ :py:class:`Path` is returned.
+ An iterable of path-like objects is cast to a list, each
+ entry of which is normalized through :py:class:`Path`.
Parameters
----------
@@ -513,7 +588,8 @@ class PathList(Path):
"""
def __call__(self, data):
- if hasattr(data, "__iter__") and not isinstance(data, str):
+ is_path_like = isinstance(data, (str, bytes)) or hasattr(data, "__fspath__")
+ if hasattr(data, "__iter__") and not is_path_like:
return [super(PathList, self).__call__(i) for i in data]
else:
return [super(PathList, self).__call__(data)]
@@ -709,6 +785,7 @@ def from_enum_or_string(cls, arg):
NonNegativeFloat
In
InEnum
+ IsInstance
ListOf
Module
Path
@@ -919,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.
@@ -1028,8 +1105,11 @@ class will still create ``c`` instances that only have the single
def _dump(*args, **kwds):
+ # TODO: Change the default behavior to no longer be YAML.
+ # This was a legacy decision that may no longer be the best
+ # decision, given changes to technology over the years.
try:
- from yaml import dump
+ from yaml import safe_dump as dump
except ImportError:
# dump = lambda x,**y: str(x)
# YAML uses lowercase True/False
@@ -1054,7 +1134,11 @@ def _domain_name(domain):
if domain is None:
return ""
elif hasattr(domain, 'domain_name'):
- return domain.domain_name()
+ dn = domain.domain_name
+ if hasattr(dn, '__call__'):
+ return dn()
+ else:
+ return dn
elif domain.__class__ is type:
return domain.__name__
elif inspect.isfunction(domain):
@@ -1090,7 +1174,9 @@ def _value2string(prefix, value, obj):
try:
_data = value._data if value is obj else value
if getattr(builtins, _data.__class__.__name__, None) is not None:
- _str += _dump(_data, default_flow_style=True).rstrip()
+ _str += _dump(
+ _data, default_flow_style=True, allow_unicode=True
+ ).rstrip()
if _str.endswith("..."):
_str = _str[:-3].rstrip()
else:
diff --git a/pyomo/common/dependencies.py b/pyomo/common/dependencies.py
index 0a179b5c2de..bbcea0b85d7 100644
--- a/pyomo/common/dependencies.py
+++ b/pyomo/common/dependencies.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -9,13 +9,16 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
-from collections.abc import Mapping
import inspect
import importlib
import logging
import sys
import warnings
+from collections.abc import Mapping
+from types import ModuleType
+from typing import List
+
from .deprecation import deprecated, deprecation_warning, in_testing_environment
from .errors import DeferredImportError
@@ -127,7 +130,7 @@ class DeferredImportModule(object):
This object is returned by :py:func:`attempt_import()` in lieu of
the module when :py:func:`attempt_import()` is called with
- ``defer_check=True``. Any attempts to access attributes on this
+ ``defer_import=True``. Any attempts to access attributes on this
object will trigger the actual module import and return either the
appropriate module attribute or else if the module import fails,
raise a :py:class:`.DeferredImportError` exception.
@@ -312,6 +315,12 @@ def __init__(
self._module = None
self._available = None
self._deferred_submodules = deferred_submodules
+ # If this import has a callback, then record this deferred
+ # import so that any direct imports of this module also trigger
+ # the resolution of this DeferredImportIndicator (and the
+ # corresponding callback)
+ if callback is not None:
+ DeferredImportCallbackFinder._callbacks.setdefault(name, []).append(self)
def __bool__(self):
self.resolve()
@@ -433,6 +442,83 @@ def check_min_version(module, min_version):
check_min_version._parser = None
+#
+# Note that we are duck-typing the Loader and MetaPathFinder base
+# classes from importlib.abc. This avoids a (surprisingly costly)
+# import of importlib.abc
+#
+class DeferredImportCallbackLoader:
+ """Custom Loader to resolve registered :py:class:`DeferredImportIndicator` objects
+
+ This :py:class:`importlib.abc.Loader` loader wraps a regular loader
+ and automatically resolves the registered
+ :py:class:`DeferredImportIndicator` objects after the module is
+ loaded.
+
+ """
+
+ def __init__(self, loader, deferred_indicators: List[DeferredImportIndicator]):
+ self._loader = loader
+ self._deferred_indicators = deferred_indicators
+
+ def module_repr(self, module: ModuleType) -> str:
+ return self._loader.module_repr(module)
+
+ def create_module(self, spec) -> ModuleType:
+ return self._loader.create_module(spec)
+
+ def exec_module(self, module: ModuleType) -> None:
+ self._loader.exec_module(module)
+ # Now that the module has been loaded, trigger the resolution of
+ # the deferred indicators (and their associated callbacks)
+ for deferred in self._deferred_indicators:
+ deferred.resolve()
+
+ def load_module(self, fullname) -> ModuleType:
+ return self._loader.load_module(fullname)
+
+
+class DeferredImportCallbackFinder:
+ """Custom Finder that will wrap the normal loader to trigger callbacks
+
+ This :py:class:`importlib.abc.MetaPathFinder` finder will wrap the
+ normal loader returned by ``PathFinder`` with a loader that will
+ trigger custom callbacks after the module is loaded. We use this to
+ trigger the post import callbacks registered through
+ :py:func:`attempt_import` even when a user imports the target library
+ directly (and not through attribute access on the
+ :py:class:`DeferredImportModule`.
+
+ """
+
+ _callbacks = {}
+
+ def find_spec(self, fullname, path, target=None):
+ if fullname not in self._callbacks:
+ return None
+
+ spec = importlib.machinery.PathFinder.find_spec(fullname, path, target)
+ if spec is None:
+ # Module not found. Returning None will proceed to the next
+ # finder (which is likely to raise a ModuleNotFoundError)
+ return None
+ spec.loader = DeferredImportCallbackLoader(
+ spec.loader, self._callbacks[fullname]
+ )
+ return spec
+
+ def invalidate_caches(self):
+ pass
+
+
+_DeferredImportCallbackFinder = DeferredImportCallbackFinder()
+# Insert the DeferredImportCallbackFinder at the beginning of the
+# sys.meta_path so that it is found before the standard finders (so that
+# we can correctly inject the resolution of the DeferredImportIndicators
+# -- which triggers the needed callbacks)
+sys.meta_path.insert(0, _DeferredImportCallbackFinder)
+
+
def attempt_import(
name,
error_message=None,
@@ -441,7 +527,8 @@ def attempt_import(
alt_names=None,
callback=None,
importer=None,
- defer_check=True,
+ defer_check=None,
+ defer_import=None,
deferred_submodules=None,
catch_exceptions=None,
):
@@ -495,7 +582,8 @@ def attempt_import(
The message for the exception raised by :py:class:`ModuleUnavailable`
only_catch_importerror: bool, optional
- DEPRECATED: use catch_exceptions instead or only_catch_importerror.
+ DEPRECATED: use ``catch_exceptions`` instead of ``only_catch_importerror``.
+
If True (the default), exceptions other than ``ImportError`` raised
during module import will be reraised. If False, any exception
will result in returning a :py:class:`ModuleUnavailable` object.
@@ -506,13 +594,14 @@ def attempt_import(
``module.__version__``)
alt_names: list, optional
- DEPRECATED: alt_names no longer needs to be specified and is ignored.
+ DEPRECATED: ``alt_names`` no longer needs to be specified and is ignored.
+
A list of common alternate names by which to look for this
module in the ``globals()`` namespaces. For example, the alt_names
for NumPy would be ``['np']``. (deprecated in version 6.0)
- callback: function, optional
- A function with the signature "``fcn(module, available)``" that
+ callback: Callable[[ModuleType, bool], None], optional
+ A function with the signature ``fcn(module, available)`` that
will be called after the import is first attempted.
importer: function, optional
@@ -522,10 +611,16 @@ def attempt_import(
want to import/return the first one that is available.
defer_check: bool, optional
- If True (the default), then the attempted import is deferred
- until the first use of either the module or the availability
- flag. The method will return instances of :py:class:`DeferredImportModule`
- and :py:class:`DeferredImportIndicator`.
+ DEPRECATED: renamed to ``defer_import`` (deprecated in version 6.7.2)
+
+ defer_import: bool, optional
+ If True, then the attempted import is deferred until the first
+ use of either the module or the availability flag. The method
+ will return instances of :py:class:`DeferredImportModule` and
+ :py:class:`DeferredImportIndicator`. If False, the import will
+ be attempted immediately. If not set, then the import will be
+ deferred unless the ``name`` is already present in
+ ``sys.modules``.
deferred_submodules: Iterable[str], optional
If provided, an iterable of submodule names within this module
@@ -576,9 +671,26 @@ def attempt_import(
if catch_exceptions is None:
catch_exceptions = (ImportError,)
+ if defer_check is not None:
+ deprecation_warning(
+ 'defer_check=%s is deprecated. Please use defer_import' % (defer_check,),
+ version='6.7.2',
+ )
+ assert defer_import is None
+ defer_import = defer_check
+
+ # If the module has already been imported, there is no reason to
+ # further defer things: just import it.
+ if defer_import is None:
+ if name in sys.modules:
+ defer_import = False
+ deferred_submodules = None
+ else:
+ defer_import = True
+
# If we are going to defer the check until later, return the
# deferred import module object
- if defer_check:
+ if defer_import:
if deferred_submodules:
if isinstance(deferred_submodules, Mapping):
deprecation_warning(
@@ -621,7 +733,7 @@ def attempt_import(
return DeferredImportModule(indicator, deferred, None), indicator
if deferred_submodules:
- raise ValueError("deferred_submodules is only valid if defer_check==True")
+ raise ValueError("deferred_submodules is only valid if defer_import==True")
return _perform_import(
name=name,
@@ -672,6 +784,11 @@ def _perform_import(
return module, False
+@deprecated(
+ "``declare_deferred_modules_as_importable()`` is deprecated. "
+ "Use the :py:class:`declare_modules_as_importable` context manager.",
+ version='6.7.2',
+)
def declare_deferred_modules_as_importable(globals_dict):
"""Make all :py:class:`DeferredImportModules` in ``globals_dict`` importable
@@ -698,6 +815,7 @@ def declare_deferred_modules_as_importable(globals_dict):
... 'scipy', callback=_finalize_scipy,
... deferred_submodules=['stats', 'sparse', 'spatial', 'integrate'])
>>> declare_deferred_modules_as_importable(globals())
+ WARNING: DEPRECATED: ...
Which enables users to use:
@@ -712,20 +830,87 @@ def declare_deferred_modules_as_importable(globals_dict):
:py:class:`ModuleUnavailable` instance.
"""
- _global_name = globals_dict['__name__'] + '.'
- deferred = list(
- (k, v) for k, v in globals_dict.items() if type(v) is DeferredImportModule
- )
- while deferred:
- name, mod = deferred.pop(0)
- mod.__path__ = None
- mod.__spec__ = None
- sys.modules[_global_name + name] = mod
- deferred.extend(
- (name + '.' + k, v)
- for k, v in mod.__dict__.items()
- if type(v) is DeferredImportModule
- )
+ return declare_modules_as_importable(globals_dict).__exit__(None, None, None)
+
+
+class declare_modules_as_importable(object):
+ """Make all :py:class:`ModuleType` and :py:class:`DeferredImportModules`
+ importable through the ``globals_dict`` context.
+
+ This context manager will detect all modules imported into the
+ specified ``globals_dict`` environment (either directly or through
+ :py:func:`attempt_import`) and will make those modules importable
+ from the specified ``globals_dict`` context. It works by detecting
+ changes in the specified ``globals_dict`` dictionary and adding any new
+ modules or instances of :py:class:`DeferredImportModule` that it
+ finds (and any of their deferred submodules) to ``sys.modules`` so
+ that the modules can be imported through the ``globals_dict``
+ namespace.
+
+ For example, ``pyomo/common/dependencies.py`` declares:
+
+ .. doctest::
+ :hide:
+
+ >>> from pyomo.common.dependencies import (
+ ... attempt_import, _finalize_scipy, __dict__ as dep_globals,
+ ... declare_modules_as_importable, )
+ >>> # Sphinx does not provide a proper globals()
+ >>> def globals(): return dep_globals
+
+ .. doctest::
+
+ >>> with declare_modules_as_importable(globals()):
+ ... scipy, scipy_available = attempt_import(
+ ... 'scipy', callback=_finalize_scipy,
+ ... deferred_submodules=['stats', 'sparse', 'spatial', 'integrate'])
+
+ Which enables users to use:
+
+ .. doctest::
+
+ >>> import pyomo.common.dependencies.scipy.sparse as spa
+
+ If the deferred import has not yet been triggered, then the
+ :py:class:`DeferredImportModule` is returned and named ``spa``.
+ However, if the import has already been triggered, then ``spa`` will
+ either be the ``scipy.sparse`` module, or a
+ :py:class:`ModuleUnavailable` instance.
+
+ """
+
+ def __init__(self, globals_dict):
+ self.globals_dict = globals_dict
+ self.init_dict = {}
+ self.init_modules = None
+
+ def __enter__(self):
+ self.init_dict.update(self.globals_dict)
+ self.init_modules = set(sys.modules)
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ _global_name = self.globals_dict['__name__'] + '.'
+ deferred = {
+ k: v
+ for k, v in self.globals_dict.items()
+ if k not in self.init_dict
+ and isinstance(v, (ModuleType, DeferredImportModule))
+ }
+ if self.init_modules:
+ for name in set(sys.modules) - self.init_modules:
+ if '.' in name and name.split('.', 1)[0] in deferred:
+ sys.modules[_global_name + name] = sys.modules[name]
+ while deferred:
+ name, mod = deferred.popitem()
+ sys.modules[_global_name + name] = mod
+ if isinstance(mod, DeferredImportModule):
+ mod.__path__ = None
+ mod.__spec__ = None
+ deferred.update(
+ (name + '.' + k, v)
+ for k, v in mod.__dict__.items()
+ if type(v) is DeferredImportModule
+ )
#
@@ -778,11 +963,18 @@ def _finalize_matplotlib(module, available):
if in_testing_environment():
module.use('Agg')
import matplotlib.pyplot
+ import matplotlib.pylab
+ import matplotlib.backends
def _finalize_numpy(np, available):
if not available:
return
+ # scipy has a dependence on numpy.testing, and if we don't import it
+ # as part of resolving numpy, then certain deferred scipy imports
+ # fail when run under pytest.
+ import numpy.testing
+
from . import numeric_types
# Register ndarray as a native type to prevent 1-element ndarrays
@@ -807,10 +999,13 @@ def _finalize_numpy(np, available):
# registration here (to bypass the deprecation warning) until we
# finally remove all support for it
numeric_types._native_boolean_types.add(t)
- _floats = [np.float_, np.float16, np.float32, np.float64]
+ _floats = [np.float16, np.float32, np.float64]
# float96 and float128 may or may not be defined in this particular
# numpy build (it depends on platform and version).
# Register them only if they are present
+ if hasattr(np, 'float_'):
+ # Prepend to preserve previous functionality
+ _floats.insert(0, np.float_)
if hasattr(np, 'float96'):
_floats.append(np.float96)
if hasattr(np, 'float128'):
@@ -821,10 +1016,13 @@ def _finalize_numpy(np, available):
# registration here (to bypass the deprecation warning) until we
# finally remove all support for it
numeric_types._native_boolean_types.add(t)
- _complex = [np.complex_, np.complex64, np.complex128]
+ _complex = [np.complex64, np.complex128]
# complex192 and complex256 may or may not be defined in this
# particular numpy build (it depends on platform and version).
# Register them only if they are present
+ if hasattr(np, 'np.complex_'):
+ # Prepend to preserve functionality
+ _complex.insert(0, np.complex_)
if hasattr(np, 'complex192'):
_complex.append(np.complex192)
if hasattr(np, 'complex256'):
@@ -842,41 +1040,42 @@ def _pyutilib_importer():
return importlib.import_module('pyutilib')
-# Standard libraries that are slower to import and not strictly required
-# on all platforms / situations.
-ctypes, _ = attempt_import(
- 'ctypes', deferred_submodules=['util'], callback=_finalize_ctypes
-)
-random, _ = attempt_import('random')
-
-# Commonly-used optional dependencies
-dill, dill_available = attempt_import('dill')
-mpi4py, mpi4py_available = attempt_import('mpi4py')
-networkx, networkx_available = attempt_import('networkx')
-numpy, numpy_available = attempt_import('numpy', callback=_finalize_numpy)
-pandas, pandas_available = attempt_import('pandas')
-plotly, plotly_available = attempt_import('plotly')
-pympler, pympler_available = attempt_import('pympler', callback=_finalize_pympler)
-pyutilib, pyutilib_available = attempt_import('pyutilib', importer=_pyutilib_importer)
-scipy, scipy_available = attempt_import(
- 'scipy',
- callback=_finalize_scipy,
- deferred_submodules=['stats', 'sparse', 'spatial', 'integrate'],
-)
-yaml, yaml_available = attempt_import('yaml', callback=_finalize_yaml)
-
-# Note that matplotlib.pyplot can generate a runtime error on OSX when
-# not installed as a Framework (as is the case in the CI systems)
-matplotlib, matplotlib_available = attempt_import(
- 'matplotlib',
- callback=_finalize_matplotlib,
- deferred_submodules=['pyplot', 'pylab'],
- catch_exceptions=(ImportError, RuntimeError),
-)
+with declare_modules_as_importable(globals()):
+ # Standard libraries that are slower to import and not strictly required
+ # on all platforms / situations.
+ ctypes, _ = attempt_import(
+ 'ctypes', deferred_submodules=['util'], callback=_finalize_ctypes
+ )
+ random, _ = attempt_import('random')
+
+ # Commonly-used optional dependencies
+ dill, dill_available = attempt_import('dill')
+ mpi4py, mpi4py_available = attempt_import('mpi4py')
+ networkx, networkx_available = attempt_import('networkx')
+ numpy, numpy_available = attempt_import('numpy', callback=_finalize_numpy)
+ pandas, pandas_available = attempt_import('pandas')
+ plotly, plotly_available = attempt_import('plotly')
+ pympler, pympler_available = attempt_import('pympler', callback=_finalize_pympler)
+ pyutilib, pyutilib_available = attempt_import(
+ 'pyutilib', importer=_pyutilib_importer
+ )
+ scipy, scipy_available = attempt_import(
+ 'scipy',
+ callback=_finalize_scipy,
+ deferred_submodules=['stats', 'sparse', 'spatial', 'integrate'],
+ )
+ yaml, yaml_available = attempt_import('yaml', callback=_finalize_yaml)
+
+ # Note that matplotlib.pyplot can generate a runtime error on OSX when
+ # not installed as a Framework (as is the case in the CI systems)
+ matplotlib, matplotlib_available = attempt_import(
+ 'matplotlib',
+ callback=_finalize_matplotlib,
+ deferred_submodules=['pyplot', 'pylab', 'backends'],
+ catch_exceptions=(ImportError, RuntimeError),
+ )
try:
import cPickle as pickle
except ImportError:
import pickle
-
-declare_deferred_modules_as_importable(globals())
diff --git a/pyomo/common/deprecation.py b/pyomo/common/deprecation.py
index 2e39083770d..c674dcddc78 100644
--- a/pyomo/common/deprecation.py
+++ b/pyomo/common/deprecation.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -542,7 +542,7 @@ def __renamed__warning__(msg):
if new_class is None and '__renamed__new_class__' not in classdict:
if not any(
- hasattr(base, '__renamed__new_class__')
+ hasattr(mro, '__renamed__new_class__')
for mro in itertools.chain.from_iterable(
base.__mro__ for base in renamed_bases
)
diff --git a/pyomo/common/download.py b/pyomo/common/download.py
index 79d5302a58e..ad3b64060e9 100644
--- a/pyomo/common/download.py
+++ b/pyomo/common/download.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -29,6 +29,7 @@
urllib_error = attempt_import('urllib.error')[0]
ssl = attempt_import('ssl')[0]
zipfile = attempt_import('zipfile')[0]
+tarfile = attempt_import('tarfile')[0]
gzip = attempt_import('gzip')[0]
distro, distro_available = attempt_import('distro')
@@ -371,7 +372,7 @@ def get_zip_archive(self, url, dirOffset=0):
# Simple sanity checks
for info in zip_file.infolist():
f = info.filename
- if f[0] in '\\/' or '..' in f:
+ if f[0] in '\\/' or '..' in f or os.path.isabs(f):
logger.error(
"malformed (potentially insecure) filename (%s) "
"found in zip archive. Skipping file." % (f,)
@@ -387,6 +388,61 @@ def get_zip_archive(self, url, dirOffset=0):
info.filename = target[-1] + '/' if f[-1] == '/' else target[-1]
zip_file.extract(f, os.path.join(self._fname, *tuple(target[dirOffset:-1])))
+ def get_tar_archive(self, url, dirOffset=0):
+ if self._fname is None:
+ raise DeveloperError(
+ "target file name has not been initialized "
+ "with set_destination_filename"
+ )
+ if os.path.exists(self._fname) and not os.path.isdir(self._fname):
+ raise RuntimeError(
+ "Target directory (%s) exists, but is not a directory" % (self._fname,)
+ )
+
+ def filter_fcn(info):
+ # this mocks up the `tarfile` filter introduced in Python
+ # 3.12 and backported to later releases of Python (e.g.,
+ # 3.8.17, 3.9.17, 3.10.12, and 3.11.4)
+ f = info.name
+ if os.path.isabs(f) or '..' in f or f.startswith(('/', os.sep)):
+ logger.error(
+ "malformed or potentially insecure filename (%s). "
+ "Skipping file." % (f,)
+ )
+ return False
+ target = self._splitpath(f)
+ if len(target) <= dirOffset:
+ if not info.isdir():
+ logger.warning(
+ "Skipping file (%s) in tar archive due to dirOffset." % (f,)
+ )
+ return False
+ info.name = f = '/'.join(target[dirOffset:])
+ target = os.path.realpath(os.path.join(dest, f))
+ try:
+ if os.path.commonpath([target, dest]) != dest:
+ logger.error(
+ "potentially insecure filename (%s) resolves outside target "
+ "directory. Skipping file." % (f,)
+ )
+ return False
+ except ValueError:
+ # commonpath() will raise ValueError for paths that
+ # don't have anything in common (notably, when files are
+ # on different drives on Windows)
+ logger.error(
+ "potentially insecure filename (%s) resolves outside target "
+ "directory. Skipping file." % (f,)
+ )
+ return False
+ # Strip high bits & group/other write bits
+ info.mode &= 0o755
+ return True
+
+ with tarfile.open(fileobj=io.BytesIO(self.retrieve_url(url))) as TAR:
+ dest = os.path.realpath(self._fname)
+ TAR.extractall(dest, filter(filter_fcn, TAR.getmembers()))
+
def get_gzipped_binary_file(self, url):
if self._fname is None:
raise DeveloperError(
diff --git a/pyomo/common/enums.py b/pyomo/common/enums.py
new file mode 100644
index 00000000000..121155d4ae8
--- /dev/null
+++ b/pyomo/common/enums.py
@@ -0,0 +1,170 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+"""This module provides standard :py:class:`enum.Enum` definitions used in
+Pyomo, along with additional utilities for working with custom Enums
+
+Utilities:
+
+.. autosummary::
+
+ ExtendedEnumType
+ NamedIntEnum
+
+Standard Enums:
+
+.. autosummary::
+
+ ObjectiveSense
+
+"""
+
+import enum
+import itertools
+import sys
+
+if sys.version_info[:2] < (3, 11):
+ _EnumType = enum.EnumMeta
+else:
+ _EnumType = enum.EnumType
+
+
+class ExtendedEnumType(_EnumType):
+ """Metaclass for creating an :py:class:`enum.Enum` that extends another Enum
+
+ In general, :py:class:`enum.Enum` classes are not extensible: that is,
+ they are frozen when defined and cannot be the base class of another
+ Enum. This Metaclass provides a workaround for creating a new Enum
+ that extends an existing enum. Members in the base Enum are all
+ present as members on the extended enum.
+
+ Example
+ -------
+
+ .. testcode::
+ :hide:
+
+ import enum
+ from pyomo.common.enums import ExtendedEnumType
+
+ .. testcode::
+
+ class ObjectiveSense(enum.IntEnum):
+ minimize = 1
+ maximize = -1
+
+ class ProblemSense(enum.IntEnum, metaclass=ExtendedEnumType):
+ __base_enum__ = ObjectiveSense
+
+ unknown = 0
+
+ .. doctest::
+
+ >>> list(ProblemSense)
+ [, , ]
+ >>> ProblemSense.unknown
+
+ >>> ProblemSense.maximize
+
+ >>> ProblemSense(0)
+
+ >>> ProblemSense(1)
+
+ >>> ProblemSense('unknown')
+
+ >>> ProblemSense('maximize')
+
+ >>> hasattr(ProblemSense, 'minimize')
+ True
+ >>> ProblemSense.minimize is ObjectiveSense.minimize
+ True
+ >>> ProblemSense.minimize in ProblemSense
+ True
+
+ """
+
+ def __getattr__(cls, attr):
+ try:
+ return getattr(cls.__base_enum__, attr)
+ except:
+ return super().__getattr__(attr)
+
+ def __iter__(cls):
+ # The members of this Enum are the base enum members joined with
+ # the local members
+ return itertools.chain(super().__iter__(), cls.__base_enum__.__iter__())
+
+ def __contains__(cls, member):
+ # This enum "contains" both its local members and the members in
+ # the __base_enum__ (necessary for good auto-enum[sphinx] docs)
+ return super().__contains__(member) or member in cls.__base_enum__
+
+ def __instancecheck__(cls, instance):
+ if cls.__subclasscheck__(type(instance)):
+ return True
+ # Also pretend that members of the extended enum are subclasses
+ # of the __base_enum__. This is needed to circumvent error
+ # checking in enum.__new__ (e.g., for `ProblemSense('minimize')`)
+ return cls.__base_enum__.__subclasscheck__(type(instance))
+
+ def _missing_(cls, value):
+ # Support attribute lookup by value or name
+ for attr in ('value', 'name'):
+ for member in cls:
+ if getattr(member, attr) == value:
+ return member
+ return None
+
+ def __new__(metacls, cls, bases, classdict, **kwds):
+ # Support lookup by name - but only if the new Enum doesn't
+ # specify its own implementation of _missing_
+ if '_missing_' not in classdict:
+ classdict['_missing_'] = classmethod(ExtendedEnumType._missing_)
+ return super().__new__(metacls, cls, bases, classdict, **kwds)
+
+
+class NamedIntEnum(enum.IntEnum):
+ """An extended version of :py:class:`enum.IntEnum` that supports
+ creating members by name as well as value.
+
+ """
+
+ @classmethod
+ def _missing_(cls, value):
+ for member in cls:
+ if member.name == value:
+ return member
+ return None
+
+
+class ObjectiveSense(NamedIntEnum):
+ """Flag indicating if an objective is minimizing (1) or maximizing (-1).
+
+ While the numeric values are arbitrary, there are parts of Pyomo
+ that rely on this particular choice of value. These values are also
+ consistent with some solvers (notably Gurobi).
+
+ """
+
+ minimize = 1
+ maximize = -1
+
+ # Overloading __str__ is needed to match the behavior of the old
+ # pyutilib.enum class (removed June 2020). There are spots in the
+ # code base that expect the string representation for items in the
+ # enum to not include the class name. New uses of enum shouldn't
+ # need to do this.
+ def __str__(self):
+ return self.name
+
+
+minimize = ObjectiveSense.minimize
+maximize = ObjectiveSense.maximize
diff --git a/pyomo/common/env.py b/pyomo/common/env.py
index 2ce0f368b9e..ee07cdc1e6a 100644
--- a/pyomo/common/env.py
+++ b/pyomo/common/env.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/envvar.py b/pyomo/common/envvar.py
index d74cb764641..1f933d4b08c 100644
--- a/pyomo/common/envvar.py
+++ b/pyomo/common/envvar.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/errors.py b/pyomo/common/errors.py
index 17013ce4dca..3c82f2b07c1 100644
--- a/pyomo/common/errors.py
+++ b/pyomo/common/errors.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/extensions.py b/pyomo/common/extensions.py
index e4f7b047bb3..0ac27f125a7 100644
--- a/pyomo/common/extensions.py
+++ b/pyomo/common/extensions.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/factory.py b/pyomo/common/factory.py
index 6a97759c714..c449cf826b4 100644
--- a/pyomo/common/factory.py
+++ b/pyomo/common/factory.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/fileutils.py b/pyomo/common/fileutils.py
index 557901c401e..7b6520327a0 100644
--- a/pyomo/common/fileutils.py
+++ b/pyomo/common/fileutils.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -38,6 +38,7 @@
import os
import platform
import importlib.util
+import subprocess
import sys
from . import envvar
@@ -375,9 +376,27 @@ def find_library(libname, cwd=True, include_PATH=True, pathlist=None):
if libname_base.startswith('lib') and _system() != 'windows':
libname_base = libname_base[3:]
if ext.lower().startswith(('.so', '.dll', '.dylib')):
- return ctypes.util.find_library(libname_base)
+ lib = ctypes.util.find_library(libname_base)
else:
- return ctypes.util.find_library(libname)
+ lib = ctypes.util.find_library(libname)
+ if lib and os.path.sep not in lib:
+ # work around https://github.com/python/cpython/issues/65241,
+ # where python does not return the absolute path on *nix
+ try:
+ libname = lib + ' '
+ with subprocess.Popen(
+ ['/sbin/ldconfig', '-p'],
+ stdin=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
+ stdout=subprocess.PIPE,
+ env={'LC_ALL': 'C', 'LANG': 'C'},
+ ) as p:
+ for line in os.fsdecode(p.stdout.read()).splitlines():
+ if line.lstrip().startswith(libname):
+ return os.path.realpath(line.split()[-1])
+ except:
+ pass
+ return lib
def find_executable(exename, cwd=True, include_PATH=True, pathlist=None):
diff --git a/pyomo/common/formatting.py b/pyomo/common/formatting.py
index 5c2b329ce21..430ec96ca09 100644
--- a/pyomo/common/formatting.py
+++ b/pyomo/common/formatting.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/gc_manager.py b/pyomo/common/gc_manager.py
index 54fbca32736..751eb95cf18 100644
--- a/pyomo/common/gc_manager.py
+++ b/pyomo/common/gc_manager.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/getGSL.py b/pyomo/common/getGSL.py
index e8b2507ab81..66b75b45665 100644
--- a/pyomo/common/getGSL.py
+++ b/pyomo/common/getGSL.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/gsl.py b/pyomo/common/gsl.py
index 5243758a0de..96fab8623b3 100644
--- a/pyomo/common/gsl.py
+++ b/pyomo/common/gsl.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -23,8 +23,8 @@
)
def get_gsl(downloader):
logger.info(
- "As of February 9, 2023, AMPL GSL can no longer be downloaded\
- through download-extensions. Visit https://portal.ampl.com/\
+ "As of February 9, 2023, AMPL GSL can no longer be downloaded \
+ through download-extensions. Visit https://portal.ampl.com/ \
to download the AMPL GSL binaries."
)
diff --git a/pyomo/common/log.py b/pyomo/common/log.py
index 3097fe1c6de..d61ed62f373 100644
--- a/pyomo/common/log.py
+++ b/pyomo/common/log.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/modeling.py b/pyomo/common/modeling.py
index 5ecc56cce9b..4c07048d77a 100644
--- a/pyomo/common/modeling.py
+++ b/pyomo/common/modeling.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/multithread.py b/pyomo/common/multithread.py
index 415d8aaba7e..a2dace2be0f 100644
--- a/pyomo/common/multithread.py
+++ b/pyomo/common/multithread.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from collections import defaultdict
from threading import get_ident, main_thread
diff --git a/pyomo/common/numeric_types.py b/pyomo/common/numeric_types.py
index 19718b308b6..2b63038e125 100644
--- a/pyomo/common/numeric_types.py
+++ b/pyomo/common/numeric_types.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -12,7 +12,6 @@
import logging
import sys
-from pyomo.common.dependencies import numpy_available
from pyomo.common.deprecation import deprecated, relocated_module_attribute
from pyomo.common.errors import TemplateExpressionError
@@ -50,7 +49,6 @@
native_integer_types = {int}
native_logical_types = {bool}
native_complex_types = {complex}
-pyomo_constant_types = set() # includes NumericConstant
_native_boolean_types = {int, bool, str, bytes}
relocated_module_attribute(
@@ -62,6 +60,16 @@
"be treated as if they were bool (as was the case for the other "
"native_*_types sets). Users likely should use native_logical_types.",
)
+_pyomo_constant_types = set() # includes NumericConstant, _PythonCallbackFunctionID
+relocated_module_attribute(
+ 'pyomo_constant_types',
+ 'pyomo.common.numeric_types._pyomo_constant_types',
+ version='6.7.2',
+ msg="The pyomo_constant_types set will be removed in the future: the set "
+ "contained only NumericConstant and _PythonCallbackFunctionID, and provided "
+ "no meaningful value to clients or walkers. Users should likely handle "
+ "these types in the same manner as immutable Params.",
+)
#: Python set used to identify numeric constants and related native
@@ -194,6 +202,67 @@ def RegisterLogicalType(new_type: type):
nonpyomo_leaf_types.add(new_type)
+def check_if_native_type(obj):
+ if isinstance(obj, (str, bytes)):
+ native_types.add(obj.__class__)
+ return True
+ if check_if_logical_type(obj):
+ return True
+ if check_if_numeric_type(obj):
+ return True
+ return False
+
+
+def check_if_logical_type(obj):
+ """Test if the argument behaves like a logical type.
+
+ We check for "logical types" by checking if the type returns sane
+ results for Boolean operators (``^``, ``|``, ``&``) and if it maps
+ ``1`` and ``2`` both to the same equivalent instance. If that
+ works, then we register the type in :py:attr:`native_logical_types`.
+
+ """
+ obj_class = obj.__class__
+ # Do not re-evaluate known native types
+ if obj_class in native_types:
+ return obj_class in native_logical_types
+
+ try:
+ # It is not an error if you can't initialize the type from an
+ # int, but if you can, it should map !0 to True
+ if obj_class(1) != obj_class(2):
+ return False
+ except:
+ pass
+
+ try:
+ # Native logical types *must* be hashable
+ hash(obj)
+ # Native logical types must honor standard Boolean operators
+ if all(
+ (
+ obj_class(False) != obj_class(True),
+ obj_class(False) ^ obj_class(False) == obj_class(False),
+ obj_class(False) ^ obj_class(True) == obj_class(True),
+ obj_class(True) ^ obj_class(False) == obj_class(True),
+ obj_class(True) ^ obj_class(True) == obj_class(False),
+ obj_class(False) | obj_class(False) == obj_class(False),
+ obj_class(False) | obj_class(True) == obj_class(True),
+ obj_class(True) | obj_class(False) == obj_class(True),
+ obj_class(True) | obj_class(True) == obj_class(True),
+ obj_class(False) & obj_class(False) == obj_class(False),
+ obj_class(False) & obj_class(True) == obj_class(False),
+ obj_class(True) & obj_class(False) == obj_class(False),
+ obj_class(True) & obj_class(True) == obj_class(True),
+ )
+ ):
+ RegisterLogicalType(obj_class)
+ return True
+ except:
+ pass
+ return False
+
+
def check_if_numeric_type(obj):
"""Test if the argument behaves like a numeric type.
@@ -208,46 +277,55 @@ def check_if_numeric_type(obj):
if obj_class in native_types:
return obj_class in native_numeric_types
- if 'numpy' in obj_class.__module__:
- # trigger the resolution of numpy_available and check if this
- # type was automatically registered
- bool(numpy_available)
- if obj_class in native_types:
- return obj_class in native_numeric_types
-
try:
obj_plus_0 = obj + 0
obj_p0_class = obj_plus_0.__class__
- # ensure that the object is comparable to 0 in a meaningful way
- # (among other things, this prevents numpy.ndarray objects from
- # being added to native_numeric_types)
+ # Native numeric types *must* be hashable
+ hash(obj)
+ except:
+ return False
+ if obj_p0_class is not obj_class and obj_p0_class not in native_numeric_types:
+ return False
+ #
+ # Check if the numeric type behaves like a complex type
+ #
+ try:
+ if 1.41 < abs(obj_class(1j + 1)) < 1.42:
+ RegisterComplexType(obj_class)
+ return False
+ except:
+ pass
+ #
+ # Ensure that the object is comparable to 0 in a meaningful way
+ #
+ try:
if not ((obj < 0) ^ (obj >= 0)):
return False
- # Native types *must* be hashable
- hash(obj)
except:
return False
- if obj_p0_class is obj_class or obj_p0_class in native_numeric_types:
- #
- # If we get here, this is a reasonably well-behaving
- # numeric type: add it to the native numeric types
- # so that future lookups will be faster.
- #
- RegisterNumericType(obj_class)
- #
- # Generate a warning, since Pyomo's management of third-party
- # numeric types is more robust when registering explicitly.
- #
- logger.warning(
- f"""Dynamically registering the following numeric type:
+ #
+ # If we get here, this is a reasonably well-behaving
+ # numeric type: add it to the native numeric types
+ # so that future lookups will be faster.
+ #
+ RegisterNumericType(obj_class)
+ try:
+ if obj_class(0.4) == obj_class(0):
+ RegisterIntegerType(obj_class)
+ except:
+ pass
+ #
+ # Generate a warning, since Pyomo's management of third-party
+ # numeric types is more robust when registering explicitly.
+ #
+ logger.warning(
+ f"""Dynamically registering the following numeric type:
{obj_class.__module__}.{obj_class.__name__}
Dynamic registration is supported for convenience, but there are known
limitations to this approach. We recommend explicitly registering
numeric types using RegisterNumericType() or RegisterIntegerType()."""
- )
- return True
- else:
- return False
+ )
+ return True
def value(obj, exception=True):
@@ -274,22 +352,10 @@ def value(obj, exception=True):
"""
if obj.__class__ in native_types:
return obj
- if obj.__class__ in pyomo_constant_types:
- #
- # I'm commenting this out for now, but I think we should never expect
- # to see a numeric constant with value None.
- #
- # if exception and obj.value is None:
- # raise ValueError(
- # "No value for uninitialized NumericConstant object %s"
- # % (obj.name,))
- return obj.value
#
# Test if we have a duck typed Pyomo expression
#
- try:
- obj.is_numeric_type()
- except AttributeError:
+ if not hasattr(obj, 'is_numeric_type'):
#
# TODO: Historically we checked for new *numeric* types and
# raised exceptions for anything else. That is inconsistent
@@ -304,7 +370,7 @@ def value(obj, exception=True):
return None
raise TypeError(
"Cannot evaluate object with unknown type: %s" % obj.__class__.__name__
- ) from None
+ )
#
# Evaluate the expression object
#
diff --git a/pyomo/common/plugin.py b/pyomo/common/plugin.py
index b48fa96a483..ac88388ebc0 100644
--- a/pyomo/common/plugin.py
+++ b/pyomo/common/plugin.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/plugin_base.py b/pyomo/common/plugin_base.py
index 67960ebbb12..75b8657d1a9 100644
--- a/pyomo/common/plugin_base.py
+++ b/pyomo/common/plugin_base.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/plugins.py b/pyomo/common/plugins.py
index 7db8077855a..ed44f8bf776 100644
--- a/pyomo/common/plugins.py
+++ b/pyomo/common/plugins.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/pyomo_typing.py b/pyomo/common/pyomo_typing.py
index 64ab2ddafc9..22ec3480842 100644
--- a/pyomo/common/pyomo_typing.py
+++ b/pyomo/common/pyomo_typing.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/shutdown.py b/pyomo/common/shutdown.py
index 5054fd21279..a96a6bc04fc 100644
--- a/pyomo/common/shutdown.py
+++ b/pyomo/common/shutdown.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import atexit
diff --git a/pyomo/common/sorting.py b/pyomo/common/sorting.py
index 31e796c6a9e..4f78a7892b8 100644
--- a/pyomo/common/sorting.py
+++ b/pyomo/common/sorting.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tee.py b/pyomo/common/tee.py
index 029d66f5767..500f7b6f58d 100644
--- a/pyomo/common/tee.py
+++ b/pyomo/common/tee.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tempfiles.py b/pyomo/common/tempfiles.py
index f51fad3f3ac..b9dface71b2 100644
--- a/pyomo/common/tempfiles.py
+++ b/pyomo/common/tempfiles.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/__init__.py b/pyomo/common/tests/__init__.py
index bc8dfa27c9c..d8d8856e52f 100644
--- a/pyomo/common/tests/__init__.py
+++ b/pyomo/common/tests/__init__.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/config_plugin.py b/pyomo/common/tests/config_plugin.py
index ada788fd7d4..6aebc40806a 100644
--- a/pyomo/common/tests/config_plugin.py
+++ b/pyomo/common/tests/config_plugin.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/dep_mod.py b/pyomo/common/tests/dep_mod.py
index 54530393783..34c7219c6eb 100644
--- a/pyomo/common/tests/dep_mod.py
+++ b/pyomo/common/tests/dep_mod.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -13,8 +13,8 @@
__version__ = '1.5'
-numpy, numpy_available = attempt_import('numpy', defer_check=True)
+numpy, numpy_available = attempt_import('numpy', defer_import=True)
bogus_nonexisting_module, bogus_nonexisting_module_available = attempt_import(
- 'bogus_nonexisting_module', alt_names=['bogus_nem'], defer_check=True
+ 'bogus_nonexisting_module', alt_names=['bogus_nem'], defer_import=True
)
diff --git a/pyomo/common/tests/dep_mod_except.py b/pyomo/common/tests/dep_mod_except.py
index 8132e8a08ac..16936996eeb 100644
--- a/pyomo/common/tests/dep_mod_except.py
+++ b/pyomo/common/tests/dep_mod_except.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/deps.py b/pyomo/common/tests/deps.py
index e5236d0f7ec..5f8c1fffdf8 100644
--- a/pyomo/common/tests/deps.py
+++ b/pyomo/common/tests/deps.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -23,15 +23,16 @@
bogus_nonexisting_module_available as has_bogus_nem,
)
-bogus, bogus_available = attempt_import('nonexisting.module.bogus', defer_check=True)
+bogus, bogus_available = attempt_import('nonexisting.module.bogus', defer_import=True)
pkl_test, pkl_available = attempt_import(
- 'nonexisting.module.pickle_test', deferred_submodules=['submod'], defer_check=True
+ 'nonexisting.module.pickle_test', deferred_submodules=['submod'], defer_import=True
)
pyo, pyo_available = attempt_import(
'pyomo',
alt_names=['pyo'],
+ defer_import=True,
deferred_submodules={'version': None, 'common.tests.dep_mod': ['dm']},
)
diff --git a/pyomo/common/tests/import_ex.py b/pyomo/common/tests/import_ex.py
index e19ad956044..73375bdc819 100644
--- a/pyomo/common/tests/import_ex.py
+++ b/pyomo/common/tests/import_ex.py
@@ -1,3 +1,15 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+
def a():
pass
diff --git a/pyomo/common/tests/relo_mod.py b/pyomo/common/tests/relo_mod.py
index 20b0712e09b..4881caba671 100644
--- a/pyomo/common/tests/relo_mod.py
+++ b/pyomo/common/tests/relo_mod.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/relo_mod_new.py b/pyomo/common/tests/relo_mod_new.py
index 1ef27681b66..0f59f3beebc 100644
--- a/pyomo/common/tests/relo_mod_new.py
+++ b/pyomo/common/tests/relo_mod_new.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/relocated.py b/pyomo/common/tests/relocated.py
index 9de63e0cec9..90cb28c23ba 100644
--- a/pyomo/common/tests/relocated.py
+++ b/pyomo/common/tests/relocated.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_bunch.py b/pyomo/common/tests/test_bunch.py
index a8daf5a0071..8c10df83005 100644
--- a/pyomo/common/tests/test_bunch.py
+++ b/pyomo/common/tests/test_bunch.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_component_map.py b/pyomo/common/tests/test_component_map.py
new file mode 100644
index 00000000000..7cd4ec2c458
--- /dev/null
+++ b/pyomo/common/tests/test_component_map.py
@@ -0,0 +1,90 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+import pyomo.common.unittest as unittest
+
+from pyomo.common.collections import ComponentMap, ComponentSet, DefaultComponentMap
+from pyomo.environ import ConcreteModel, Block, Var, Constraint
+
+
+class TestComponentMap(unittest.TestCase):
+ def test_tuple(self):
+ m = ConcreteModel()
+ m.v = Var()
+ m.c = Constraint(expr=m.v >= 0)
+ m.cm = cm = ComponentMap()
+
+ cm[(1, 2)] = 5
+ self.assertEqual(len(cm), 1)
+ self.assertIn((1, 2), cm)
+ self.assertEqual(cm[1, 2], 5)
+
+ cm[(1, 2)] = 50
+ self.assertEqual(len(cm), 1)
+ self.assertIn((1, 2), cm)
+ self.assertEqual(cm[1, 2], 50)
+
+ cm[(1, (2, m.v))] = 10
+ self.assertEqual(len(cm), 2)
+ self.assertIn((1, (2, m.v)), cm)
+ self.assertEqual(cm[1, (2, m.v)], 10)
+
+ cm[(1, (2, m.v))] = 100
+ self.assertEqual(len(cm), 2)
+ self.assertIn((1, (2, m.v)), cm)
+ self.assertEqual(cm[1, (2, m.v)], 100)
+
+ i = m.clone()
+ self.assertIn((1, 2), i.cm)
+ self.assertIn((1, (2, i.v)), i.cm)
+ self.assertNotIn((1, (2, i.v)), m.cm)
+ self.assertIn((1, (2, m.v)), m.cm)
+ self.assertNotIn((1, (2, m.v)), i.cm)
+
+
+class TestDefaultComponentMap(unittest.TestCase):
+ def test_default_component_map(self):
+ dcm = DefaultComponentMap(ComponentSet)
+
+ m = ConcreteModel()
+ m.x = Var()
+ m.b = Block()
+ m.b.y = Var()
+
+ self.assertEqual(len(dcm), 0)
+
+ dcm[m.x].add(m)
+ self.assertEqual(len(dcm), 1)
+ self.assertIn(m.x, dcm)
+ self.assertIn(m, dcm[m.x])
+
+ dcm[m.b.y].add(m.b)
+ self.assertEqual(len(dcm), 2)
+ self.assertIn(m.b.y, dcm)
+ self.assertNotIn(m, dcm[m.b.y])
+ self.assertIn(m.b, dcm[m.b.y])
+
+ dcm[m.b.y].add(m)
+ self.assertEqual(len(dcm), 2)
+ self.assertIn(m.b.y, dcm)
+ self.assertIn(m, dcm[m.b.y])
+ self.assertIn(m.b, dcm[m.b.y])
+
+ def test_no_default_factory(self):
+ dcm = DefaultComponentMap()
+
+ dcm['found'] = 5
+ self.assertEqual(len(dcm), 1)
+ self.assertIn('found', dcm)
+ self.assertEqual(dcm['found'], 5)
+
+ with self.assertRaisesRegex(KeyError, "'missing'"):
+ dcm["missing"]
diff --git a/pyomo/common/tests/test_config.py b/pyomo/common/tests/test_config.py
index 1b732d86c0a..a47f5e0d8af 100644
--- a/pyomo/common/tests/test_config.py
+++ b/pyomo/common/tests/test_config.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -60,6 +60,7 @@ def yaml_load(arg):
NonPositiveFloat,
NonNegativeFloat,
In,
+ IsInstance,
ListOf,
Module,
Path,
@@ -448,12 +449,85 @@ class TestEnum(enum.Enum):
with self.assertRaisesRegex(ValueError, '.*invalid value'):
cfg.enum = 'ITEM_THREE'
+ def test_IsInstance(self):
+ c = ConfigDict()
+ c.declare("val", ConfigValue(None, IsInstance(int)))
+ c.val = 1
+ self.assertEqual(c.val, 1)
+ exc_str = (
+ "Expected an instance of 'int', but received value 2.4 of type 'float'"
+ )
+ with self.assertRaisesRegex(ValueError, exc_str):
+ c.val = 2.4
+
+ class TestClass:
+ def __repr__(self):
+ return f"{TestClass.__name__}()"
+
+ c.declare("val2", ConfigValue(None, IsInstance(TestClass)))
+ testinst = TestClass()
+ c.val2 = testinst
+ self.assertEqual(c.val2, testinst)
+ exc_str = (
+ r"Expected an instance of 'TestClass', "
+ "but received value 2.4 of type 'float'"
+ )
+ with self.assertRaisesRegex(ValueError, exc_str):
+ c.val2 = 2.4
+
+ c.declare(
+ "val3",
+ ConfigValue(
+ None, IsInstance(int, TestClass, document_full_base_names=True)
+ ),
+ )
+ self.assertRegex(
+ c.get("val3").domain_name(), r"IsInstance\(int, .*\.TestClass\)"
+ )
+ c.val3 = 2
+ self.assertEqual(c.val3, 2)
+ exc_str = (
+ r"Expected an instance of one of these types: 'int', '.*\.TestClass'"
+ r", but received value 2.4 of type 'float'"
+ )
+ with self.assertRaisesRegex(ValueError, exc_str):
+ c.val3 = 2.4
+
+ c.declare(
+ "val4",
+ ConfigValue(
+ None, IsInstance(int, TestClass, document_full_base_names=False)
+ ),
+ )
+ self.assertEqual(c.get("val4").domain_name(), "IsInstance(int, TestClass)")
+ c.val4 = 2
+ self.assertEqual(c.val4, 2)
+ exc_str = (
+ r"Expected an instance of one of these types: 'int', 'TestClass'"
+ r", but received value 2.4 of type 'float'"
+ )
+ with self.assertRaisesRegex(ValueError, exc_str):
+ c.val4 = 2.4
+
def test_Path(self):
def norm(x):
if cwd[1] == ':' and x[0] == '/':
x = cwd[:2] + x
return x.replace('/', os.path.sep)
+ class ExamplePathLike:
+ def __init__(self, path_str_or_bytes):
+ self.path = path_str_or_bytes
+
+ def __fspath__(self):
+ return self.path
+
+ def __str__(self):
+ path_str = str(self.path)
+ return f"{type(self).__name__}({path_str})"
+
+ self.assertEqual(Path().domain_name(), "Path")
+
cwd = os.getcwd() + os.path.sep
c = ConfigDict()
@@ -462,12 +536,30 @@ def norm(x):
c.a = "/a/b/c"
self.assertTrue(os.path.sep in c.a)
self.assertEqual(c.a, norm('/a/b/c'))
+ c.a = b"/a/b/c"
+ self.assertTrue(os.path.sep in c.a)
+ self.assertEqual(c.a, norm('/a/b/c'))
+ c.a = ExamplePathLike("/a/b/c")
+ self.assertTrue(os.path.sep in c.a)
+ self.assertEqual(c.a, norm('/a/b/c'))
c.a = "a/b/c"
self.assertTrue(os.path.sep in c.a)
self.assertEqual(c.a, norm(cwd + 'a/b/c'))
+ c.a = b'a/b/c'
+ self.assertTrue(os.path.sep in c.a)
+ self.assertEqual(c.a, norm(cwd + 'a/b/c'))
+ c.a = ExamplePathLike('a/b/c')
+ self.assertTrue(os.path.sep in c.a)
+ self.assertEqual(c.a, norm(cwd + 'a/b/c'))
c.a = "${CWD}/a/b/c"
self.assertTrue(os.path.sep in c.a)
self.assertEqual(c.a, norm(cwd + 'a/b/c'))
+ c.a = b'${CWD}/a/b/c'
+ self.assertTrue(os.path.sep in c.a)
+ self.assertEqual(c.a, norm(cwd + 'a/b/c'))
+ c.a = ExamplePathLike('${CWD}/a/b/c')
+ self.assertTrue(os.path.sep in c.a)
+ self.assertEqual(c.a, norm(cwd + 'a/b/c'))
c.a = None
self.assertIs(c.a, None)
@@ -476,12 +568,30 @@ def norm(x):
c.b = "/a/b/c"
self.assertTrue(os.path.sep in c.b)
self.assertEqual(c.b, norm('/a/b/c'))
+ c.b = b"/a/b/c"
+ self.assertTrue(os.path.sep in c.b)
+ self.assertEqual(c.b, norm('/a/b/c'))
+ c.b = ExamplePathLike("/a/b/c")
+ self.assertTrue(os.path.sep in c.b)
+ self.assertEqual(c.b, norm('/a/b/c'))
c.b = "a/b/c"
self.assertTrue(os.path.sep in c.b)
self.assertEqual(c.b, norm(cwd + 'rel/path/a/b/c'))
+ c.b = b"a/b/c"
+ self.assertTrue(os.path.sep in c.b)
+ self.assertEqual(c.b, norm(cwd + 'rel/path/a/b/c'))
+ c.b = ExamplePathLike("a/b/c")
+ self.assertTrue(os.path.sep in c.b)
+ self.assertEqual(c.b, norm(cwd + "rel/path/a/b/c"))
c.b = "${CWD}/a/b/c"
self.assertTrue(os.path.sep in c.b)
self.assertEqual(c.b, norm(cwd + 'a/b/c'))
+ c.b = b"${CWD}/a/b/c"
+ self.assertTrue(os.path.sep in c.b)
+ self.assertEqual(c.b, norm(cwd + 'a/b/c'))
+ c.b = ExamplePathLike("${CWD}/a/b/c")
+ self.assertTrue(os.path.sep in c.b)
+ self.assertEqual(c.b, norm(cwd + 'a/b/c'))
c.b = None
self.assertIs(c.b, None)
@@ -490,12 +600,30 @@ def norm(x):
c.c = "/a/b/c"
self.assertTrue(os.path.sep in c.c)
self.assertEqual(c.c, norm('/a/b/c'))
+ c.c = b"/a/b/c"
+ self.assertTrue(os.path.sep in c.c)
+ self.assertEqual(c.c, norm('/a/b/c'))
+ c.c = ExamplePathLike("/a/b/c")
+ self.assertTrue(os.path.sep in c.c)
+ self.assertEqual(c.c, norm('/a/b/c'))
c.c = "a/b/c"
self.assertTrue(os.path.sep in c.c)
self.assertEqual(c.c, norm('/my/dir/a/b/c'))
+ c.c = b"a/b/c"
+ self.assertTrue(os.path.sep in c.c)
+ self.assertEqual(c.c, norm('/my/dir/a/b/c'))
+ c.c = ExamplePathLike("a/b/c")
+ self.assertTrue(os.path.sep in c.c)
+ self.assertEqual(c.c, norm("/my/dir/a/b/c"))
c.c = "${CWD}/a/b/c"
self.assertTrue(os.path.sep in c.c)
self.assertEqual(c.c, norm(cwd + 'a/b/c'))
+ c.c = b"${CWD}/a/b/c"
+ self.assertTrue(os.path.sep in c.c)
+ self.assertEqual(c.c, norm(cwd + 'a/b/c'))
+ c.c = ExamplePathLike("${CWD}/a/b/c")
+ self.assertTrue(os.path.sep in c.c)
+ self.assertEqual(c.c, norm(cwd + 'a/b/c'))
c.c = None
self.assertIs(c.c, None)
@@ -505,12 +633,30 @@ def norm(x):
c.d = "/a/b/c"
self.assertTrue(os.path.sep in c.d)
self.assertEqual(c.d, norm('/a/b/c'))
+ c.d = b"/a/b/c"
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm('/a/b/c'))
+ c.d = ExamplePathLike("/a/b/c")
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm('/a/b/c'))
c.d = "a/b/c"
self.assertTrue(os.path.sep in c.d)
self.assertEqual(c.d, norm(cwd + 'a/b/c'))
+ c.d = b"a/b/c"
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm(cwd + 'a/b/c'))
+ c.d = ExamplePathLike("a/b/c")
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm(cwd + 'a/b/c'))
c.d = "${CWD}/a/b/c"
self.assertTrue(os.path.sep in c.d)
self.assertEqual(c.d, norm(cwd + 'a/b/c'))
+ c.d = b"${CWD}/a/b/c"
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm(cwd + 'a/b/c'))
+ c.d = ExamplePathLike("${CWD}/a/b/c")
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm(cwd + 'a/b/c'))
c.d_base = '/my/dir'
c.d = "/a/b/c"
@@ -527,12 +673,30 @@ def norm(x):
c.d = "/a/b/c"
self.assertTrue(os.path.sep in c.d)
self.assertEqual(c.d, norm('/a/b/c'))
+ c.d = b"/a/b/c"
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm('/a/b/c'))
+ c.d = ExamplePathLike("/a/b/c")
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm('/a/b/c'))
c.d = "a/b/c"
self.assertTrue(os.path.sep in c.d)
self.assertEqual(c.d, norm(cwd + 'rel/path/a/b/c'))
+ c.d = b"a/b/c"
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm(cwd + 'rel/path/a/b/c'))
+ c.d = ExamplePathLike("a/b/c")
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm(cwd + 'rel/path/a/b/c'))
c.d = "${CWD}/a/b/c"
self.assertTrue(os.path.sep in c.d)
self.assertEqual(c.d, norm(cwd + 'a/b/c'))
+ c.d = b"${CWD}/a/b/c"
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm(cwd + 'a/b/c'))
+ c.d = ExamplePathLike("${CWD}/a/b/c")
+ self.assertTrue(os.path.sep in c.d)
+ self.assertEqual(c.d, norm(cwd + 'a/b/c'))
try:
Path.SuppressPathExpansion = True
@@ -540,14 +704,38 @@ def norm(x):
self.assertTrue('/' in c.d)
self.assertTrue('\\' not in c.d)
self.assertEqual(c.d, '/a/b/c')
+ c.d = b"/a/b/c"
+ self.assertTrue('/' in c.d)
+ self.assertTrue('\\' not in c.d)
+ self.assertEqual(c.d, '/a/b/c')
+ c.d = ExamplePathLike("/a/b/c")
+ self.assertTrue('/' in c.d)
+ self.assertTrue('\\' not in c.d)
+ self.assertEqual(c.d, '/a/b/c')
c.d = "a/b/c"
self.assertTrue('/' in c.d)
self.assertTrue('\\' not in c.d)
self.assertEqual(c.d, 'a/b/c')
+ c.d = b"a/b/c"
+ self.assertTrue('/' in c.d)
+ self.assertTrue('\\' not in c.d)
+ self.assertEqual(c.d, 'a/b/c')
+ c.d = ExamplePathLike("a/b/c")
+ self.assertTrue('/' in c.d)
+ self.assertTrue('\\' not in c.d)
+ self.assertEqual(c.d, 'a/b/c')
c.d = "${CWD}/a/b/c"
self.assertTrue('/' in c.d)
self.assertTrue('\\' not in c.d)
self.assertEqual(c.d, "${CWD}/a/b/c")
+ c.d = b"${CWD}/a/b/c"
+ self.assertTrue('/' in c.d)
+ self.assertTrue('\\' not in c.d)
+ self.assertEqual(c.d, "${CWD}/a/b/c")
+ c.d = ExamplePathLike("${CWD}/a/b/c")
+ self.assertTrue('/' in c.d)
+ self.assertTrue('\\' not in c.d)
+ self.assertEqual(c.d, "${CWD}/a/b/c")
finally:
Path.SuppressPathExpansion = False
@@ -560,6 +748,8 @@ def norm(x):
cwd = os.getcwd() + os.path.sep
c = ConfigDict()
+ self.assertEqual(PathList().domain_name(), "PathList")
+
c.declare('a', ConfigValue(None, PathList()))
self.assertEqual(c.a, None)
c.a = "/a/b/c"
@@ -582,6 +772,13 @@ def norm(x):
self.assertEqual(len(c.a), 0)
self.assertIs(type(c.a), list)
+ exc_str = r".*expected str, bytes or os.PathLike.*int"
+
+ with self.assertRaisesRegex(ValueError, exc_str):
+ c.a = 2
+ with self.assertRaisesRegex(ValueError, exc_str):
+ c.a = ["/a/b/c", 2]
+
def test_ListOf(self):
c = ConfigDict()
c.declare('a', ConfigValue(domain=ListOf(int), default=None))
@@ -1473,7 +1670,7 @@ def test_parseDisplay_userdata_add_block_nonDefault(self):
self.config.add("bar", ConfigDict(implicit=True)).add("baz", ConfigDict())
test = _display(self.config, 'userdata')
sys.stdout.write(test)
- self.assertEqual(yaml_load(test), {'bar': {'baz': None}, foo: 0})
+ self.assertEqual(yaml_load(test), {'bar': {'baz': None}, 'foo': 0})
@unittest.skipIf(not yaml_available, "Test requires PyYAML")
def test_parseDisplay_userdata_add_block(self):
@@ -1901,7 +2098,6 @@ def test_generate_custom_documentation(self):
"generate_documentation is deprecated.",
LOG,
)
- self.maxDiff = None
# print(test)
self.assertEqual(test, reference)
@@ -1916,7 +2112,6 @@ def test_generate_custom_documentation(self):
)
)
self.assertEqual(LOG.getvalue(), "")
- self.maxDiff = None
# print(test)
self.assertEqual(test, reference)
@@ -1962,7 +2157,6 @@ def test_generate_custom_documentation(self):
"generate_documentation is deprecated.",
LOG,
)
- self.maxDiff = None
# print(test)
self.assertEqual(test, reference)
@@ -2380,7 +2574,6 @@ def test_argparse_help_implicit_disable(self):
parser = argparse.ArgumentParser(prog='tester')
self.config.initialize_argparse(parser)
help = parser.format_help()
- self.maxDiff = None
self.assertIn(
"""
-h, --help show this help message and exit
@@ -2909,8 +3102,6 @@ def test_declare_from(self):
cfg2.declare_from({})
def test_docstring_decorator(self):
- self.maxDiff = None
-
@document_kwargs_from_configdict('CONFIG')
class ExampleClass(object):
CONFIG = ExampleConfig()
@@ -3068,6 +3259,41 @@ def __init__(
OUT.getvalue().replace('null', 'None'),
)
+ def test_domain_name(self):
+ cfg = ConfigDict()
+
+ cfg.declare('none', ConfigValue())
+ self.assertEqual(cfg.get('none').domain_name(), '')
+
+ def fcn(val):
+ return val
+
+ cfg.declare('fcn', ConfigValue(domain=fcn))
+ self.assertEqual(cfg.get('fcn').domain_name(), 'fcn')
+
+ fcn.domain_name = 'custom fcn'
+ self.assertEqual(cfg.get('fcn').domain_name(), 'custom fcn')
+
+ class functor:
+ def __call__(self, val):
+ return val
+
+ cfg.declare('functor', ConfigValue(domain=functor()))
+ self.assertEqual(cfg.get('functor').domain_name(), 'functor')
+
+ class cfunctor:
+ def __call__(self, val):
+ return val
+
+ def domain_name(self):
+ return 'custom functor'
+
+ cfg.declare('cfunctor', ConfigValue(domain=cfunctor()))
+ self.assertEqual(cfg.get('cfunctor').domain_name(), 'custom functor')
+
+ cfg.declare('type', ConfigValue(domain=int))
+ self.assertEqual(cfg.get('type').domain_name(), 'int')
+
if __name__ == "__main__":
unittest.main()
diff --git a/pyomo/common/tests/test_dependencies.py b/pyomo/common/tests/test_dependencies.py
index 65058e01812..6aedc428244 100644
--- a/pyomo/common/tests/test_dependencies.py
+++ b/pyomo/common/tests/test_dependencies.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -45,7 +45,7 @@ def test_import_error(self):
module_obj, module_available = attempt_import(
'__there_is_no_module_named_this__',
'Testing import of a non-existent module',
- defer_check=False,
+ defer_import=False,
)
self.assertFalse(module_available)
with self.assertRaisesRegex(
@@ -85,7 +85,7 @@ def test_pickle(self):
def test_import_success(self):
module_obj, module_available = attempt_import(
- 'ply', 'Testing import of ply', defer_check=False
+ 'ply', 'Testing import of ply', defer_import=False
)
self.assertTrue(module_available)
import ply
@@ -123,7 +123,7 @@ def test_imported_deferred_import(self):
def test_min_version(self):
mod, avail = attempt_import(
- 'pyomo.common.tests.dep_mod', minimum_version='1.0', defer_check=False
+ 'pyomo.common.tests.dep_mod', minimum_version='1.0', defer_import=False
)
self.assertTrue(avail)
self.assertTrue(inspect.ismodule(mod))
@@ -131,7 +131,7 @@ def test_min_version(self):
self.assertFalse(check_min_version(mod, '2.0'))
mod, avail = attempt_import(
- 'pyomo.common.tests.dep_mod', minimum_version='2.0', defer_check=False
+ 'pyomo.common.tests.dep_mod', minimum_version='2.0', defer_import=False
)
self.assertFalse(avail)
self.assertIs(type(mod), ModuleUnavailable)
@@ -146,7 +146,7 @@ def test_min_version(self):
'pyomo.common.tests.dep_mod',
error_message="Failed import",
minimum_version='2.0',
- defer_check=False,
+ defer_import=False,
)
self.assertFalse(avail)
self.assertIs(type(mod), ModuleUnavailable)
@@ -159,10 +159,10 @@ def test_min_version(self):
# Verify check_min_version works with deferred imports
- mod, avail = attempt_import('pyomo.common.tests.dep_mod', defer_check=True)
+ mod, avail = attempt_import('pyomo.common.tests.dep_mod', defer_import=True)
self.assertTrue(check_min_version(mod, '1.0'))
- mod, avail = attempt_import('pyomo.common.tests.dep_mod', defer_check=True)
+ mod, avail = attempt_import('pyomo.common.tests.dep_mod', defer_import=True)
self.assertFalse(check_min_version(mod, '2.0'))
# Verify check_min_version works when called directly
@@ -174,10 +174,10 @@ def test_min_version(self):
self.assertFalse(check_min_version(mod, '1.0'))
def test_and_or(self):
- mod0, avail0 = attempt_import('ply', defer_check=True)
- mod1, avail1 = attempt_import('pyomo.common.tests.dep_mod', defer_check=True)
+ mod0, avail0 = attempt_import('ply', defer_import=True)
+ mod1, avail1 = attempt_import('pyomo.common.tests.dep_mod', defer_import=True)
mod2, avail2 = attempt_import(
- 'pyomo.common.tests.dep_mod', minimum_version='2.0', defer_check=True
+ 'pyomo.common.tests.dep_mod', minimum_version='2.0', defer_import=True
)
_and = avail0 & avail1
@@ -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
@@ -233,11 +233,11 @@ def test_callbacks(self):
def _record_avail(module, avail):
ans.append(avail)
- mod0, avail0 = attempt_import('ply', defer_check=True, callback=_record_avail)
+ mod0, avail0 = attempt_import('ply', defer_import=True, callback=_record_avail)
mod1, avail1 = attempt_import(
'pyomo.common.tests.dep_mod',
minimum_version='2.0',
- defer_check=True,
+ defer_import=True,
callback=_record_avail,
)
@@ -250,7 +250,7 @@ def _record_avail(module, avail):
def test_import_exceptions(self):
mod, avail = attempt_import(
'pyomo.common.tests.dep_mod_except',
- defer_check=True,
+ defer_import=True,
only_catch_importerror=True,
)
with self.assertRaisesRegex(ValueError, "cannot import module"):
@@ -260,7 +260,7 @@ def test_import_exceptions(self):
mod, avail = attempt_import(
'pyomo.common.tests.dep_mod_except',
- defer_check=True,
+ defer_import=True,
only_catch_importerror=False,
)
self.assertFalse(avail)
@@ -268,7 +268,7 @@ def test_import_exceptions(self):
mod, avail = attempt_import(
'pyomo.common.tests.dep_mod_except',
- defer_check=True,
+ defer_import=True,
catch_exceptions=(ImportError, ValueError),
)
self.assertFalse(avail)
@@ -280,7 +280,7 @@ def test_import_exceptions(self):
):
mod, avail = attempt_import(
'pyomo.common.tests.dep_mod_except',
- defer_check=True,
+ defer_import=True,
only_catch_importerror=True,
catch_exceptions=(ImportError,),
)
@@ -288,7 +288,7 @@ def test_import_exceptions(self):
def test_generate_warning(self):
mod, avail = attempt_import(
'pyomo.common.tests.dep_mod_except',
- defer_check=True,
+ defer_import=True,
only_catch_importerror=False,
)
@@ -324,7 +324,7 @@ def test_generate_warning(self):
def test_log_warning(self):
mod, avail = attempt_import(
'pyomo.common.tests.dep_mod_except',
- defer_check=True,
+ defer_import=True,
only_catch_importerror=False,
)
log = StringIO()
@@ -366,9 +366,9 @@ def test_importer(self):
def _importer():
attempted_import.append(True)
- return attempt_import('pyomo.common.tests.dep_mod', defer_check=False)[0]
+ return attempt_import('pyomo.common.tests.dep_mod', defer_import=False)[0]
- mod, avail = attempt_import('foo', importer=_importer, defer_check=True)
+ mod, avail = attempt_import('foo', importer=_importer, defer_import=True)
self.assertEqual(attempted_import, [])
self.assertIsInstance(mod, DeferredImportModule)
@@ -401,17 +401,17 @@ def test_deferred_submodules(self):
self.assertTrue(inspect.ismodule(deps.dm))
with self.assertRaisesRegex(
- ValueError, "deferred_submodules is only valid if defer_check==True"
+ ValueError, "deferred_submodules is only valid if defer_import==True"
):
mod, mod_available = attempt_import(
'nonexisting.module',
- defer_check=False,
+ defer_import=False,
deferred_submodules={'submod': None},
)
mod, mod_available = attempt_import(
'nonexisting.module',
- defer_check=True,
+ defer_import=True,
deferred_submodules={'submod.subsubmod': None},
)
self.assertIs(type(mod), DeferredImportModule)
@@ -427,7 +427,7 @@ def test_UnavailableClass(self):
module_obj, module_available = attempt_import(
'__there_is_no_module_named_this__',
'Testing import of a non-existent module',
- defer_check=False,
+ defer_import=False,
)
class A_Class(UnavailableClass(module_obj)):
diff --git a/pyomo/common/tests/test_deprecated.py b/pyomo/common/tests/test_deprecated.py
index 1fb4a471740..37e1ba81bb3 100644
--- a/pyomo/common/tests/test_deprecated.py
+++ b/pyomo/common/tests/test_deprecated.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -529,7 +529,10 @@ class DeprecatedClassSubclass(DeprecatedClass):
out = StringIO()
with LoggingIntercept(out):
- class DeprecatedClassSubSubclass(DeprecatedClassSubclass):
+ class otherClass:
+ pass
+
+ class DeprecatedClassSubSubclass(DeprecatedClassSubclass, otherClass):
attr = 'DeprecatedClassSubSubclass'
self.assertEqual(out.getvalue(), "")
diff --git a/pyomo/common/tests/test_download.py b/pyomo/common/tests/test_download.py
index 8c41edc1512..8fee0ba7e31 100644
--- a/pyomo/common/tests/test_download.py
+++ b/pyomo/common/tests/test_download.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -9,12 +9,14 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
+import io
import os
import platform
import re
import shutil
-import tempfile
import subprocess
+import tarfile
+import tempfile
import pyomo.common.unittest as unittest
import pyomo.common.envvar as envvar
@@ -22,6 +24,7 @@
from pyomo.common import DeveloperError
from pyomo.common.fileutils import this_file
from pyomo.common.download import FileDownloader, distro_available
+from pyomo.common.log import LoggingIntercept
from pyomo.common.tee import capture_output
@@ -242,7 +245,7 @@ def test_get_files_requires_set_destination(self):
):
f.get_gzipped_binary_file('bogus')
- def test_get_test_binary_file(self):
+ def test_get_text_binary_file(self):
tmpdir = tempfile.mkdtemp()
try:
f = FileDownloader()
@@ -263,3 +266,66 @@ def test_get_test_binary_file(self):
self.assertEqual(os.path.getsize(target), len(os.linesep))
finally:
shutil.rmtree(tmpdir)
+
+ def test_get_tar_archive(self):
+ tmpdir = tempfile.mkdtemp()
+ try:
+ f = FileDownloader()
+
+ # Mock retrieve_url so network connections are not necessary
+ buf = io.BytesIO()
+ with tarfile.open(mode="w:gz", fileobj=buf) as TAR:
+ info = tarfile.TarInfo('b/lnk')
+ info.size = 0
+ info.type = tarfile.SYMTYPE
+ info.linkname = envvar.PYOMO_CONFIG_DIR
+ TAR.addfile(info)
+ for fname in ('a', 'b/c', 'b/d', '/root', 'b/lnk/test'):
+ info = tarfile.TarInfo(fname)
+ info.size = 0
+ info.type = tarfile.REGTYPE
+ info.mode = 0o644
+ info.mtime = info.uid = info.gid = 0
+ info.uname = info.gname = 'root'
+ TAR.addfile(info)
+ f.retrieve_url = lambda url: buf.getvalue()
+
+ with self.assertRaisesRegex(
+ DeveloperError,
+ r"(?s)target file name has not been initialized "
+ r"with set_destination_filename".replace(' ', r'\s+'),
+ ):
+ f.get_tar_archive(None, 1)
+
+ _tmp = os.path.join(tmpdir, 'a_file')
+ with open(_tmp, 'w'):
+ pass
+ f.set_destination_filename(_tmp)
+ with self.assertRaisesRegex(
+ RuntimeError,
+ r"Target directory \(.*a_file\) exists, but is not a directory",
+ ):
+ f.get_tar_archive(None, 1)
+
+ f.set_destination_filename(tmpdir)
+ with LoggingIntercept() as LOG:
+ f.get_tar_archive(None, 1)
+
+ self.assertEqual(
+ LOG.getvalue().strip(),
+ """
+Skipping file (a) in tar archive due to dirOffset.
+malformed or potentially insecure filename (/root). Skipping file.
+potentially insecure filename (lnk/test) resolves outside target directory. Skipping file.
+""".strip(),
+ )
+ for f in ('c', 'd'):
+ fname = os.path.join(tmpdir, f)
+ self.assertTrue(os.path.exists(fname))
+ self.assertTrue(os.path.isfile(fname))
+ for f in ('lnk',):
+ fname = os.path.join(tmpdir, f)
+ self.assertTrue(os.path.exists(fname))
+ self.assertTrue(os.path.islink(fname))
+ finally:
+ shutil.rmtree(tmpdir)
diff --git a/pyomo/common/tests/test_enums.py b/pyomo/common/tests/test_enums.py
new file mode 100644
index 00000000000..80d081505e9
--- /dev/null
+++ b/pyomo/common/tests/test_enums.py
@@ -0,0 +1,97 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+import enum
+
+import pyomo.common.unittest as unittest
+
+from pyomo.common.enums import ExtendedEnumType, ObjectiveSense
+
+
+class ProblemSense(enum.IntEnum, metaclass=ExtendedEnumType):
+ __base_enum__ = ObjectiveSense
+
+ unknown = 0
+
+
+class TestExtendedEnumType(unittest.TestCase):
+ def test_members(self):
+ self.assertEqual(
+ list(ProblemSense),
+ [ProblemSense.unknown, ObjectiveSense.minimize, ObjectiveSense.maximize],
+ )
+
+ def test_isinstance(self):
+ self.assertIsInstance(ProblemSense.unknown, ProblemSense)
+ self.assertIsInstance(ProblemSense.minimize, ProblemSense)
+ self.assertIsInstance(ProblemSense.maximize, ProblemSense)
+
+ self.assertTrue(ProblemSense.__instancecheck__(ProblemSense.unknown))
+ self.assertTrue(ProblemSense.__instancecheck__(ProblemSense.minimize))
+ self.assertTrue(ProblemSense.__instancecheck__(ProblemSense.maximize))
+
+ def test_getattr(self):
+ self.assertIs(ProblemSense.unknown, ProblemSense.unknown)
+ self.assertIs(ProblemSense.minimize, ObjectiveSense.minimize)
+ self.assertIs(ProblemSense.maximize, ObjectiveSense.maximize)
+
+ def test_hasattr(self):
+ self.assertTrue(hasattr(ProblemSense, 'unknown'))
+ self.assertTrue(hasattr(ProblemSense, 'minimize'))
+ self.assertTrue(hasattr(ProblemSense, 'maximize'))
+
+ def test_call(self):
+ self.assertIs(ProblemSense(0), ProblemSense.unknown)
+ self.assertIs(ProblemSense(1), ObjectiveSense.minimize)
+ self.assertIs(ProblemSense(-1), ObjectiveSense.maximize)
+
+ self.assertIs(ProblemSense('unknown'), ProblemSense.unknown)
+ self.assertIs(ProblemSense('minimize'), ObjectiveSense.minimize)
+ self.assertIs(ProblemSense('maximize'), ObjectiveSense.maximize)
+
+ with self.assertRaisesRegex(ValueError, "'foo' is not a valid ProblemSense"):
+ ProblemSense('foo')
+ with self.assertRaisesRegex(ValueError, "2 is not a valid ProblemSense"):
+ ProblemSense(2)
+
+ def test_contains(self):
+ self.assertIn(ProblemSense.unknown, ProblemSense)
+ self.assertIn(ProblemSense.minimize, ProblemSense)
+ self.assertIn(ProblemSense.maximize, ProblemSense)
+
+ self.assertNotIn(ProblemSense.unknown, ObjectiveSense)
+ self.assertIn(ProblemSense.minimize, ObjectiveSense)
+ self.assertIn(ProblemSense.maximize, ObjectiveSense)
+
+
+class TestObjectiveSense(unittest.TestCase):
+ def test_members(self):
+ self.assertEqual(
+ list(ObjectiveSense), [ObjectiveSense.minimize, ObjectiveSense.maximize]
+ )
+
+ def test_hasattr(self):
+ self.assertTrue(hasattr(ProblemSense, 'minimize'))
+ self.assertTrue(hasattr(ProblemSense, 'maximize'))
+
+ def test_call(self):
+ self.assertIs(ObjectiveSense(1), ObjectiveSense.minimize)
+ self.assertIs(ObjectiveSense(-1), ObjectiveSense.maximize)
+
+ self.assertIs(ObjectiveSense('minimize'), ObjectiveSense.minimize)
+ self.assertIs(ObjectiveSense('maximize'), ObjectiveSense.maximize)
+
+ with self.assertRaisesRegex(ValueError, "'foo' is not a valid ObjectiveSense"):
+ ObjectiveSense('foo')
+
+ def test_str(self):
+ self.assertEqual(str(ObjectiveSense.minimize), 'minimize')
+ self.assertEqual(str(ObjectiveSense.maximize), 'maximize')
diff --git a/pyomo/common/tests/test_env.py b/pyomo/common/tests/test_env.py
index d14326ddc19..93802fc40bb 100644
--- a/pyomo/common/tests/test_env.py
+++ b/pyomo/common/tests/test_env.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_errors.py b/pyomo/common/tests/test_errors.py
index ec77643f722..67a200e84e3 100644
--- a/pyomo/common/tests/test_errors.py
+++ b/pyomo/common/tests/test_errors.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_fileutils.py b/pyomo/common/tests/test_fileutils.py
index 63570774e5b..068360b55cb 100644
--- a/pyomo/common/tests/test_fileutils.py
+++ b/pyomo/common/tests/test_fileutils.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_formatting.py b/pyomo/common/tests/test_formatting.py
index d502c81da5a..29db26676ab 100644
--- a/pyomo/common/tests/test_formatting.py
+++ b/pyomo/common/tests/test_formatting.py
@@ -2,7 +2,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_gc.py b/pyomo/common/tests/test_gc.py
index b2f23102a0e..176010b8d0d 100644
--- a/pyomo/common/tests/test_gc.py
+++ b/pyomo/common/tests/test_gc.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_log.py b/pyomo/common/tests/test_log.py
index 39fab153e98..166e1e44cdb 100644
--- a/pyomo/common/tests/test_log.py
+++ b/pyomo/common/tests/test_log.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -511,7 +511,6 @@ def test_verbatim(self):
"\n"
" quote block\n"
)
- self.maxDiff = None
self.assertEqual(self.stream.getvalue(), ans)
diff --git a/pyomo/common/tests/test_modeling.py b/pyomo/common/tests/test_modeling.py
index 0684d77b2e9..97bef76c2c0 100644
--- a/pyomo/common/tests/test_modeling.py
+++ b/pyomo/common/tests/test_modeling.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_multithread.py b/pyomo/common/tests/test_multithread.py
index ae1bc48be44..fa1a46fa25f 100644
--- a/pyomo/common/tests/test_multithread.py
+++ b/pyomo/common/tests/test_multithread.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import threading
import pyomo.common.unittest as unittest
from pyomo.common.multithread import *
diff --git a/pyomo/common/tests/test_numeric_types.py b/pyomo/common/tests/test_numeric_types.py
new file mode 100644
index 00000000000..b7ffb5fb255
--- /dev/null
+++ b/pyomo/common/tests/test_numeric_types.py
@@ -0,0 +1,219 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
+import pyomo.common.numeric_types as nt
+import pyomo.common.unittest as unittest
+
+from pyomo.common.dependencies import numpy, numpy_available
+from pyomo.core.expr import LinearExpression
+from pyomo.environ import Var
+
+_type_sets = (
+ 'native_types',
+ 'native_numeric_types',
+ 'native_logical_types',
+ 'native_integer_types',
+ 'native_complex_types',
+)
+
+
+class TestNativeTypes(unittest.TestCase):
+ def setUp(self):
+ bool(numpy_available)
+ for s in _type_sets:
+ setattr(self, s, set(getattr(nt, s)))
+ getattr(nt, s).clear()
+
+ def tearDown(self):
+ for s in _type_sets:
+ getattr(nt, s).clear()
+ getattr(nt, s).update(getattr(self, s))
+
+ def test_check_if_native_type(self):
+ self.assertEqual(nt.native_types, set())
+ self.assertEqual(nt.native_logical_types, set())
+ self.assertEqual(nt.native_numeric_types, set())
+ self.assertEqual(nt.native_integer_types, set())
+ self.assertEqual(nt.native_complex_types, set())
+
+ self.assertTrue(nt.check_if_native_type("a"))
+ self.assertIn(str, nt.native_types)
+ self.assertNotIn(str, nt.native_logical_types)
+ self.assertNotIn(str, nt.native_numeric_types)
+ self.assertNotIn(str, nt.native_integer_types)
+ self.assertNotIn(str, nt.native_complex_types)
+
+ self.assertTrue(nt.check_if_native_type(1))
+ self.assertIn(int, nt.native_types)
+ self.assertNotIn(int, nt.native_logical_types)
+ self.assertIn(int, nt.native_numeric_types)
+ self.assertIn(int, nt.native_integer_types)
+ self.assertNotIn(int, nt.native_complex_types)
+
+ self.assertTrue(nt.check_if_native_type(1.5))
+ self.assertIn(float, nt.native_types)
+ self.assertNotIn(float, nt.native_logical_types)
+ self.assertIn(float, nt.native_numeric_types)
+ self.assertNotIn(float, nt.native_integer_types)
+ self.assertNotIn(float, nt.native_complex_types)
+
+ self.assertTrue(nt.check_if_native_type(True))
+ self.assertIn(bool, nt.native_types)
+ self.assertIn(bool, nt.native_logical_types)
+ self.assertNotIn(bool, nt.native_numeric_types)
+ self.assertNotIn(bool, nt.native_integer_types)
+ self.assertNotIn(bool, nt.native_complex_types)
+
+ self.assertFalse(nt.check_if_native_type(slice(None, None, None)))
+ self.assertNotIn(slice, nt.native_types)
+ self.assertNotIn(slice, nt.native_logical_types)
+ self.assertNotIn(slice, nt.native_numeric_types)
+ self.assertNotIn(slice, nt.native_integer_types)
+ self.assertNotIn(slice, nt.native_complex_types)
+
+ def test_check_if_logical_type(self):
+ self.assertEqual(nt.native_types, set())
+ self.assertEqual(nt.native_logical_types, set())
+ self.assertEqual(nt.native_numeric_types, set())
+ self.assertEqual(nt.native_integer_types, set())
+ self.assertEqual(nt.native_complex_types, set())
+
+ self.assertFalse(nt.check_if_logical_type("a"))
+ self.assertNotIn(str, nt.native_types)
+ self.assertNotIn(str, nt.native_logical_types)
+ self.assertNotIn(str, nt.native_numeric_types)
+ self.assertNotIn(str, nt.native_integer_types)
+ self.assertNotIn(str, nt.native_complex_types)
+
+ self.assertFalse(nt.check_if_logical_type("a"))
+
+ self.assertTrue(nt.check_if_logical_type(True))
+ self.assertIn(bool, nt.native_types)
+ self.assertIn(bool, nt.native_logical_types)
+ self.assertNotIn(bool, nt.native_numeric_types)
+ self.assertNotIn(bool, nt.native_integer_types)
+ self.assertNotIn(bool, nt.native_complex_types)
+
+ self.assertTrue(nt.check_if_logical_type(True))
+
+ self.assertFalse(nt.check_if_logical_type(1))
+ self.assertNotIn(int, nt.native_types)
+ self.assertNotIn(int, nt.native_logical_types)
+ self.assertNotIn(int, nt.native_numeric_types)
+ self.assertNotIn(int, nt.native_integer_types)
+ self.assertNotIn(int, nt.native_complex_types)
+
+ if numpy_available:
+ self.assertTrue(nt.check_if_logical_type(numpy.bool_(1)))
+ self.assertIn(numpy.bool_, nt.native_types)
+ self.assertIn(numpy.bool_, nt.native_logical_types)
+ self.assertNotIn(numpy.bool_, nt.native_numeric_types)
+ self.assertNotIn(numpy.bool_, nt.native_integer_types)
+ self.assertNotIn(numpy.bool_, nt.native_complex_types)
+
+ def test_check_if_numeric_type(self):
+ self.assertEqual(nt.native_types, set())
+ self.assertEqual(nt.native_logical_types, set())
+ self.assertEqual(nt.native_numeric_types, set())
+ self.assertEqual(nt.native_integer_types, set())
+ self.assertEqual(nt.native_complex_types, set())
+
+ self.assertFalse(nt.check_if_numeric_type("a"))
+ self.assertFalse(nt.check_if_numeric_type("a"))
+ self.assertNotIn(str, nt.native_types)
+ self.assertNotIn(str, nt.native_logical_types)
+ self.assertNotIn(str, nt.native_numeric_types)
+ self.assertNotIn(str, nt.native_integer_types)
+ self.assertNotIn(str, nt.native_complex_types)
+
+ self.assertFalse(nt.check_if_numeric_type(True))
+ self.assertFalse(nt.check_if_numeric_type(True))
+ self.assertNotIn(bool, nt.native_types)
+ self.assertNotIn(bool, nt.native_logical_types)
+ self.assertNotIn(bool, nt.native_numeric_types)
+ self.assertNotIn(bool, nt.native_integer_types)
+ self.assertNotIn(bool, nt.native_complex_types)
+
+ self.assertTrue(nt.check_if_numeric_type(1))
+ self.assertTrue(nt.check_if_numeric_type(1))
+ self.assertIn(int, nt.native_types)
+ self.assertNotIn(int, nt.native_logical_types)
+ self.assertIn(int, nt.native_numeric_types)
+ self.assertIn(int, nt.native_integer_types)
+ self.assertNotIn(int, nt.native_complex_types)
+
+ self.assertTrue(nt.check_if_numeric_type(1.5))
+ self.assertTrue(nt.check_if_numeric_type(1.5))
+ self.assertIn(float, nt.native_types)
+ self.assertNotIn(float, nt.native_logical_types)
+ self.assertIn(float, nt.native_numeric_types)
+ self.assertNotIn(float, nt.native_integer_types)
+ self.assertNotIn(float, nt.native_complex_types)
+
+ self.assertFalse(nt.check_if_numeric_type(1j))
+ self.assertIn(complex, nt.native_types)
+ self.assertNotIn(complex, nt.native_logical_types)
+ self.assertNotIn(complex, nt.native_numeric_types)
+ self.assertNotIn(complex, nt.native_integer_types)
+ self.assertIn(complex, nt.native_complex_types)
+
+ v = Var()
+ v.construct()
+ self.assertFalse(nt.check_if_numeric_type(v))
+ self.assertNotIn(type(v), nt.native_types)
+ self.assertNotIn(type(v), nt.native_logical_types)
+ self.assertNotIn(type(v), nt.native_numeric_types)
+ self.assertNotIn(type(v), nt.native_integer_types)
+ self.assertNotIn(type(v), nt.native_complex_types)
+
+ e = LinearExpression([1])
+ self.assertFalse(nt.check_if_numeric_type(e))
+ self.assertNotIn(type(e), nt.native_types)
+ self.assertNotIn(type(e), nt.native_logical_types)
+ self.assertNotIn(type(e), nt.native_numeric_types)
+ self.assertNotIn(type(e), nt.native_integer_types)
+ self.assertNotIn(type(e), nt.native_complex_types)
+
+ if numpy_available:
+ self.assertFalse(nt.check_if_numeric_type(numpy.bool_(1)))
+ self.assertNotIn(numpy.bool_, nt.native_types)
+ self.assertNotIn(numpy.bool_, nt.native_logical_types)
+ self.assertNotIn(numpy.bool_, nt.native_numeric_types)
+ self.assertNotIn(numpy.bool_, nt.native_integer_types)
+ self.assertNotIn(numpy.bool_, nt.native_complex_types)
+
+ self.assertFalse(nt.check_if_numeric_type(numpy.array([1])))
+ self.assertNotIn(numpy.ndarray, nt.native_types)
+ self.assertNotIn(numpy.ndarray, nt.native_logical_types)
+ self.assertNotIn(numpy.ndarray, nt.native_numeric_types)
+ self.assertNotIn(numpy.ndarray, nt.native_integer_types)
+ self.assertNotIn(numpy.ndarray, nt.native_complex_types)
+
+ self.assertTrue(nt.check_if_numeric_type(numpy.float64(1)))
+ self.assertIn(numpy.float64, nt.native_types)
+ self.assertNotIn(numpy.float64, nt.native_logical_types)
+ self.assertIn(numpy.float64, nt.native_numeric_types)
+ self.assertNotIn(numpy.float64, nt.native_integer_types)
+ self.assertNotIn(numpy.float64, nt.native_complex_types)
+
+ self.assertTrue(nt.check_if_numeric_type(numpy.int64(1)))
+ self.assertIn(numpy.int64, nt.native_types)
+ self.assertNotIn(numpy.int64, nt.native_logical_types)
+ self.assertIn(numpy.int64, nt.native_numeric_types)
+ self.assertIn(numpy.int64, nt.native_integer_types)
+ self.assertNotIn(numpy.int64, nt.native_complex_types)
+
+ self.assertFalse(nt.check_if_numeric_type(numpy.complex128(1)))
+ self.assertIn(numpy.complex128, nt.native_types)
+ self.assertNotIn(numpy.complex128, nt.native_logical_types)
+ self.assertNotIn(numpy.complex128, nt.native_numeric_types)
+ self.assertNotIn(numpy.complex128, nt.native_integer_types)
+ self.assertIn(numpy.complex128, nt.native_complex_types)
diff --git a/pyomo/common/tests/test_orderedset.py b/pyomo/common/tests/test_orderedset.py
index d87bebc1e4a..8f944e66bd7 100644
--- a/pyomo/common/tests/test_orderedset.py
+++ b/pyomo/common/tests/test_orderedset.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_plugin.py b/pyomo/common/tests/test_plugin.py
index 86d136dd9d1..54431334d5b 100644
--- a/pyomo/common/tests/test_plugin.py
+++ b/pyomo/common/tests/test_plugin.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_sorting.py b/pyomo/common/tests/test_sorting.py
index 7a9fe5ac923..7fbefda6a19 100644
--- a/pyomo/common/tests/test_sorting.py
+++ b/pyomo/common/tests/test_sorting.py
@@ -2,7 +2,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_tee.py b/pyomo/common/tests/test_tee.py
index 666a431631f..a5c6ee894b2 100644
--- a/pyomo/common/tests/test_tee.py
+++ b/pyomo/common/tests/test_tee.py
@@ -2,7 +2,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_tempfile.py b/pyomo/common/tests/test_tempfile.py
index 5e75c55305a..c49aa8c6771 100644
--- a/pyomo/common/tests/test_tempfile.py
+++ b/pyomo/common/tests/test_tempfile.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_timing.py b/pyomo/common/tests/test_timing.py
index d885359e6c6..90f4cdcd034 100644
--- a/pyomo/common/tests/test_timing.py
+++ b/pyomo/common/tests/test_timing.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -35,7 +35,7 @@
Any,
TransformationFactory,
)
-from pyomo.core.base.var import _VarData
+from pyomo.core.base.var import VarData
class _pseudo_component(Var):
@@ -62,7 +62,7 @@ def test_raw_construction_timer(self):
)
v = Var()
v.construct()
- a = ConstructionTimer(_VarData(v))
+ a = ConstructionTimer(VarData(v))
self.assertRegex(
str(a),
r"ConstructionTimer object for Var ScalarVar\[NOTSET\]; "
@@ -107,7 +107,6 @@ def test_report_timing(self):
m.y = Var(Any, dense=False)
xfrm.apply_to(m)
result = out.getvalue().strip()
- self.maxDiff = None
for l, r in zip(result.splitlines(), ref.splitlines()):
self.assertRegex(str(l.strip()), str(r.strip()))
finally:
@@ -122,7 +121,6 @@ def test_report_timing(self):
m.y = Var(Any, dense=False)
xfrm.apply_to(m)
result = os.getvalue().strip()
- self.maxDiff = None
for l, r in zip(result.splitlines(), ref.splitlines()):
self.assertRegex(str(l.strip()), str(r.strip()))
finally:
@@ -135,7 +133,6 @@ def test_report_timing(self):
m.y = Var(Any, dense=False)
xfrm.apply_to(m)
result = os.getvalue().strip()
- self.maxDiff = None
for l, r in zip(result.splitlines(), ref.splitlines()):
self.assertRegex(str(l.strip()), str(r.strip()))
self.assertEqual(buf.getvalue().strip(), "")
@@ -172,7 +169,6 @@ def test_report_timing_context_manager(self):
xfrm.apply_to(m)
self.assertEqual(OUT.getvalue(), "")
result = OS.getvalue().strip()
- self.maxDiff = None
for l, r in zip_longest(result.splitlines(), ref.splitlines()):
self.assertRegex(str(l.strip()), str(r.strip()))
# Active reporting is False: the previous log should not have changed
diff --git a/pyomo/common/tests/test_typing.py b/pyomo/common/tests/test_typing.py
index 982462f8a8d..e65effe7f29 100644
--- a/pyomo/common/tests/test_typing.py
+++ b/pyomo/common/tests/test_typing.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/tests/test_unittest.py b/pyomo/common/tests/test_unittest.py
index e3779e6f86e..9344853b737 100644
--- a/pyomo/common/tests/test_unittest.py
+++ b/pyomo/common/tests/test_unittest.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/timing.py b/pyomo/common/timing.py
index b37570fa666..d502b38d12d 100644
--- a/pyomo/common/timing.py
+++ b/pyomo/common/timing.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/common/unittest.py b/pyomo/common/unittest.py
index 1ed26f72320..c78e003a07d 100644
--- a/pyomo/common/unittest.py
+++ b/pyomo/common/unittest.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -498,6 +498,10 @@ class TestCase(_unittest.TestCase):
__doc__ += _unittest.TestCase.__doc__
+ # By default, we always want to spend the time to create the full
+ # diff of the test reault and the baseline
+ maxDiff = None
+
def assertStructuredAlmostEqual(
self,
first,
@@ -631,7 +635,7 @@ def initialize_dependencies(self):
cls.package_modules = {}
packages_used = set(sum(list(cls.package_dependencies.values()), []))
for package_ in packages_used:
- pack, pack_avail = attempt_import(package_, defer_check=False)
+ pack, pack_avail = attempt_import(package_, defer_import=False)
cls.package_available[package_] = pack_avail
cls.package_modules[package_] = pack
@@ -779,6 +783,7 @@ def filter_fcn(self, line):
return False
def filter_file_contents(self, lines, abstol=None):
+ _numpy_scalar_re = re.compile(r'np.(int|float)\d+\(([^\)]+)\)')
filtered = []
deprecated = None
for line in lines:
@@ -803,6 +808,15 @@ def filter_file_contents(self, lines, abstol=None):
item_list = []
items = line.strip().split()
for i in items:
+ # Split up lists, dicts, and sets
+ while i and i[0] in '[{':
+ item_list.append(i[0])
+ i = i[1:]
+ tail = []
+ while i and i[-1] in ',:]}':
+ tail.append(i[-1])
+ i = i[:-1]
+
# A few substitutions to get tests passing on pypy3
if ".inf" in i:
i = i.replace(".inf", "inf")
@@ -810,9 +824,19 @@ def filter_file_contents(self, lines, abstol=None):
i = i.replace("null", "None")
try:
- item_list.append(float(i))
+ # Numpy 2.x changed the repr for scalars. Convert
+ # the new scalar reprs back to the original (which
+ # were indistinguishable from python floats/ints)
+ np_match = _numpy_scalar_re.match(i)
+ if np_match:
+ item_list.append(float(np_match.group(2)))
+ else:
+ item_list.append(float(i))
except:
item_list.append(i)
+ if tail:
+ tail.reverse()
+ item_list.extend(tail)
# We can get printed results objects where the baseline is
# exactly 0 (and omitted) and the test is slightly non-zero.
@@ -820,12 +844,13 @@ def filter_file_contents(self, lines, abstol=None):
# results objects and remote them if they are within
# tolerance of 0
if (
- len(item_list) == 2
- and item_list[0] == 'Value:'
- and type(item_list[1]) is float
- and abs(item_list[1]) < (abstol or 0)
- and len(filtered[-1]) == 1
- and filtered[-1][0][-1] == ':'
+ len(item_list) == 3
+ and item_list[0] == 'Value'
+ and item_list[1] == ':'
+ and type(item_list[2]) is float
+ and abs(item_list[2]) < (abstol or 0)
+ and len(filtered[-1]) == 2
+ and filtered[-1][1] == ':'
):
filtered.pop()
else:
diff --git a/pyomo/contrib/__init__.py b/pyomo/contrib/__init__.py
index e69de29bb2d..a4a626013c4 100644
--- a/pyomo/contrib/__init__.py
+++ b/pyomo/contrib/__init__.py
@@ -0,0 +1,10 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
diff --git a/pyomo/contrib/ampl_function_demo/__init__.py b/pyomo/contrib/ampl_function_demo/__init__.py
index e69de29bb2d..a4a626013c4 100644
--- a/pyomo/contrib/ampl_function_demo/__init__.py
+++ b/pyomo/contrib/ampl_function_demo/__init__.py
@@ -0,0 +1,10 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
diff --git a/pyomo/contrib/ampl_function_demo/build.py b/pyomo/contrib/ampl_function_demo/build.py
index cd35064ea4e..764a613b3d7 100644
--- a/pyomo/contrib/ampl_function_demo/build.py
+++ b/pyomo/contrib/ampl_function_demo/build.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/contrib/ampl_function_demo/plugins.py b/pyomo/contrib/ampl_function_demo/plugins.py
index 230d9c4b667..5a200174c43 100644
--- a/pyomo/contrib/ampl_function_demo/plugins.py
+++ b/pyomo/contrib/ampl_function_demo/plugins.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/contrib/ampl_function_demo/src/CMakeLists.txt b/pyomo/contrib/ampl_function_demo/src/CMakeLists.txt
index ce2c1a60f82..67efc13d3c8 100644
--- a/pyomo/contrib/ampl_function_demo/src/CMakeLists.txt
+++ b/pyomo/contrib/ampl_function_demo/src/CMakeLists.txt
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/contrib/ampl_function_demo/src/FindASL.cmake b/pyomo/contrib/ampl_function_demo/src/FindASL.cmake
index f413176f1cc..8bbc048fa6e 100644
--- a/pyomo/contrib/ampl_function_demo/src/FindASL.cmake
+++ b/pyomo/contrib/ampl_function_demo/src/FindASL.cmake
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/contrib/ampl_function_demo/src/functions.c b/pyomo/contrib/ampl_function_demo/src/functions.c
index f62148c995a..e87af745aea 100644
--- a/pyomo/contrib/ampl_function_demo/src/functions.c
+++ b/pyomo/contrib/ampl_function_demo/src/functions.c
@@ -1,6 +1,6 @@
/* ___________________________________________________________________________
* Pyomo: Python Optimization Modeling Objects
- * Copyright (c) 2008-2022
+ * Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
* Under the terms of Contract DE-NA0003525 with National Technology and
* Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/contrib/ampl_function_demo/tests/__init__.py b/pyomo/contrib/ampl_function_demo/tests/__init__.py
index e69de29bb2d..a4a626013c4 100644
--- a/pyomo/contrib/ampl_function_demo/tests/__init__.py
+++ b/pyomo/contrib/ampl_function_demo/tests/__init__.py
@@ -0,0 +1,10 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
diff --git a/pyomo/contrib/ampl_function_demo/tests/test_ampl_function_demo.py b/pyomo/contrib/ampl_function_demo/tests/test_ampl_function_demo.py
index af52c2def9f..39890494d55 100644
--- a/pyomo/contrib/ampl_function_demo/tests/test_ampl_function_demo.py
+++ b/pyomo/contrib/ampl_function_demo/tests/test_ampl_function_demo.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/contrib/appsi/__init__.py b/pyomo/contrib/appsi/__init__.py
index df3ba212448..2f06fc89e70 100644
--- a/pyomo/contrib/appsi/__init__.py
+++ b/pyomo/contrib/appsi/__init__.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
from . import base
from . import solvers
from . import writers
diff --git a/pyomo/contrib/appsi/base.py b/pyomo/contrib/appsi/base.py
index e6186eeedd2..6d2b5ccfcd4 100644
--- a/pyomo/contrib/appsi/base.py
+++ b/pyomo/contrib/appsi/base.py
@@ -1,3 +1,14 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+# rights in this software.
+# This software is distributed under the 3-clause BSD License.
+# ___________________________________________________________________________
+
import abc
import enum
from typing import (
@@ -10,12 +21,12 @@
Tuple,
MutableMapping,
)
-from pyomo.core.base.constraint import _GeneralConstraintData, Constraint
-from pyomo.core.base.sos import _SOSConstraintData, SOSConstraint
-from pyomo.core.base.var import _GeneralVarData, Var
-from pyomo.core.base.param import _ParamData, Param
-from pyomo.core.base.block import _BlockData, Block
-from pyomo.core.base.objective import _GeneralObjectiveData
+from pyomo.core.base.constraint import ConstraintData, Constraint
+from pyomo.core.base.sos import SOSConstraintData, SOSConstraint
+from pyomo.core.base.var import VarData, Var
+from pyomo.core.base.param import ParamData, Param
+from pyomo.core.base.block import BlockData, Block
+from pyomo.core.base.objective import ObjectiveData
from pyomo.common.collections import ComponentMap
from .utils.get_objective import get_objective
from .utils.collect_vars_and_named_exprs import collect_vars_and_named_exprs
@@ -168,9 +179,7 @@ def __init__(
class SolutionLoaderBase(abc.ABC):
- def load_vars(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> NoReturn:
+ def load_vars(self, vars_to_load: Optional[Sequence[VarData]] = None) -> NoReturn:
"""
Load the solution of the primal variables into the value attribute of the variables.
@@ -186,8 +195,8 @@ def load_vars(
@abc.abstractmethod
def get_primals(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> Mapping[_GeneralVarData, float]:
+ self, vars_to_load: Optional[Sequence[VarData]] = None
+ ) -> Mapping[VarData, float]:
"""
Returns a ComponentMap mapping variable to var value.
@@ -205,8 +214,8 @@ def get_primals(
pass
def get_duals(
- self, cons_to_load: Optional[Sequence[_GeneralConstraintData]] = None
- ) -> Dict[_GeneralConstraintData, float]:
+ self, cons_to_load: Optional[Sequence[ConstraintData]] = None
+ ) -> Dict[ConstraintData, float]:
"""
Returns a dictionary mapping constraint to dual value.
@@ -224,8 +233,8 @@ def get_duals(
raise NotImplementedError(f'{type(self)} does not support the get_duals method')
def get_slacks(
- self, cons_to_load: Optional[Sequence[_GeneralConstraintData]] = None
- ) -> Dict[_GeneralConstraintData, float]:
+ self, cons_to_load: Optional[Sequence[ConstraintData]] = None
+ ) -> Dict[ConstraintData, float]:
"""
Returns a dictionary mapping constraint to slack.
@@ -245,8 +254,8 @@ def get_slacks(
)
def get_reduced_costs(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> Mapping[_GeneralVarData, float]:
+ self, vars_to_load: Optional[Sequence[VarData]] = None
+ ) -> Mapping[VarData, float]:
"""
Returns a ComponentMap mapping variable to reduced cost.
@@ -292,8 +301,8 @@ def __init__(
self._reduced_costs = reduced_costs
def get_primals(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> Mapping[_GeneralVarData, float]:
+ self, vars_to_load: Optional[Sequence[VarData]] = None
+ ) -> Mapping[VarData, float]:
if self._primals is None:
raise RuntimeError(
'Solution loader does not currently have a valid solution. Please '
@@ -308,8 +317,8 @@ def get_primals(
return primals
def get_duals(
- self, cons_to_load: Optional[Sequence[_GeneralConstraintData]] = None
- ) -> Dict[_GeneralConstraintData, float]:
+ self, cons_to_load: Optional[Sequence[ConstraintData]] = None
+ ) -> Dict[ConstraintData, float]:
if self._duals is None:
raise RuntimeError(
'Solution loader does not currently have valid duals. Please '
@@ -325,8 +334,8 @@ def get_duals(
return duals
def get_slacks(
- self, cons_to_load: Optional[Sequence[_GeneralConstraintData]] = None
- ) -> Dict[_GeneralConstraintData, float]:
+ self, cons_to_load: Optional[Sequence[ConstraintData]] = None
+ ) -> Dict[ConstraintData, float]:
if self._slacks is None:
raise RuntimeError(
'Solution loader does not currently have valid slacks. Please '
@@ -342,8 +351,8 @@ def get_slacks(
return slacks
def get_reduced_costs(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> Mapping[_GeneralVarData, float]:
+ self, vars_to_load: Optional[Sequence[VarData]] = None
+ ) -> Mapping[VarData, float]:
if self._reduced_costs is None:
raise RuntimeError(
'Solution loader does not currently have valid reduced costs. Please '
@@ -610,13 +619,13 @@ def __str__(self):
return self.name
@abc.abstractmethod
- def solve(self, model: _BlockData, timer: HierarchicalTimer = None) -> Results:
+ def solve(self, model: BlockData, timer: HierarchicalTimer = None) -> Results:
"""
Solve a Pyomo model.
Parameters
----------
- model: _BlockData
+ model: BlockData
The Pyomo model to be solved
timer: HierarchicalTimer
An option timer for reporting timing
@@ -697,9 +706,7 @@ class PersistentSolver(Solver):
def is_persistent(self):
return True
- def load_vars(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> NoReturn:
+ def load_vars(self, vars_to_load: Optional[Sequence[VarData]] = None) -> NoReturn:
"""
Load the solution of the primal variables into the value attribute of the variables.
@@ -715,13 +722,13 @@ def load_vars(
@abc.abstractmethod
def get_primals(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> Mapping[_GeneralVarData, float]:
+ self, vars_to_load: Optional[Sequence[VarData]] = None
+ ) -> Mapping[VarData, float]:
pass
def get_duals(
- self, cons_to_load: Optional[Sequence[_GeneralConstraintData]] = None
- ) -> Dict[_GeneralConstraintData, float]:
+ self, cons_to_load: Optional[Sequence[ConstraintData]] = None
+ ) -> Dict[ConstraintData, float]:
"""
Declare sign convention in docstring here.
@@ -741,8 +748,8 @@ def get_duals(
)
def get_slacks(
- self, cons_to_load: Optional[Sequence[_GeneralConstraintData]] = None
- ) -> Dict[_GeneralConstraintData, float]:
+ self, cons_to_load: Optional[Sequence[ConstraintData]] = None
+ ) -> Dict[ConstraintData, float]:
"""
Parameters
----------
@@ -760,8 +767,8 @@ def get_slacks(
)
def get_reduced_costs(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> Mapping[_GeneralVarData, float]:
+ self, vars_to_load: Optional[Sequence[VarData]] = None
+ ) -> Mapping[VarData, float]:
"""
Parameters
----------
@@ -788,43 +795,43 @@ def set_instance(self, model):
pass
@abc.abstractmethod
- def add_variables(self, variables: List[_GeneralVarData]):
+ def add_variables(self, variables: List[VarData]):
pass
@abc.abstractmethod
- def add_params(self, params: List[_ParamData]):
+ def add_params(self, params: List[ParamData]):
pass
@abc.abstractmethod
- def add_constraints(self, cons: List[_GeneralConstraintData]):
+ def add_constraints(self, cons: List[ConstraintData]):
pass
@abc.abstractmethod
- def add_block(self, block: _BlockData):
+ def add_block(self, block: BlockData):
pass
@abc.abstractmethod
- def remove_variables(self, variables: List[_GeneralVarData]):
+ def remove_variables(self, variables: List[VarData]):
pass
@abc.abstractmethod
- def remove_params(self, params: List[_ParamData]):
+ def remove_params(self, params: List[ParamData]):
pass
@abc.abstractmethod
- def remove_constraints(self, cons: List[_GeneralConstraintData]):
+ def remove_constraints(self, cons: List[ConstraintData]):
pass
@abc.abstractmethod
- def remove_block(self, block: _BlockData):
+ def remove_block(self, block: BlockData):
pass
@abc.abstractmethod
- def set_objective(self, obj: _GeneralObjectiveData):
+ def set_objective(self, obj: ObjectiveData):
pass
@abc.abstractmethod
- def update_variables(self, variables: List[_GeneralVarData]):
+ def update_variables(self, variables: List[VarData]):
pass
@abc.abstractmethod
@@ -846,20 +853,20 @@ def get_primals(self, vars_to_load=None):
return self._solver.get_primals(vars_to_load=vars_to_load)
def get_duals(
- self, cons_to_load: Optional[Sequence[_GeneralConstraintData]] = None
- ) -> Dict[_GeneralConstraintData, float]:
+ self, cons_to_load: Optional[Sequence[ConstraintData]] = None
+ ) -> Dict[ConstraintData, float]:
self._assert_solution_still_valid()
return self._solver.get_duals(cons_to_load=cons_to_load)
def get_slacks(
- self, cons_to_load: Optional[Sequence[_GeneralConstraintData]] = None
- ) -> Dict[_GeneralConstraintData, float]:
+ self, cons_to_load: Optional[Sequence[ConstraintData]] = None
+ ) -> Dict[ConstraintData, float]:
self._assert_solution_still_valid()
return self._solver.get_slacks(cons_to_load=cons_to_load)
def get_reduced_costs(
- self, vars_to_load: Optional[Sequence[_GeneralVarData]] = None
- ) -> Mapping[_GeneralVarData, float]:
+ self, vars_to_load: Optional[Sequence[VarData]] = None
+ ) -> Mapping[VarData, float]:
self._assert_solution_still_valid()
return self._solver.get_reduced_costs(vars_to_load=vars_to_load)
@@ -943,10 +950,10 @@ def set_instance(self, model):
self.set_objective(None)
@abc.abstractmethod
- def _add_variables(self, variables: List[_GeneralVarData]):
+ def _add_variables(self, variables: List[VarData]):
pass
- def add_variables(self, variables: List[_GeneralVarData]):
+ def add_variables(self, variables: List[VarData]):
for v in variables:
if id(v) in self._referenced_variables:
raise ValueError(
@@ -964,19 +971,19 @@ def add_variables(self, variables: List[_GeneralVarData]):
self._add_variables(variables)
@abc.abstractmethod
- def _add_params(self, params: List[_ParamData]):
+ def _add_params(self, params: List[ParamData]):
pass
- def add_params(self, params: List[_ParamData]):
+ def add_params(self, params: List[ParamData]):
for p in params:
self._params[id(p)] = p
self._add_params(params)
@abc.abstractmethod
- def _add_constraints(self, cons: List[_GeneralConstraintData]):
+ def _add_constraints(self, cons: List[ConstraintData]):
pass
- def _check_for_new_vars(self, variables: List[_GeneralVarData]):
+ def _check_for_new_vars(self, variables: List[VarData]):
new_vars = dict()
for v in variables:
v_id = id(v)
@@ -984,7 +991,7 @@ def _check_for_new_vars(self, variables: List[_GeneralVarData]):
new_vars[v_id] = v
self.add_variables(list(new_vars.values()))
- def _check_to_remove_vars(self, variables: List[_GeneralVarData]):
+ def _check_to_remove_vars(self, variables: List[VarData]):
vars_to_remove = dict()
for v in variables:
v_id = id(v)
@@ -993,7 +1000,7 @@ def _check_to_remove_vars(self, variables: List[_GeneralVarData]):
vars_to_remove[v_id] = v
self.remove_variables(list(vars_to_remove.values()))
- def add_constraints(self, cons: List[_GeneralConstraintData]):
+ def add_constraints(self, cons: List[ConstraintData]):
all_fixed_vars = dict()
for con in cons:
if con in self._named_expressions:
@@ -1023,10 +1030,10 @@ def add_constraints(self, cons: List[_GeneralConstraintData]):
v.fix()
@abc.abstractmethod
- def _add_sos_constraints(self, cons: List[_SOSConstraintData]):
+ def _add_sos_constraints(self, cons: List[SOSConstraintData]):
pass
- def add_sos_constraints(self, cons: List[_SOSConstraintData]):
+ def add_sos_constraints(self, cons: List[SOSConstraintData]):
for con in cons:
if con in self._vars_referenced_by_con:
raise ValueError(
@@ -1043,10 +1050,10 @@ def add_sos_constraints(self, cons: List[_SOSConstraintData]):
self._add_sos_constraints(cons)
@abc.abstractmethod
- def _set_objective(self, obj: _GeneralObjectiveData):
+ def _set_objective(self, obj: ObjectiveData):
pass
- def set_objective(self, obj: _GeneralObjectiveData):
+ def set_objective(self, obj: ObjectiveData):
if self._objective is not None:
for v in self._vars_referenced_by_obj:
self._referenced_variables[id(v)][2] = None
@@ -1121,10 +1128,10 @@ def add_block(self, block):
self.set_objective(obj)
@abc.abstractmethod
- def _remove_constraints(self, cons: List[_GeneralConstraintData]):
+ def _remove_constraints(self, cons: List[ConstraintData]):
pass
- def remove_constraints(self, cons: List[_GeneralConstraintData]):
+ def remove_constraints(self, cons: List[ConstraintData]):
self._remove_constraints(cons)
for con in cons:
if con not in self._named_expressions:
@@ -1143,10 +1150,10 @@ def remove_constraints(self, cons: List[_GeneralConstraintData]):
del self._vars_referenced_by_con[con]
@abc.abstractmethod
- def _remove_sos_constraints(self, cons: List[_SOSConstraintData]):
+ def _remove_sos_constraints(self, cons: List[SOSConstraintData]):
pass
- def remove_sos_constraints(self, cons: List[_SOSConstraintData]):
+ def remove_sos_constraints(self, cons: List[SOSConstraintData]):
self._remove_sos_constraints(cons)
for con in cons:
if con not in self._vars_referenced_by_con:
@@ -1163,10 +1170,10 @@ def remove_sos_constraints(self, cons: List[_SOSConstraintData]):
del self._vars_referenced_by_con[con]
@abc.abstractmethod
- def _remove_variables(self, variables: List[_GeneralVarData]):
+ def _remove_variables(self, variables: List[VarData]):
pass
- def remove_variables(self, variables: List[_GeneralVarData]):
+ def remove_variables(self, variables: List[VarData]):
self._remove_variables(variables)
for v in variables:
v_id = id(v)
@@ -1187,10 +1194,10 @@ def remove_variables(self, variables: List[_GeneralVarData]):
del self._vars[v_id]
@abc.abstractmethod
- def _remove_params(self, params: List[_ParamData]):
+ def _remove_params(self, params: List[ParamData]):
pass
- def remove_params(self, params: List[_ParamData]):
+ def remove_params(self, params: List[ParamData]):
self._remove_params(params)
for p in params:
del self._params[id(p)]
@@ -1235,10 +1242,10 @@ def remove_block(self, block):
)
@abc.abstractmethod
- def _update_variables(self, variables: List[_GeneralVarData]):
+ def _update_variables(self, variables: List[VarData]):
pass
- def update_variables(self, variables: List[_GeneralVarData]):
+ def update_variables(self, variables: List[VarData]):
for v in variables:
self._vars[id(v)] = (
v,
@@ -1323,12 +1330,12 @@ def update(self, timer: HierarchicalTimer = None):
for c in self._vars_referenced_by_con.keys():
if c not in current_cons_dict and c not in current_sos_dict:
if (c.ctype is Constraint) or (
- c.ctype is None and isinstance(c, _GeneralConstraintData)
+ c.ctype is None and isinstance(c, ConstraintData)
):
old_cons.append(c)
else:
assert (c.ctype is SOSConstraint) or (
- c.ctype is None and isinstance(c, _SOSConstraintData)
+ c.ctype is None and isinstance(c, SOSConstraintData)
)
old_sos.append(c)
self.remove_constraints(old_cons)
@@ -1518,7 +1525,7 @@ def update(self, timer: HierarchicalTimer = None):
class LegacySolverInterface(object):
def solve(
self,
- model: _BlockData,
+ model: BlockData,
tee: bool = False,
load_solutions: bool = True,
logfile: Optional[str] = None,
@@ -1654,7 +1661,7 @@ def license_is_valid(self) -> bool:
@property
def options(self):
- for solver_name in ['gurobi', 'ipopt', 'cplex', 'cbc', 'highs']:
+ for solver_name in ['gurobi', 'ipopt', 'cplex', 'cbc', 'highs', 'maingo']:
if hasattr(self, solver_name + '_options'):
return getattr(self, solver_name + '_options')
raise NotImplementedError('Could not find the correct options')
@@ -1662,7 +1669,7 @@ def options(self):
@options.setter
def options(self, val):
found = False
- for solver_name in ['gurobi', 'ipopt', 'cplex', 'cbc', 'highs']:
+ for solver_name in ['gurobi', 'ipopt', 'cplex', 'cbc', 'highs', 'maingo']:
if hasattr(self, solver_name + '_options'):
setattr(self, solver_name + '_options', val)
found = True
@@ -1685,7 +1692,7 @@ def decorator(cls):
class LegacySolver(LegacySolverInterface, cls):
pass
- LegacySolverFactory.register(name, doc)(LegacySolver)
+ LegacySolverFactory.register('appsi_' + name, doc)(LegacySolver)
return cls
diff --git a/pyomo/contrib/appsi/build.py b/pyomo/contrib/appsi/build.py
index 2c8d02dd3ac..38f8cb713ca 100644
--- a/pyomo/contrib/appsi/build.py
+++ b/pyomo/contrib/appsi/build.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -16,15 +16,6 @@
import tempfile
-def handleReadonly(function, path, excinfo):
- excvalue = excinfo[1]
- if excvalue.errno == errno.EACCES:
- os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777
- function(path)
- else:
- raise
-
-
def get_appsi_extension(in_setup=False, appsi_root=None):
from pybind11.setup_helpers import Pybind11Extension
@@ -66,6 +57,7 @@ def build_appsi(args=[]):
from setuptools import Distribution
from pybind11.setup_helpers import build_ext
import pybind11.setup_helpers
+ from pyomo.common.cmake_builder import handleReadonly
from pyomo.common.envvar import PYOMO_CONFIG_DIR
from pyomo.common.fileutils import this_file_dir
diff --git a/pyomo/contrib/appsi/cmodel/__init__.py b/pyomo/contrib/appsi/cmodel/__init__.py
index 9c276b518de..cc2aec28241 100644
--- a/pyomo/contrib/appsi/cmodel/__init__.py
+++ b/pyomo/contrib/appsi/cmodel/__init__.py
@@ -1,7 +1,7 @@
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
-# Copyright (c) 2008-2022
+# Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
diff --git a/pyomo/contrib/appsi/cmodel/src/cmodel_bindings.cpp b/pyomo/contrib/appsi/cmodel/src/cmodel_bindings.cpp
index db9d3112069..5a838ffd786 100644
--- a/pyomo/contrib/appsi/cmodel/src/cmodel_bindings.cpp
+++ b/pyomo/contrib/appsi/cmodel/src/cmodel_bindings.cpp
@@ -1,7 +1,7 @@
/**___________________________________________________________________________
*
* Pyomo: Python Optimization Modeling Objects
- * Copyright (c) 2008-2022
+ * Copyright (c) 2008-2024
# National Technology and Engineering Solutions of Sandia, LLC
* Under the terms of Contract DE-NA0003525 with National Technology and
* Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
@@ -63,7 +63,8 @@ PYBIND11_MODULE(appsi_cmodel, m) {
m.def("appsi_exprs_from_pyomo_exprs", &appsi_exprs_from_pyomo_exprs);
m.def("appsi_expr_from_pyomo_expr", &appsi_expr_from_pyomo_expr);
m.def("prep_for_repn", &prep_for_repn);
- py::class_(m, "PyomoExprTypes").def(py::init<>());
+ py::class_(m, "PyomoExprTypes", py::module_local())
+ .def(py::init<>());
py::class_>(m, "Node")
.def("is_variable_type", &Node::is_variable_type)
.def("is_param_type", &Node::is_param_type)
@@ -165,7 +166,7 @@ PYBIND11_MODULE(appsi_cmodel, m) {
.def(py::init<>())
.def("write", &LPWriter::write)
.def("get_solve_cons", &LPWriter::get_solve_cons);
- py::enum_(m, "ExprType")
+ py::enum_(m, "ExprType", py::module_local())
.value("py_float", ExprType::py_float)
.value("var", ExprType::var)
.value("param", ExprType::param)
diff --git a/pyomo/contrib/appsi/cmodel/src/common.cpp b/pyomo/contrib/appsi/cmodel/src/common.cpp
index 255a0a3a70f..6f8002cb50e 100644
--- a/pyomo/contrib/appsi/cmodel/src/common.cpp
+++ b/pyomo/contrib/appsi/cmodel/src/common.cpp
@@ -1,3 +1,15 @@
+/**___________________________________________________________________________
+ *
+ * Pyomo: Python Optimization Modeling Objects
+ * Copyright (c) 2008-2024
+ * National Technology and Engineering Solutions of Sandia, LLC
+ * Under the terms of Contract DE-NA0003525 with National Technology and
+ * Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+ * rights in this software.
+ * This software is distributed under the 3-clause BSD License.
+ * ___________________________________________________________________________
+**/
+
#include "common.hpp"
double inf;
diff --git a/pyomo/contrib/appsi/cmodel/src/common.hpp b/pyomo/contrib/appsi/cmodel/src/common.hpp
index 36afd549116..9edc9571a4d 100644
--- a/pyomo/contrib/appsi/cmodel/src/common.hpp
+++ b/pyomo/contrib/appsi/cmodel/src/common.hpp
@@ -1,3 +1,15 @@
+/**___________________________________________________________________________
+ *
+ * Pyomo: Python Optimization Modeling Objects
+ * Copyright (c) 2008-2024
+ * National Technology and Engineering Solutions of Sandia, LLC
+ * Under the terms of Contract DE-NA0003525 with National Technology and
+ * Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+ * rights in this software.
+ * This software is distributed under the 3-clause BSD License.
+ * ___________________________________________________________________________
+**/
+
#include
#include
diff --git a/pyomo/contrib/appsi/cmodel/src/expression.cpp b/pyomo/contrib/appsi/cmodel/src/expression.cpp
index 1923d3a1894..a49d6f2e499 100644
--- a/pyomo/contrib/appsi/cmodel/src/expression.cpp
+++ b/pyomo/contrib/appsi/cmodel/src/expression.cpp
@@ -1,1970 +1,1986 @@
-#include "expression.hpp"
-
-bool Leaf::is_leaf() { return true; }
-
-bool Var::is_variable_type() { return true; }
-
-bool Param::is_param_type() { return true; }
-
-bool Constant::is_constant_type() { return true; }
-
-bool Expression::is_expression_type() { return true; }
-
-double Leaf::evaluate() { return value; }
-
-double Var::get_lb() {
- if (fixed)
- return value;
- else
- return std::max(lb->evaluate(), domain_lb);
-}
-
-double Var::get_ub() {
- if (fixed)
- return value;
- else
- return std::min(ub->evaluate(), domain_ub);
-}
-
-Domain Var::get_domain() { return domain; }
-
-bool Operator::is_operator_type() { return true; }
-
-std::vector> Expression::get_operators() {
- std::vector> res(n_operators);
- for (unsigned int i = 0; i < n_operators; ++i) {
- res[i] = operators[i];
- }
- return res;
-}
-
-double Leaf::get_value_from_array(double *val_array) { return value; }
-
-double Expression::get_value_from_array(double *val_array) {
- return val_array[n_operators - 1];
-}
-
-double Operator::get_value_from_array(double *val_array) {
- return val_array[index];
-}
-
-void MultiplyOperator::evaluate(double *values) {
- values[index] = operand1->get_value_from_array(values) *
- operand2->get_value_from_array(values);
-}
-
-void ExternalOperator::evaluate(double *values) {
- // It would be nice to implement this, but it will take some more work.
- // This would require dynamic linking to the external function.
- throw std::runtime_error("cannot evaluate ExternalOperator yet");
-}
-
-void LinearOperator::evaluate(double *values) {
- values[index] = constant->evaluate();
- for (unsigned int i = 0; i < nterms; ++i) {
- values[index] += coefficients[i]->evaluate() * variables[i]->evaluate();
- }
-}
-
-void SumOperator::evaluate(double *values) {
- values[index] = 0.0;
- for (unsigned int i = 0; i < nargs; ++i) {
- values[index] += operands[i]->get_value_from_array(values);
- }
-}
-
-void DivideOperator::evaluate(double *values) {
- values[index] = operand1->get_value_from_array(values) /
- operand2->get_value_from_array(values);
-}
-
-void PowerOperator::evaluate(double *values) {
- values[index] = std::pow(operand1->get_value_from_array(values),
- operand2->get_value_from_array(values));
-}
-
-void NegationOperator::evaluate(double *values) {
- values[index] = -operand->get_value_from_array(values);
-}
-
-void ExpOperator::evaluate(double *values) {
- values[index] = std::exp(operand->get_value_from_array(values));
-}
-
-void LogOperator::evaluate(double *values) {
- values[index] = std::log(operand->get_value_from_array(values));
-}
-
-void AbsOperator::evaluate(double *values) {
- values[index] = std::fabs(operand->get_value_from_array(values));
-}
-
-void SqrtOperator::evaluate(double *values) {
- values[index] = std::pow(operand->get_value_from_array(values), 0.5);
-}
-
-void Log10Operator::evaluate(double *values) {
- values[index] = std::log10(operand->get_value_from_array(values));
-}
-
-void SinOperator::evaluate(double *values) {
- values[index] = std::sin(operand->get_value_from_array(values));
-}
-
-void CosOperator::evaluate(double *values) {
- values[index] = std::cos(operand->get_value_from_array(values));
-}
-
-void TanOperator::evaluate(double *values) {
- values[index] = std::tan(operand->get_value_from_array(values));
-}
-
-void AsinOperator::evaluate(double *values) {
- values[index] = std::asin(operand->get_value_from_array(values));
-}
-
-void AcosOperator::evaluate(double *values) {
- values[index] = std::acos(operand->get_value_from_array(values));
-}
-
-void AtanOperator::evaluate(double *values) {
- values[index] = std::atan(operand->get_value_from_array(values));
-}
-
-double Expression::evaluate() {
- double *values = new double[n_operators];
- for (unsigned int i = 0; i < n_operators; ++i) {
- operators[i]->index = i;
- operators[i]->evaluate(values);
- }
- double res = get_value_from_array(values);
- delete[] values;
- return res;
-}
-
-void UnaryOperator::identify_variables(
- std::set> &var_set,
- std::shared_ptr>> var_vec) {
- if (operand->is_variable_type()) {
- if (var_set.count(operand) == 0) {
- var_vec->push_back(std::dynamic_pointer_cast(operand));
- var_set.insert(operand);
- }
- }
-}
-
-void BinaryOperator::identify_variables(
- std::set> &var_set,
- std::shared_ptr>> var_vec) {
- if (operand1->is_variable_type()) {
- if (var_set.count(operand1) == 0) {
- var_vec->push_back(std::dynamic_pointer_cast(operand1));
- var_set.insert(operand1);
- }
- }
- if (operand2->is_variable_type()) {
- if (var_set.count(operand2) == 0) {
- var_vec->push_back(std::dynamic_pointer_cast(operand2));
- var_set.insert(operand2);
- }
- }
-}
-
-void ExternalOperator::identify_variables(
- std::set> &var_set,
- std::shared_ptr>> var_vec) {
- for (unsigned int i = 0; i < nargs; ++i) {
- if (operands[i]->is_variable_type()) {
- if (var_set.count(operands[i]) == 0) {
- var_vec->push_back(std::dynamic_pointer_cast(operands[i]));
- var_set.insert(operands[i]);
- }
- }
- }
-}
-
-void LinearOperator::identify_variables(
- std::set> &var_set,
- std::shared_ptr>> var_vec) {
- for (unsigned int i = 0; i < nterms; ++i) {
- if (var_set.count(variables[i]) == 0) {
- var_vec->push_back(std::dynamic_pointer_cast(variables[i]));
- var_set.insert(variables[i]);
- }
- }
-}
-
-void SumOperator::identify_variables(
- std::set> &var_set,
- std::shared_ptr>> var_vec) {
- for (unsigned int i = 0; i < nargs; ++i) {
- if (operands[i]->is_variable_type()) {
- if (var_set.count(operands[i]) == 0) {
- var_vec->push_back(std::dynamic_pointer_cast(operands[i]));
- var_set.insert(operands[i]);
- }
- }
- }
-}
-
-std::shared_ptr>>
-Expression::identify_variables() {
- std::set> var_set;
- std::shared_ptr>> res =
- std::make_shared>>(var_set.size());
- for (unsigned int i = 0; i < n_operators; ++i) {
- operators[i]->identify_variables(var_set, res);
- }
- return res;
-}
-
-std::shared_ptr>> Var::identify_variables() {
- std::shared_ptr>> res =
- std::make_shared>>();
- res->push_back(shared_from_this());
- return res;
-}
-
-std::shared_ptr>>
-Constant::identify_variables() {
- std::shared_ptr>> res =
- std::make_shared>>();
- return res;
-}
-
-std::shared_ptr>> Param::identify_variables() {
- std::shared_ptr>> res =
- std::make_shared>>();
- return res;
-}
-
-std::shared_ptr>>
-Expression::identify_external_operators() {
- std::set> external_set;
- for (unsigned int i = 0; i < n_operators; ++i) {
- if (operators[i]->is_external_operator()) {
- external_set.insert(operators[i]);
- }
- }
- std::shared_ptr>> res =
- std::make_shared>>(
- external_set.size());
- int ndx = 0;
- for (std::shared_ptr n : external_set) {
- (*res)[ndx] = std::dynamic_pointer_cast(n);
- ndx += 1;
- }
- return res;
-}
-
-std::shared_ptr>>
-Var::identify_external_operators() {
- std::shared_ptr>> res =
- std::make_shared>>();
- return res;
-}
-
-std::shared_ptr>>
-Constant::identify_external_operators() {
- std::shared_ptr>> res =
- std::make_shared>>();
- return res;
-}
-
-std::shared_ptr>>
-Param::identify_external_operators() {
- std::shared_ptr>> res =
- std::make_shared>>();
- return res;
-}
-
-int Var::get_degree_from_array(int *degree_array) { return 1; }
-
-int Param::get_degree_from_array(int *degree_array) { return 0; }
-
-int Constant::get_degree_from_array(int *degree_array) { return 0; }
-
-int Expression::get_degree_from_array(int *degree_array) {
- return degree_array[n_operators - 1];
-}
-
-int Operator::get_degree_from_array(int *degree_array) {
- return degree_array[index];
-}
-
-void LinearOperator::propagate_degree_forward(int *degrees, double *values) {
- degrees[index] = 1;
-}
-
-void SumOperator::propagate_degree_forward(int *degrees, double *values) {
- int deg = 0;
- int _deg;
- for (unsigned int i = 0; i < nargs; ++i) {
- _deg = operands[i]->get_degree_from_array(degrees);
- if (_deg > deg) {
- deg = _deg;
- }
- }
- degrees[index] = deg;
-}
-
-void MultiplyOperator::propagate_degree_forward(int *degrees, double *values) {
- degrees[index] = operand1->get_degree_from_array(degrees) +
- operand2->get_degree_from_array(degrees);
-}
-
-void ExternalOperator::propagate_degree_forward(int *degrees, double *values) {
- // External functions are always considered nonlinear
- // Anything larger than 2 is nonlinear
- degrees[index] = 3;
-}
-
-void DivideOperator::propagate_degree_forward(int *degrees, double *values) {
- // anything larger than 2 is nonlinear
- degrees[index] = std::max(operand1->get_degree_from_array(degrees),
- 3 * (operand2->get_degree_from_array(degrees)));
-}
-
-void PowerOperator::propagate_degree_forward(int *degrees, double *values) {
- if (operand2->get_degree_from_array(degrees) != 0) {
- degrees[index] = 3;
- } else {
- double val2 = operand2->get_value_from_array(values);
- double intpart;
- if (std::modf(val2, &intpart) == 0.0) {
- degrees[index] = operand1->get_degree_from_array(degrees) * (int)val2;
- } else {
- degrees[index] = 3;
- }
- }
-}
-
-void NegationOperator::propagate_degree_forward(int *degrees, double *values) {
- degrees[index] = operand->get_degree_from_array(degrees);
-}
-
-void UnaryOperator::propagate_degree_forward(int *degrees, double *values) {
- if (operand->get_degree_from_array(degrees) == 0) {
- degrees[index] = 0;
- } else {
- degrees[index] = 3;
- }
-}
-
-std::string Var::__str__() { return name; }
-
-std::string Param::__str__() { return name; }
-
-std::string Constant::__str__() { return std::to_string(value); }
-
-std::string Expression::__str__() {
- std::string *string_array = new std::string[n_operators];
- std::shared_ptr oper;
- for (unsigned int i = 0; i < n_operators; ++i) {
- oper = operators[i];
- oper->index = i;
- oper->print(string_array);
- }
- std::string res = string_array[n_operators - 1];
- delete[] string_array;
- return res;
-}
-
-std::string Leaf::get_string_from_array(std::string *string_array) {
- return __str__();
-}
-
-std::string Expression::get_string_from_array(std::string *string_array) {
- return string_array[n_operators - 1];
-}
-
-std::string Operator::get_string_from_array(std::string *string_array) {
- return string_array[index];
-}
-
-void MultiplyOperator::print(std::string *string_array) {
- string_array[index] =
- ("(" + operand1->get_string_from_array(string_array) + "*" +
- operand2->get_string_from_array(string_array) + ")");
-}
-
-void ExternalOperator::print(std::string *string_array) {
- std::string res = function_name + "(";
- for (unsigned int i = 0; i < (nargs - 1); ++i) {
- res += operands[i]->get_string_from_array(string_array);
- res += ", ";
- }
- res += operands[nargs - 1]->get_string_from_array(string_array);
- res += ")";
- string_array[index] = res;
-}
-
-void DivideOperator::print(std::string *string_array) {
- string_array[index] =
- ("(" + operand1->get_string_from_array(string_array) + "/" +
- operand2->get_string_from_array(string_array) + ")");
-}
-
-void PowerOperator::print(std::string *string_array) {
- string_array[index] =
- ("(" + operand1->get_string_from_array(string_array) + "**" +
- operand2->get_string_from_array(string_array) + ")");
-}
-
-void NegationOperator::print(std::string *string_array) {
- string_array[index] =
- ("(-" + operand->get_string_from_array(string_array) + ")");
-}
-
-void ExpOperator::print(std::string *string_array) {
- string_array[index] =
- ("exp(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void LogOperator::print(std::string *string_array) {
- string_array[index] =
- ("log(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void AbsOperator::print(std::string *string_array) {
- string_array[index] =
- ("abs(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void SqrtOperator::print(std::string *string_array) {
- string_array[index] =
- ("sqrt(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void Log10Operator::print(std::string *string_array) {
- string_array[index] =
- ("log10(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void SinOperator::print(std::string *string_array) {
- string_array[index] =
- ("sin(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void CosOperator::print(std::string *string_array) {
- string_array[index] =
- ("cos(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void TanOperator::print(std::string *string_array) {
- string_array[index] =
- ("tan(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void AsinOperator::print(std::string *string_array) {
- string_array[index] =
- ("asin(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void AcosOperator::print(std::string *string_array) {
- string_array[index] =
- ("acos(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void AtanOperator::print(std::string *string_array) {
- string_array[index] =
- ("atan(" + operand->get_string_from_array(string_array) + ")");
-}
-
-void LinearOperator::print(std::string *string_array) {
- std::string res = "(" + constant->__str__();
- for (unsigned int i = 0; i < nterms; ++i) {
- res += " + " + coefficients[i]->__str__() + "*" + variables[i]->__str__();
- }
- res += ")";
- string_array[index] = res;
-}
-
-void SumOperator::print(std::string *string_array) {
- std::string res = "(" + operands[0]->get_string_from_array(string_array);
- for (unsigned int i = 1; i < nargs; ++i) {
- res += " + " + operands[i]->get_string_from_array(string_array);
- }
- res += ")";
- string_array[index] = res;
-}
-
-std::shared_ptr>>
-Leaf::get_prefix_notation() {
- std::shared_ptr>> res =
- std::make_shared>>();
- res->push_back(shared_from_this());
- return res;
-}
-
-std::shared_ptr>>
-Expression::get_prefix_notation() {
- std::shared_ptr>> res =
- std::make_shared>>();
- std::shared_ptr>> stack =
- std::make_shared>>();
- std::shared_ptr node;
- stack->push_back(operators[n_operators - 1]);
- while (stack->size() > 0) {
- node = stack->back();
- stack->pop_back();
- res->push_back(node);
- node->fill_prefix_notation_stack(stack);
- }
-
- return res;
-}
-
-void BinaryOperator::fill_prefix_notation_stack(
- std::shared_ptr>> stack) {
- stack->push_back(operand2);
- stack->push_back(operand1);
-}
-
-void UnaryOperator::fill_prefix_notation_stack(
- std::shared_ptr>> stack) {
- stack->push_back(operand);
-}
-
-void SumOperator::fill_prefix_notation_stack(
- std::shared_ptr>> stack) {
- int ndx = nargs - 1;
- while (ndx >= 0) {
- stack->push_back(operands[ndx]);
- ndx -= 1;
- }
-}
-
-void LinearOperator::fill_prefix_notation_stack(
- std::shared_ptr>> stack) {
- ; // This is treated as a leaf in this context; write_nl_string will take care
- // of it
-}
-
-void ExternalOperator::fill_prefix_notation_stack(
- std::shared_ptr>> stack) {
- int i = nargs - 1;
- while (i >= 0) {
- stack->push_back(operands[i]);
- i -= 1;
- }
-}
-
-void Var::write_nl_string(std::ofstream &f) { f << "v" << index << "\n"; }
-
-void Param::write_nl_string(std::ofstream &f) { f << "n" << value << "\n"; }
-
-void Constant::write_nl_string(std::ofstream &f) { f << "n" << value << "\n"; }
-
-void Expression::write_nl_string(std::ofstream &f) {
- std::shared_ptr>> prefix_notation =
- get_prefix_notation();
- for (std::shared_ptr &node : *(prefix_notation)) {
- node->write_nl_string(f);
- }
-}
-
-void MultiplyOperator::write_nl_string(std::ofstream &f) { f << "o2\n"; }
-
-void ExternalOperator::write_nl_string(std::ofstream &f) {
- f << "f" << external_function_index << " " << nargs << "\n";
-}
-
-void SumOperator::write_nl_string(std::ofstream &f) {
- if (nargs == 2) {
- f << "o0\n";
- } else {
- f << "o54\n";
- f << nargs << "\n";
- }
-}
-
-void LinearOperator::write_nl_string(std::ofstream &f) {
- bool has_const =
- (!constant->is_constant_type()) || (constant->evaluate() != 0);
- unsigned int n_sum_args = nterms + (has_const ? 1 : 0);
- if (n_sum_args == 2) {
- f << "o0\n";
- } else {
- f << "o54\n";
- f << n_sum_args << "\n";
- }
- if (has_const)
- f << "n" << constant->evaluate() << "\n";
- for (unsigned int ndx = 0; ndx < nterms; ++ndx) {
- f << "o2\n";
- f << "n" << coefficients[ndx]->evaluate() << "\n";
- variables[ndx]->write_nl_string(f);
- }
-}
-
-void DivideOperator::write_nl_string(std::ofstream &f) { f << "o3\n"; }
-
-void PowerOperator::write_nl_string(std::ofstream &f) { f << "o5\n"; }
-
-void NegationOperator::write_nl_string(std::ofstream &f) { f << "o16\n"; }
-
-void ExpOperator::write_nl_string(std::ofstream &f) { f << "o44\n"; }
-
-void LogOperator::write_nl_string(std::ofstream &f) { f << "o43\n"; }
-
-void AbsOperator::write_nl_string(std::ofstream &f) { f << "o15\n"; }
-
-void SqrtOperator::write_nl_string(std::ofstream &f) { f << "o39\n"; }
-
-void Log10Operator::write_nl_string(std::ofstream &f) { f << "o42\n"; }
-
-void SinOperator::write_nl_string(std::ofstream &f) { f << "o41\n"; }
-
-void CosOperator::write_nl_string(std::ofstream &f) { f << "o46\n"; }
-
-void TanOperator::write_nl_string(std::ofstream &f) { f << "o38\n"; }
-
-void AsinOperator::write_nl_string(std::ofstream &f) { f << "o51\n"; }
-
-void AcosOperator::write_nl_string(std::ofstream &f) { f << "o53\n"; }
-
-void AtanOperator::write_nl_string(std::ofstream &f) { f << "o49\n"; }
-
-bool BinaryOperator::is_binary_operator() { return true; }
-
-bool UnaryOperator::is_unary_operator() { return true; }
-
-bool LinearOperator::is_linear_operator() { return true; }
-
-bool SumOperator::is_sum_operator() { return true; }
-
-bool MultiplyOperator::is_multiply_operator() { return true; }
-
-bool DivideOperator::is_divide_operator() { return true; }
-
-bool PowerOperator::is_power_operator() { return true; }
-
-bool NegationOperator::is_negation_operator() { return true; }
-
-bool ExpOperator::is_exp_operator() { return true; }
-
-bool LogOperator::is_log_operator() { return true; }
-
-bool AbsOperator::is_abs_operator() { return true; }
-
-bool SqrtOperator::is_sqrt_operator() { return true; }
-
-bool ExternalOperator::is_external_operator() { return true; }
-
-void Leaf::fill_expression(std::shared_ptr *oper_array,
- int &oper_ndx) {
- ;
-}
-
-void Expression::fill_expression(std::shared_ptr *oper_array,
- int &oper_ndx) {
- throw std::runtime_error("This should not happen");
-}
-
-void BinaryOperator::fill_expression(std::shared_ptr *oper_array,
- int &oper_ndx) {
- oper_ndx -= 1;
- oper_array[oper_ndx] = shared_from_this();
- // The order does not actually matter here. It
- // will just be easier to debug this way.
- operand2->fill_expression(oper_array, oper_ndx);
- operand1->fill_expression(oper_array, oper_ndx);
-}
-
-void UnaryOperator::fill_expression(std::shared_ptr *oper_array,
- int &oper_ndx) {
- oper_ndx -= 1;
- oper_array[oper_ndx] = shared_from_this();
- operand->fill_expression(oper_array, oper_ndx);
-}
-
-void LinearOperator::fill_expression(std::shared_ptr *oper_array,
- int &oper_ndx) {
- oper_ndx -= 1;
- oper_array[oper_ndx] = shared_from_this();
-}
-
-void SumOperator::fill_expression(std::shared_ptr *oper_array,
- int &oper_ndx) {
- oper_ndx -= 1;
- oper_array[oper_ndx] = shared_from_this();
- // The order does not actually matter here. It
- // will just be easier to debug this way.
- int arg_ndx = nargs - 1;
- while (arg_ndx >= 0) {
- operands[arg_ndx]->fill_expression(oper_array, oper_ndx);
- arg_ndx -= 1;
- }
-}
-
-void ExternalOperator::fill_expression(std::shared_ptr *oper_array,
- int &oper_ndx) {
- oper_ndx -= 1;
- oper_array[oper_ndx] = shared_from_this();
- // The order does not actually matter here. It
- // will just be easier to debug this way.
- int arg_ndx = nargs - 1;
- while (arg_ndx >= 0) {
- operands[arg_ndx]->fill_expression(oper_array, oper_ndx);
- arg_ndx -= 1;
- }
-}
-
-double Leaf::get_lb_from_array(double *lbs) { return value; }
-
-double Leaf::get_ub_from_array(double *ubs) { return value; }
-
-double Var::get_lb_from_array(double *lbs) { return get_lb(); }
-
-double Var::get_ub_from_array(double *ubs) { return get_ub(); }
-
-double Expression::get_lb_from_array(double *lbs) {
- return lbs[n_operators - 1];
-}
-
-double Expression::get_ub_from_array(double *ubs) {
- return ubs[n_operators - 1];
-}
-
-double Operator::get_lb_from_array(double *lbs) { return lbs[index]; }
-
-double Operator::get_ub_from_array(double *ubs) { return ubs[index]; }
-
-void Leaf::set_bounds_in_array(double new_lb, double new_ub, double *lbs,
- double *ubs, double feasibility_tol,
- double integer_tol, double improvement_tol,
- std::set> &improved_vars) {
- if (new_lb < value - feasibility_tol || new_lb > value + feasibility_tol) {
- throw InfeasibleConstraintException(
- "Infeasible constraint; bounds computed on parameter or constant "
- "disagree with the value of the parameter or constant\n value: " +
- std::to_string(value) + "\n computed LB: " + std::to_string(new_lb) +
- "\n computed UB: " + std::to_string(new_ub));
- }
-
- if (new_ub < value - feasibility_tol || new_ub > value + feasibility_tol) {
- throw InfeasibleConstraintException(
- "Infeasible constraint; bounds computed on parameter or constant "
- "disagree with the value of the parameter or constant\n value: " +
- std::to_string(value) + "\n computed LB: " + std::to_string(new_lb) +
- "\n computed UB: " + std::to_string(new_ub));
- }
-}
-
-void Var::set_bounds_in_array(double new_lb, double new_ub, double *lbs,
- double *ubs, double feasibility_tol,
- double integer_tol, double improvement_tol,
- std::set> &improved_vars) {
- if (new_lb > new_ub) {
- if (new_lb - feasibility_tol > new_ub)
- throw InfeasibleConstraintException(
- "Infeasible constraint; The computed lower bound for a variable is "
- "larger than the computed upper bound.\n computed LB: " +
- std::to_string(new_lb) +
- "\n computed UB: " + std::to_string(new_ub));
- else {
- new_lb -= feasibility_tol;
- new_ub += feasibility_tol;
- }
- }
- if (new_lb >= inf)
- throw InfeasibleConstraintException(
- "Infeasible constraint; The compute lower bound for " + name +
- " is inf");
- if (new_ub <= -inf)
- throw InfeasibleConstraintException(
- "Infeasible constraint; The computed upper bound for " + name +
- " is -inf");
-
- if (domain == integers || domain == binary) {
- if (new_lb > -inf) {
- double lb_floor = floor(new_lb);
- double lb_ceil = ceil(new_lb - integer_tol);
- if (lb_floor > lb_ceil)
- new_lb = lb_floor;
- else
- new_lb = lb_ceil;
- }
- if (new_ub < inf) {
- double ub_ceil = ceil(new_ub);
- double ub_floor = floor(new_ub + integer_tol);
- if (ub_ceil < ub_floor)
- new_ub = ub_ceil;
- else
- new_ub = ub_floor;
- }
- }
-
- double current_lb = get_lb();
- double current_ub = get_ub();
-
- if (new_lb > current_lb + improvement_tol ||
- new_ub < current_ub - improvement_tol)
- improved_vars.insert(shared_from_this());
-
- if (new_lb > current_lb) {
- if (lb->is_leaf())
- std::dynamic_pointer_cast(lb)->value = new_lb;
- else
- throw py::value_error(
- "variable bounds cannot be expressions when performing FBBT");
- }
-
- if (new_ub < current_ub) {
- if (ub->is_leaf())
- std::dynamic_pointer_cast(ub)->value = new_ub;
- else
- throw py::value_error(
- "variable bounds cannot be expressions when performing FBBT");
- }
-}
-
-void Expression::set_bounds_in_array(
- double new_lb, double new_ub, double *lbs, double *ubs,
- double feasibility_tol, double integer_tol, double improvement_tol,
- std::set> &improved_vars) {
- lbs[n_operators - 1] = new_lb;
- ubs[n_operators - 1] = new_ub;
-}
-
-void Operator::set_bounds_in_array(
- double new_lb, double new_ub, double *lbs, double *ubs,
- double feasibility_tol, double integer_tol, double improvement_tol,
- std::set> &improved_vars) {
- lbs[index] = new_lb;
- ubs[index] = new_ub;
-}
-
-void Expression::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- for (unsigned int ndx = 0; ndx < n_operators; ++ndx) {
- operators[ndx]->index = ndx;
- operators[ndx]->propagate_bounds_forward(lbs, ubs, feasibility_tol,
- integer_tol);
- }
-}
-
-void Expression::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- int ndx = n_operators - 1;
- while (ndx >= 0) {
- operators[ndx]->propagate_bounds_backward(
- lbs, ubs, feasibility_tol, integer_tol, improvement_tol, improved_vars);
- ndx -= 1;
- }
-}
-
-void Operator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- lbs[index] = -inf;
- ubs[index] = inf;
-}
-
-void Operator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- ;
-}
-
-void MultiplyOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- if (operand1 == operand2) {
- interval_power(operand1->get_lb_from_array(lbs),
- operand1->get_ub_from_array(ubs), 2, 2, &lbs[index],
- &ubs[index], feasibility_tol);
- } else {
- interval_mul(operand1->get_lb_from_array(lbs),
- operand1->get_ub_from_array(ubs),
- operand2->get_lb_from_array(lbs),
- operand2->get_ub_from_array(ubs), &lbs[index], &ubs[index]);
- }
-}
-
-void MultiplyOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand1->get_lb_from_array(lbs);
- double xu = operand1->get_ub_from_array(ubs);
- double yl = operand2->get_lb_from_array(lbs);
- double yu = operand2->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu, new_yl, new_yu;
-
- if (operand1 == operand2) {
- _inverse_power1(lb, ub, 2, 2, xl, xu, &new_xl, &new_xu, feasibility_tol);
- new_yl = new_xl;
- new_yu = new_xu;
- } else {
- interval_div(lb, ub, yl, yu, &new_xl, &new_xu, feasibility_tol);
- interval_div(lb, ub, xl, xu, &new_yl, &new_yu, feasibility_tol);
- }
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand1->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-
- if (new_yl > yl)
- yl = new_yl;
- if (new_yu < yu)
- yu = new_yu;
- operand2->set_bounds_in_array(yl, yu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void SumOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- double lb = operands[0]->get_lb_from_array(lbs);
- double ub = operands[0]->get_ub_from_array(ubs);
- double tmp_lb;
- double tmp_ub;
-
- for (unsigned int ndx = 1; ndx < nargs; ++ndx) {
- interval_add(lb, ub, operands[ndx]->get_lb_from_array(lbs),
- operands[ndx]->get_ub_from_array(ubs), &tmp_lb, &tmp_ub);
- lb = tmp_lb;
- ub = tmp_ub;
- }
-
- lbs[index] = lb;
- ubs[index] = ub;
-}
-
-void SumOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double *accumulated_lbs = new double[nargs];
- double *accumulated_ubs = new double[nargs];
-
- accumulated_lbs[0] = operands[0]->get_lb_from_array(lbs);
- accumulated_ubs[0] = operands[0]->get_ub_from_array(ubs);
- for (unsigned int ndx = 1; ndx < nargs; ++ndx) {
- interval_add(accumulated_lbs[ndx - 1], accumulated_ubs[ndx - 1],
- operands[ndx]->get_lb_from_array(lbs),
- operands[ndx]->get_ub_from_array(ubs), &accumulated_lbs[ndx],
- &accumulated_ubs[ndx]);
- }
-
- double new_sum_lb = get_lb_from_array(lbs);
- double new_sum_ub = get_ub_from_array(ubs);
-
- if (new_sum_lb > accumulated_lbs[nargs - 1])
- accumulated_lbs[nargs - 1] = new_sum_lb;
- if (new_sum_ub < accumulated_ubs[nargs - 1])
- accumulated_ubs[nargs - 1] = new_sum_ub;
-
- double lb0, ub0, lb1, ub1, lb2, ub2, _lb1, _ub1, _lb2, _ub2;
-
- int ndx = nargs - 1;
- while (ndx >= 1) {
- lb0 = accumulated_lbs[ndx];
- ub0 = accumulated_ubs[ndx];
- lb1 = accumulated_lbs[ndx - 1];
- ub1 = accumulated_ubs[ndx - 1];
- lb2 = operands[ndx]->get_lb_from_array(lbs);
- ub2 = operands[ndx]->get_ub_from_array(ubs);
- interval_sub(lb0, ub0, lb2, ub2, &_lb1, &_ub1);
- interval_sub(lb0, ub0, lb1, ub1, &_lb2, &_ub2);
- if (_lb1 > lb1)
- lb1 = _lb1;
- if (_ub1 < ub1)
- ub1 = _ub1;
- if (_lb2 > lb2)
- lb2 = _lb2;
- if (_ub2 < ub2)
- ub2 = _ub2;
- accumulated_lbs[ndx - 1] = lb1;
- accumulated_ubs[ndx - 1] = ub1;
- operands[ndx]->set_bounds_in_array(lb2, ub2, lbs, ubs, feasibility_tol,
- integer_tol, improvement_tol,
- improved_vars);
- ndx -= 1;
- }
-
- // take care of ndx = 0
- lb1 = operands[0]->get_lb_from_array(lbs);
- ub1 = operands[0]->get_ub_from_array(ubs);
- _lb1 = accumulated_lbs[0];
- _ub1 = accumulated_ubs[0];
- if (_lb1 > lb1)
- lb1 = _lb1;
- if (_ub1 < ub1)
- ub1 = _ub1;
- operands[0]->set_bounds_in_array(lb1, ub1, lbs, ubs, feasibility_tol,
- integer_tol, improvement_tol, improved_vars);
-
- delete[] accumulated_lbs;
- delete[] accumulated_ubs;
-}
-
-void LinearOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- double lb = constant->evaluate();
- double ub = lb;
- double tmp_lb;
- double tmp_ub;
- double coef;
-
- for (unsigned int ndx = 0; ndx < nterms; ++ndx) {
- coef = coefficients[ndx]->evaluate();
- interval_mul(coef, coef, variables[ndx]->get_lb(), variables[ndx]->get_ub(),
- &tmp_lb, &tmp_ub);
- interval_add(lb, ub, tmp_lb, tmp_ub, &lb, &ub);
- }
-
- lbs[index] = lb;
- ubs[index] = ub;
-}
-
-void LinearOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double *accumulated_lbs = new double[nterms + 1];
- double *accumulated_ubs = new double[nterms + 1];
-
- double coef;
-
- accumulated_lbs[0] = constant->evaluate();
- accumulated_ubs[0] = constant->evaluate();
- for (unsigned int ndx = 0; ndx < nterms; ++ndx) {
- coef = coefficients[ndx]->evaluate();
- interval_mul(coef, coef, variables[ndx]->get_lb(), variables[ndx]->get_ub(),
- &accumulated_lbs[ndx + 1], &accumulated_ubs[ndx + 1]);
- interval_add(accumulated_lbs[ndx], accumulated_ubs[ndx],
- accumulated_lbs[ndx + 1], accumulated_ubs[ndx + 1],
- &accumulated_lbs[ndx + 1], &accumulated_ubs[ndx + 1]);
- }
-
- double new_sum_lb = get_lb_from_array(lbs);
- double new_sum_ub = get_ub_from_array(ubs);
-
- if (new_sum_lb > accumulated_lbs[nterms])
- accumulated_lbs[nterms] = new_sum_lb;
- if (new_sum_ub < accumulated_ubs[nterms])
- accumulated_ubs[nterms] = new_sum_ub;
-
- double lb0, ub0, lb1, ub1, lb2, ub2, _lb1, _ub1, _lb2, _ub2, new_v_lb,
- new_v_ub;
-
- int ndx = nterms - 1;
- while (ndx >= 0) {
- lb0 = accumulated_lbs[ndx + 1];
- ub0 = accumulated_ubs[ndx + 1];
- lb1 = accumulated_lbs[ndx];
- ub1 = accumulated_ubs[ndx];
- coef = coefficients[ndx]->evaluate();
- interval_mul(coef, coef, variables[ndx]->get_lb(), variables[ndx]->get_ub(),
- &lb2, &ub2);
- interval_sub(lb0, ub0, lb2, ub2, &_lb1, &_ub1);
- interval_sub(lb0, ub0, lb1, ub1, &_lb2, &_ub2);
- if (_lb1 > lb1)
- lb1 = _lb1;
- if (_ub1 < ub1)
- ub1 = _ub1;
- if (_lb2 > lb2)
- lb2 = _lb2;
- if (_ub2 < ub2)
- ub2 = _ub2;
- accumulated_lbs[ndx] = lb1;
- accumulated_ubs[ndx] = ub1;
- interval_div(lb2, ub2, coef, coef, &new_v_lb, &new_v_ub, feasibility_tol);
- variables[ndx]->set_bounds_in_array(new_v_lb, new_v_ub, lbs, ubs,
- feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
- ndx -= 1;
- }
-
- delete[] accumulated_lbs;
- delete[] accumulated_ubs;
-}
-
-void DivideOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_div(
- operand1->get_lb_from_array(lbs), operand1->get_ub_from_array(ubs),
- operand2->get_lb_from_array(lbs), operand2->get_ub_from_array(ubs),
- &lbs[index], &ubs[index], feasibility_tol);
-}
-
-void DivideOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand1->get_lb_from_array(lbs);
- double xu = operand1->get_ub_from_array(ubs);
- double yl = operand2->get_lb_from_array(lbs);
- double yu = operand2->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl;
- double new_xu;
- double new_yl;
- double new_yu;
-
- interval_mul(lb, ub, yl, yu, &new_xl, &new_xu);
- interval_div(xl, xu, lb, ub, &new_yl, &new_yu, feasibility_tol);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand1->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-
- if (new_yl > yl)
- yl = new_yl;
- if (new_yu < yu)
- yu = new_yu;
- operand2->set_bounds_in_array(yl, yu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void NegationOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_sub(0, 0, operand->get_lb_from_array(lbs),
- operand->get_ub_from_array(ubs), &lbs[index], &ubs[index]);
-}
-
-void NegationOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl;
- double new_xu;
-
- interval_sub(0, 0, lb, ub, &new_xl, &new_xu);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void PowerOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_power(
- operand1->get_lb_from_array(lbs), operand1->get_ub_from_array(ubs),
- operand2->get_lb_from_array(lbs), operand2->get_ub_from_array(ubs),
- &lbs[index], &ubs[index], feasibility_tol);
-}
-
-void PowerOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand1->get_lb_from_array(lbs);
- double xu = operand1->get_ub_from_array(ubs);
- double yl = operand2->get_lb_from_array(lbs);
- double yu = operand2->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu, new_yl, new_yu;
- _inverse_power1(lb, ub, yl, yu, xl, xu, &new_xl, &new_xu, feasibility_tol);
- if (yl != yu)
- _inverse_power2(lb, ub, xl, xu, &new_yl, &new_yu, feasibility_tol);
- else {
- new_yl = yl;
- new_yu = yu;
- }
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand1->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-
- if (new_yl > yl)
- yl = new_yl;
- if (new_yu < yu)
- yu = new_yu;
- operand2->set_bounds_in_array(yl, yu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void SqrtOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_power(operand->get_lb_from_array(lbs),
- operand->get_ub_from_array(ubs), 0.5, 0.5, &lbs[index],
- &ubs[index], feasibility_tol);
-}
-
-void SqrtOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double yl = 0.5;
- double yu = 0.5;
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- _inverse_power1(lb, ub, yl, yu, xl, xu, &new_xl, &new_xu, feasibility_tol);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void ExpOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_exp(operand->get_lb_from_array(lbs), operand->get_ub_from_array(ubs),
- &lbs[index], &ubs[index]);
-}
-
-void ExpOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_log(lb, ub, &new_xl, &new_xu);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void LogOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_log(operand->get_lb_from_array(lbs), operand->get_ub_from_array(ubs),
- &lbs[index], &ubs[index]);
-}
-
-void LogOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_exp(lb, ub, &new_xl, &new_xu);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void AbsOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_abs(operand->get_lb_from_array(lbs), operand->get_ub_from_array(ubs),
- &lbs[index], &ubs[index]);
-}
-
-void AbsOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- _inverse_abs(lb, ub, &new_xl, &new_xu);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void Log10Operator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_log10(operand->get_lb_from_array(lbs),
- operand->get_ub_from_array(ubs), &lbs[index], &ubs[index]);
-}
-
-void Log10Operator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_power(10, 10, lb, ub, &new_xl, &new_xu, feasibility_tol);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void SinOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_sin(operand->get_lb_from_array(lbs), operand->get_ub_from_array(ubs),
- &lbs[index], &ubs[index]);
-}
-
-void SinOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_asin(lb, ub, xl, xu, &new_xl, &new_xu, feasibility_tol);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void CosOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_cos(operand->get_lb_from_array(lbs), operand->get_ub_from_array(ubs),
- &lbs[index], &ubs[index]);
-}
-
-void CosOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_acos(lb, ub, xl, xu, &new_xl, &new_xu, feasibility_tol);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void TanOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_tan(operand->get_lb_from_array(lbs), operand->get_ub_from_array(ubs),
- &lbs[index], &ubs[index]);
-}
-
-void TanOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_atan(lb, ub, xl, xu, &new_xl, &new_xu);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void AsinOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_asin(operand->get_lb_from_array(lbs),
- operand->get_ub_from_array(ubs), -inf, inf, &lbs[index],
- &ubs[index], feasibility_tol);
-}
-
-void AsinOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_sin(lb, ub, &new_xl, &new_xu);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void AcosOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_acos(operand->get_lb_from_array(lbs),
- operand->get_ub_from_array(ubs), -inf, inf, &lbs[index],
- &ubs[index], feasibility_tol);
-}
-
-void AcosOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_cos(lb, ub, &new_xl, &new_xu);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-void AtanOperator::propagate_bounds_forward(double *lbs, double *ubs,
- double feasibility_tol,
- double integer_tol) {
- interval_atan(operand->get_lb_from_array(lbs),
- operand->get_ub_from_array(ubs), -inf, inf, &lbs[index],
- &ubs[index]);
-}
-
-void AtanOperator::propagate_bounds_backward(
- double *lbs, double *ubs, double feasibility_tol, double integer_tol,
- double improvement_tol, std::set> &improved_vars) {
- double xl = operand->get_lb_from_array(lbs);
- double xu = operand->get_ub_from_array(ubs);
- double lb = get_lb_from_array(lbs);
- double ub = get_ub_from_array(ubs);
-
- double new_xl, new_xu;
- interval_tan(lb, ub, &new_xl, &new_xu);
-
- if (new_xl > xl)
- xl = new_xl;
- if (new_xu < xu)
- xu = new_xu;
- operand->set_bounds_in_array(xl, xu, lbs, ubs, feasibility_tol, integer_tol,
- improvement_tol, improved_vars);
-}
-
-std::vector> create_vars(int n_vars) {
- std::vector> res;
- for (int i = 0; i < n_vars; ++i) {
- res.push_back(std::make_shared());
- }
- return res;
-}
-
-std::vector> create_params(int n_params) {
- std::vector> res;
- for (int i = 0; i < n_params; ++i) {
- res.push_back(std::make_shared());
- }
- return res;
-}
-
-std::vector> create_constants(int n_constants) {
- std::vector> res;
- for (int i = 0; i < n_constants; ++i) {
- res.push_back(std::make_shared());
- }
- return res;
-}
-
-std::shared_ptr
-appsi_operator_from_pyomo_expr(py::handle expr, py::handle var_map,
- py::handle param_map,
- PyomoExprTypes &expr_types) {
- std::shared_ptr res;
- ExprType tmp_type =
- expr_types.expr_type_map[py::type::of(expr)].cast();
-
- switch (tmp_type) {
- case py_float: {
- res = std::make_shared(expr.cast());
- break;
- }
- case var: {
- res = var_map[expr_types.id(expr)].cast>();
- break;
- }
- case param: {
- res = param_map[expr_types.id(expr)].cast>();
- break;
- }
- case product: {
- res = std::make_shared();
- break;
- }
- case sum: {
- res = std::make_shared(expr.attr("nargs")().cast());
- break;
- }
- case negation: {
- res = std::make_shared();
- break;
- }
- case external_func: {
- res = std::make_shared(expr.attr("nargs")().cast());
- std::shared_ptr oper =
- std::dynamic_pointer_cast(res);
- oper->function_name =
- expr.attr("_fcn").attr("_function").cast();
- break;
- }
- case power: {
- res = std::make_shared();
- break;
- }
- case division: {
- res = std::make_shared();
- break;
- }
- case unary_func: {
- std::string function_name = expr.attr("getname")().cast();
- if (function_name == "exp")
- res = std::make_shared();
- else if (function_name == "log")
- res = std::make_shared();
- else if (function_name == "log10")
- res = std::make_shared();
- else if (function_name == "sin")
- res = std::make_shared();
- else if (function_name == "cos")
- res = std::make_shared();
- else if (function_name == "tan")
- res = std::make_shared();
- else if (function_name == "asin")
- res = std::make_shared();
- else if (function_name == "acos")
- res = std::make_shared();
- else if (function_name == "atan")
- res = std::make_shared();
- else if (function_name == "sqrt")
- res = std::make_shared();
- else
- throw py::value_error("Unrecognized expression type: " + function_name);
- break;
- }
- case linear: {
- res = std::make_shared(
- expr_types.len(expr.attr("linear_vars")).cast());
- break;
- }
- case named_expr: {
- res = appsi_operator_from_pyomo_expr(expr.attr("expr"), var_map, param_map,
- expr_types);
- break;
- }
- case numeric_constant: {
- res = std::make_shared(expr.attr("value").cast());
- break;
- }
- case pyomo_unit: {
- res = std::make_shared(1.0);
- break;
- }
- case unary_abs: {
- res = std::make_shared();
- break;
- }
- default: {
- throw py::value_error("Unrecognized expression type: " +
- expr_types.builtins.attr("str")(py::type::of(expr))
- .cast());
- break;
- }
- }
- return res;
-}
-
-void prep_for_repn_helper(py::handle expr, py::handle named_exprs,
- py::handle variables, py::handle fixed_vars,
- py::handle external_funcs,
- PyomoExprTypes &expr_types) {
- ExprType tmp_type =
- expr_types.expr_type_map[py::type::of(expr)].cast();
-
- switch (tmp_type) {
- case py_float: {
- break;
- }
- case var: {
- variables[expr_types.id(expr)] = expr;
- if (expr.attr("fixed").cast()) {
- fixed_vars[expr_types.id(expr)] = expr;
- }
- break;
- }
- case param: {
- break;
- }
- case product: {
- py::tuple args = expr.attr("_args_");
- for (py::handle arg : args) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- break;
- }
- case sum: {
- py::tuple args = expr.attr("args");
- for (py::handle arg : args) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- break;
- }
- case negation: {
- py::tuple args = expr.attr("_args_");
- for (py::handle arg : args) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- break;
- }
- case external_func: {
- external_funcs[expr_types.id(expr)] = expr;
- py::tuple args = expr.attr("args");
- for (py::handle arg : args) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- break;
- }
- case power: {
- py::tuple args = expr.attr("_args_");
- for (py::handle arg : args) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- break;
- }
- case division: {
- py::tuple args = expr.attr("_args_");
- for (py::handle arg : args) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- break;
- }
- case unary_func: {
- py::tuple args = expr.attr("_args_");
- for (py::handle arg : args) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- break;
- }
- case linear: {
- py::list linear_vars = expr.attr("linear_vars");
- py::list linear_coefs = expr.attr("linear_coefs");
- for (py::handle arg : linear_vars) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- for (py::handle arg : linear_coefs) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- prep_for_repn_helper(expr.attr("constant"), named_exprs, variables,
- fixed_vars, external_funcs, expr_types);
- break;
- }
- case named_expr: {
- named_exprs[expr_types.id(expr)] = expr;
- prep_for_repn_helper(expr.attr("expr"), named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- break;
- }
- case numeric_constant: {
- break;
- }
- case pyomo_unit: {
- break;
- }
- case unary_abs: {
- py::tuple args = expr.attr("_args_");
- for (py::handle arg : args) {
- prep_for_repn_helper(arg, named_exprs, variables, fixed_vars,
- external_funcs, expr_types);
- }
- break;
- }
- default: {
- if (expr_types.builtins.attr("hasattr")(expr, "is_constant").cast()) {
- if (expr.attr("is_constant")().cast())
- break;
- }
- throw py::value_error("Unrecognized expression type: " +
- expr_types.builtins.attr("str")(py::type::of(expr))
- .cast());
- break;
- }
- }
-}
-
-py::tuple prep_for_repn(py::handle expr, PyomoExprTypes &expr_types) {
- py::dict named_exprs;
- py::dict variables;
- py::dict fixed_vars;
- py::dict external_funcs;
-
- prep_for_repn_helper(expr, named_exprs, variables, fixed_vars, external_funcs,
- expr_types);
-
- py::list named_expr_list = named_exprs.attr("values")();
- py::list variable_list = variables.attr("values")();
- py::list fixed_var_list = fixed_vars.attr("values")();
- py::list external_func_list = external_funcs.attr("values")();
-
- py::tuple res = py::make_tuple(named_expr_list, variable_list, fixed_var_list,
- external_func_list);
- return res;
-}
-
-int build_expression_tree(py::handle pyomo_expr,
- std::shared_ptr appsi_expr, py::handle var_map,
- py::handle param_map, PyomoExprTypes &expr_types) {
- int num_nodes = 0;
-
- if (expr_types.expr_type_map[py::type::of(pyomo_expr)].cast() ==
- named_expr)
- pyomo_expr = pyomo_expr.attr("expr");
-
- if (appsi_expr->is_leaf()) {
- ;
- } else if (appsi_expr->is_binary_operator()) {
- num_nodes += 1;
- std::shared_ptr oper =
- std::dynamic_pointer_cast(appsi_expr);
- py::list pyomo_args = pyomo_expr.attr("args");
- oper->operand1 = appsi_operator_from_pyomo_expr(pyomo_args[0], var_map,
- param_map, expr_types);
- oper->operand2 = appsi_operator_from_pyomo_expr(pyomo_args[1], var_map,
- param_map, expr_types);
- num_nodes += build_expression_tree(pyomo_args[0], oper->operand1, var_map,
- param_map, expr_types);
- num_nodes += build_expression_tree(pyomo_args[1], oper->operand2, var_map,
- param_map, expr_types);
- } else if (appsi_expr->is_unary_operator()) {
- num_nodes += 1;
- std::shared_ptr oper =
- std::dynamic_pointer_cast(appsi_expr);
- py::list pyomo_args = pyomo_expr.attr("args");
- oper->operand = appsi_operator_from_pyomo_expr(pyomo_args[0], var_map,
- param_map, expr_types);
- num_nodes += build_expression_tree(pyomo_args[0], oper->operand, var_map,
- param_map, expr_types);
- } else if (appsi_expr->is_sum_operator()) {
- num_nodes += 1;
- std::shared_ptr oper =
- std::dynamic_pointer_cast(appsi_expr);
- py::list pyomo_args = pyomo_expr.attr("args");
- for (unsigned int arg_ndx = 0; arg_ndx < oper->nargs; ++arg_ndx) {
- oper->operands[arg_ndx] = appsi_operator_from_pyomo_expr(
- pyomo_args[arg_ndx], var_map, param_map, expr_types);
- num_nodes +=
- build_expression_tree(pyomo_args[arg_ndx], oper->operands[arg_ndx],
- var_map, param_map, expr_types);
- }
- } else if (appsi_expr->is_linear_operator()) {
- num_nodes += 1;
- std::shared_ptr oper =
- std::dynamic_pointer_cast(appsi_expr);
- oper->constant = appsi_expr_from_pyomo_expr(pyomo_expr.attr("constant"),
- var_map, param_map, expr_types);
- py::list pyomo_vars = pyomo_expr.attr("linear_vars");
- py::list pyomo_coefs = pyomo_expr.attr("linear_coefs");
- for (unsigned int arg_ndx = 0; arg_ndx < oper->nterms; ++arg_ndx) {
- oper->variables[arg_ndx] = var_map[expr_types.id(pyomo_vars[arg_ndx])]
- .cast>();
- oper->coefficients[arg_ndx] = appsi_expr_from_pyomo_expr(
- pyomo_coefs[arg_ndx], var_map, param_map, expr_types);
- }
- } else if (appsi_expr->is_external_operator()) {
- num_nodes += 1;
- std::shared_ptr oper =
- std::dynamic_pointer_cast(appsi_expr);
- py::list pyomo_args = pyomo_expr.attr("args");
- for (unsigned int arg_ndx = 0; arg_ndx < oper->nargs; ++arg_ndx) {
- oper->operands[arg_ndx] = appsi_operator_from_pyomo_expr(
- pyomo_args[arg_ndx], var_map, param_map, expr_types);
- num_nodes +=
- build_expression_tree(pyomo_args[arg_ndx], oper->operands[arg_ndx],
- var_map, param_map, expr_types);
- }
- } else {
- throw py::value_error(
- "Unrecognized expression type: " +
- expr_types.builtins.attr("str")(py::type::of(pyomo_expr))
- .cast());
- }
- return num_nodes;
-}
-
-std::shared_ptr
-appsi_expr_from_pyomo_expr(py::handle expr, py::handle var_map,
- py::handle param_map, PyomoExprTypes &expr_types) {
- std::shared_ptr node =
- appsi_operator_from_pyomo_expr(expr, var_map, param_map, expr_types);
- int num_nodes =
- build_expression_tree(expr, node, var_map, param_map, expr_types);
- if (num_nodes == 0) {
- return std::dynamic_pointer_cast(node);
- } else {
- std::shared_ptr res = std::make_shared(num_nodes);
- node->fill_expression(res->operators, num_nodes);
- return res;
- }
-}
-
-std::vector>
-appsi_exprs_from_pyomo_exprs(py::list expr_list, py::dict var_map,
- py::dict param_map) {
- PyomoExprTypes expr_types = PyomoExprTypes();
- int num_exprs = expr_types.builtins.attr("len")(expr_list).cast();
- std::vector> res(num_exprs);
-
- int ndx = 0;
- for (py::handle expr : expr_list) {
- res[ndx] = appsi_expr_from_pyomo_expr(expr, var_map, param_map, expr_types);
- ndx += 1;
- }
- return res;
-}
-
-void process_pyomo_vars(PyomoExprTypes &expr_types, py::list pyomo_vars,
- py::dict var_map, py::dict param_map,
- py::dict var_attrs, py::dict rev_var_map,
- py::bool_ _set_name, py::handle symbol_map,
- py::handle labeler, py::bool_ _update) {
- py::tuple v_attrs;
- std::shared_ptr cv;
- py::handle v_lb;
- py::handle v_ub;
- py::handle v_val;
- py::tuple domain_interval;
- py::handle interval_lb;
- py::handle interval_ub;
- py::handle interval_step;
- bool v_fixed;
- bool set_name = _set_name.cast();
- bool update = _update.cast();
- double domain_step;
-
- for (py::handle v : pyomo_vars) {
- v_attrs = var_attrs[expr_types.id(v)];
- v_lb = v_attrs[1];
- v_ub = v_attrs[2];
- v_fixed = v_attrs[3].cast();
- domain_interval = v_attrs[4];
- v_val = v_attrs[5];
-
- interval_lb = domain_interval[0];
- interval_ub = domain_interval[1];
- interval_step = domain_interval[2];
- domain_step = interval_step.cast();
-
- if (update) {
- cv = var_map[expr_types.id(v)].cast>();
- } else {
- cv = std::make_shared();
- }
-
- if (!(v_lb.is(py::none()))) {
- cv->lb = appsi_expr_from_pyomo_expr(v_lb, var_map, param_map, expr_types);
- } else {
- cv->lb = std::make_shared(-inf);
- }
- if (!(v_ub.is(py::none()))) {
- cv->ub = appsi_expr_from_pyomo_expr(v_ub, var_map, param_map, expr_types);
- } else {
- cv->ub = std::make_shared(inf);
- }
-
- if (!(v_val.is(py::none()))) {
- cv->value = v_val.cast();
- }
-
- if (v_fixed) {
- cv->fixed = true;
- } else {
- cv->fixed = false;
- }
-
- if (set_name && !update) {
- cv->name = symbol_map.attr("getSymbol")(v, labeler).cast();
- }
-
- if (interval_lb.is(py::none()))
- cv->domain_lb = -inf;
- else
- cv->domain_lb = interval_lb.cast();
- if (interval_ub.is(py::none()))
- cv->domain_ub = inf;
- else
- cv->domain_ub = interval_ub.cast();
- if (domain_step == 0)
- cv->domain = continuous;
- else if (domain_step == 1) {
- if ((cv->domain_lb == 0) && (cv->domain_ub == 1))
- cv->domain = binary;
- else
- cv->domain = integers;
- } else
- throw py::value_error("Unrecognized domain step");
-
- if (!update) {
- var_map[expr_types.id(v)] = py::cast(cv);
- rev_var_map[py::cast(cv)] = v;
- }
- }
-}
+/**___________________________________________________________________________
+ *
+ * Pyomo: Python Optimization Modeling Objects
+ * Copyright (c) 2008-2024
+ * National Technology and Engineering Solutions of Sandia, LLC
+ * Under the terms of Contract DE-NA0003525 with National Technology and
+ * Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
+ * rights in this software.
+ * This software is distributed under the 3-clause BSD License.
+ * ___________________________________________________________________________
+**/
+
+#include "expression.hpp"
+
+bool Leaf::is_leaf() { return true; }
+
+bool Var::is_variable_type() { return true; }
+
+bool Param::is_param_type() { return true; }
+
+bool Constant::is_constant_type() { return true; }
+
+bool Expression::is_expression_type() { return true; }
+
+double Leaf::evaluate() { return value; }
+
+double Var::get_lb() {
+ if (fixed)
+ return value;
+ else
+ return std::max(lb->evaluate(), domain_lb);
+}
+
+double Var::get_ub() {
+ if (fixed)
+ return value;
+ else
+ return std::min(ub->evaluate(), domain_ub);
+}
+
+Domain Var::get_domain() { return domain; }
+
+bool Operator::is_operator_type() { return true; }
+
+std::vector> Expression::get_operators() {
+ std::vector> res(n_operators);
+ for (unsigned int i = 0; i < n_operators; ++i) {
+ res[i] = operators[i];
+ }
+ return res;
+}
+
+double Leaf::get_value_from_array(double *val_array) { return value; }
+
+double Expression::get_value_from_array(double *val_array) {
+ return val_array[n_operators - 1];
+}
+
+double Operator::get_value_from_array(double *val_array) {
+ return val_array[index];
+}
+
+void MultiplyOperator::evaluate(double *values) {
+ values[index] = operand1->get_value_from_array(values) *
+ operand2->get_value_from_array(values);
+}
+
+void ExternalOperator::evaluate(double *values) {
+ // It would be nice to implement this, but it will take some more work.
+ // This would require dynamic linking to the external function.
+ throw std::runtime_error("cannot evaluate ExternalOperator yet");
+}
+
+void LinearOperator::evaluate(double *values) {
+ values[index] = constant->evaluate();
+ for (unsigned int i = 0; i < nterms; ++i) {
+ values[index] += coefficients[i]->evaluate() * variables[i]->evaluate();
+ }
+}
+
+void SumOperator::evaluate(double *values) {
+ values[index] = 0.0;
+ for (unsigned int i = 0; i < nargs; ++i) {
+ values[index] += operands[i]->get_value_from_array(values);
+ }
+}
+
+void DivideOperator::evaluate(double *values) {
+ values[index] = operand1->get_value_from_array(values) /
+ operand2->get_value_from_array(values);
+}
+
+void PowerOperator::evaluate(double *values) {
+ values[index] = std::pow(operand1->get_value_from_array(values),
+ operand2->get_value_from_array(values));
+}
+
+void NegationOperator::evaluate(double *values) {
+ values[index] = -operand->get_value_from_array(values);
+}
+
+void ExpOperator::evaluate(double *values) {
+ values[index] = std::exp(operand->get_value_from_array(values));
+}
+
+void LogOperator::evaluate(double *values) {
+ values[index] = std::log(operand->get_value_from_array(values));
+}
+
+void AbsOperator::evaluate(double *values) {
+ values[index] = std::fabs(operand->get_value_from_array(values));
+}
+
+void SqrtOperator::evaluate(double *values) {
+ values[index] = std::pow(operand->get_value_from_array(values), 0.5);
+}
+
+void Log10Operator::evaluate(double *values) {
+ values[index] = std::log10(operand->get_value_from_array(values));
+}
+
+void SinOperator::evaluate(double *values) {
+ values[index] = std::sin(operand->get_value_from_array(values));
+}
+
+void CosOperator::evaluate(double *values) {
+ values[index] = std::cos(operand->get_value_from_array(values));
+}
+
+void TanOperator::evaluate(double *values) {
+ values[index] = std::tan(operand->get_value_from_array(values));
+}
+
+void AsinOperator::evaluate(double *values) {
+ values[index] = std::asin(operand->get_value_from_array(values));
+}
+
+void AcosOperator::evaluate(double *values) {
+ values[index] = std::acos(operand->get_value_from_array(values));
+}
+
+void AtanOperator::evaluate(double *values) {
+ values[index] = std::atan(operand->get_value_from_array(values));
+}
+
+double Expression::evaluate() {
+ double *values = new double[n_operators];
+ for (unsigned int i = 0; i < n_operators; ++i) {
+ operators[i]->index = i;
+ operators[i]->evaluate(values);
+ }
+ double res = get_value_from_array(values);
+ delete[] values;
+ return res;
+}
+
+void UnaryOperator::identify_variables(
+ std::set> &var_set,
+ std::shared_ptr>> var_vec) {
+ if (operand->is_variable_type()) {
+ if (var_set.count(operand) == 0) {
+ var_vec->push_back(std::dynamic_pointer_cast(operand));
+ var_set.insert(operand);
+ }
+ }
+}
+
+void BinaryOperator::identify_variables(
+ std::set> &var_set,
+ std::shared_ptr>> var_vec) {
+ if (operand1->is_variable_type()) {
+ if (var_set.count(operand1) == 0) {
+ var_vec->push_back(std::dynamic_pointer_cast(operand1));
+ var_set.insert(operand1);
+ }
+ }
+ if (operand2->is_variable_type()) {
+ if (var_set.count(operand2) == 0) {
+ var_vec->push_back(std::dynamic_pointer_cast(operand2));
+ var_set.insert(operand2);
+ }
+ }
+}
+
+void ExternalOperator::identify_variables(
+ std::set> &var_set,
+ std::shared_ptr>> var_vec) {
+ for (unsigned int i = 0; i < nargs; ++i) {
+ if (operands[i]->is_variable_type()) {
+ if (var_set.count(operands[i]) == 0) {
+ var_vec->push_back(std::dynamic_pointer_cast(operands[i]));
+ var_set.insert(operands[i]);
+ }
+ }
+ }
+}
+
+void LinearOperator::identify_variables(
+ std::set> &var_set,
+ std::shared_ptr>> var_vec) {
+ for (unsigned int i = 0; i < nterms; ++i) {
+ if (var_set.count(variables[i]) == 0) {
+ var_vec->push_back(std::dynamic_pointer_cast(variables[i]));
+ var_set.insert(variables[i]);
+ }
+ }
+}
+
+void SumOperator::identify_variables(
+ std::set> &var_set,
+ std::shared_ptr>> var_vec) {
+ for (unsigned int i = 0; i < nargs; ++i) {
+ if (operands[i]->is_variable_type()) {
+ if (var_set.count(operands[i]) == 0) {
+ var_vec->push_back(std::dynamic_pointer_cast(operands[i]));
+ var_set.insert(operands[i]);
+ }
+ }
+ }
+}
+
+std::shared_ptr>>
+Expression::identify_variables() {
+ std::set> var_set;
+ std::shared_ptr