diff --git a/.coin-or/projDesc.xml b/.coin-or/projDesc.xml
index c08006d08e8..073efd968a7 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.6.2
- 6.6.2
+ 6.7.2
+ 6.7.2
@@ -287,7 +287,7 @@ Carl D. Laird, Chair, Pyomo Management Committee, claird at andrew dot cmu dot e
Any
- Python 3.8, 3.9, 3.10, 3.11
+ Python 3.8, 3.9, 3.10, 3.11, 3.12
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 6d3e6401c5b..36b9898397f 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -43,4 +43,6 @@ ed13c8c65d6c3f56973887744be1c62a5d4756de
0d93f98aa608f892df404ad8015885d26e09bb55
63a3c602a00a2b747fc308c0571bbe33e55a3731
363a16a609f519b3edfdfcf40c66d6de7ac135af
+d024718991455519e09149ede53a38df1c067abe
+017e21ee50d98d8b2f2083e6880f030025ed5378
diff --git a/.github/workflows/release_wheel_creation.yml b/.github/workflows/release_wheel_creation.yml
index da183eebfe2..932b0d8eea6 100644
--- a/.github/workflows/release_wheel_creation.yml
+++ b/.github/workflows/release_wheel_creation.yml
@@ -15,52 +15,94 @@ concurrency:
cancel-in-progress: true
env:
- PYOMO_SETUP_ARGS: --with-distributable-extensions
+ PYOMO_SETUP_ARGS: "--with-cython --with-distributable-extensions"
jobs:
- manylinux:
- name: ${{ matrix.TARGET }}/${{ matrix.wheel-version }}_wheel_creation
+ native_wheels:
+ name: Build wheels (${{ matrix.wheel-version }}) on ${{ matrix.os }} for native and cross-compiled architecture
runs-on: ${{ matrix.os }}
strategy:
- fail-fast: false
+ fail-fast: true
matrix:
- wheel-version: ['cp38-cp38', 'cp39-cp39', 'cp310-cp310', 'cp311-cp311']
- os: [ubuntu-latest]
+ os: [ubuntu-22.04, windows-latest, macos-latest]
+ arch: [all]
+ wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*']
+
include:
- - os: ubuntu-latest
- TARGET: manylinux
- python-version: [3.8]
+ - 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@v3
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v3
- with:
- python-version: ${{ matrix.python-version }}
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install twine wheel setuptools pybind11
- # TODO: Update the manylinux builder to next tagged release
- - name: Build manylinux Python wheels
- uses: RalfG/python-wheels-manylinux-build@a1e012c58ed3960f81b7ed2759a037fb0ad28e2d
- with:
- python-versions: ${{ matrix.wheel-version }}
- build-requirements: 'cython pybind11'
- package-path: ''
- pip-wheel-args: ''
- # When locally testing, --no-deps flag is necessary (PyUtilib dependency will trigger an error otherwise)
- - name: Consolidate wheels
- run: |
- sudo test -d dist || mkdir -v dist
- sudo find . -name \*.whl | grep -v /dist/ | xargs -n1 -i mv -v "{}" dist/
- - name: Delete linux wheels
- run: |
- sudo rm -rfv dist/*-linux_x86_64.whl
- - name: Upload artifact
- uses: actions/upload-artifact@v3
- with:
- name: manylinux-wheels
- path: dist
+ - uses: actions/checkout@v4
+ - name: Build wheels
+ uses: pypa/cibuildwheel@v2.16.5
+ with:
+ output-dir: dist
+ env:
+ CIBW_ARCHS_LINUX: "native"
+ CIBW_ARCHS_MACOS: "native arm64"
+ CIBW_ARCHS_WINDOWS: "native ARM64"
+ CIBW_SKIP: "*-musllinux*"
+ CIBW_BUILD: ${{ matrix.wheel-version }}
+ CIBW_BUILD_VERBOSITY: 1
+ CIBW_BEFORE_BUILD: pip install cython pybind11
+ CIBW_CONFIG_SETTINGS: '--global-option="--with-cython --with-distributable-extensions"'
+ - uses: actions/upload-artifact@v4
+ with:
+ 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
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ 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
+ if: runner.os == 'Linux'
+ uses: docker/setup-qemu-action@v3
+ with:
+ platforms: all
+ - name: Build wheels
+ uses: pypa/cibuildwheel@v2.16.5
+ with:
+ output-dir: dist
+ env:
+ CIBW_ARCHS_LINUX: "aarch64"
+ CIBW_SKIP: "*-musllinux*"
+ CIBW_BUILD: ${{ matrix.wheel-version }}
+ CIBW_BUILD_VERBOSITY: 1
+ CIBW_BEFORE_BUILD: pip install cython pybind11
+ CIBW_CONFIG_SETTINGS: '--global-option="--with-cython --with-distributable-extensions"'
+ - uses: actions/upload-artifact@v4
+ with:
+ name: alt_wheels-${{ matrix.os }}-${{ matrix.TARGET }}
+ path: dist/*.whl
+ overwrite: true
generictarball:
name: ${{ matrix.TARGET }}
@@ -74,9 +116,9 @@ jobs:
TARGET: generic_tarball
python-version: [3.8]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v3
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
@@ -87,72 +129,9 @@ jobs:
run: |
python setup.py --without-cython sdist --format=gztar
- name: Upload artifact
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: generictarball
path: dist
+ overwrite: true
- osx:
- name: ${{ matrix.TARGET }}py${{ matrix.python-version }}/wheel_creation
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- os: [macos-latest]
- include:
- - os: macos-latest
- TARGET: osx
- python-version: [ 3.8, 3.9, '3.10', '3.11' ]
- steps:
- - uses: actions/checkout@v3
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v3
- with:
- python-version: ${{ matrix.python-version }}
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install twine wheel setuptools cython pybind11
- - name: Build OSX Python wheels
- run: |
- python setup.py --with-cython --with-distributable-extensions sdist --format=gztar bdist_wheel
-
- - name: Upload artifact
- uses: actions/upload-artifact@v3
- with:
- name: osx-wheels
- path: dist
-
- windows:
- name: ${{ matrix.TARGET }}py${{ matrix.python-version }}/wheel_creation
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- os: [windows-latest]
- include:
- - os: windows-latest
- TARGET: win
- python-version: [ 3.8, 3.9, '3.10', '3.11' ]
- steps:
- - uses: actions/checkout@v3
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v3
- with:
- python-version: ${{ matrix.python-version }}
- - name: Install dependencies
- shell: pwsh
- run: |
- $env:PYTHONWARNINGS="ignore::UserWarning"
- Invoke-Expression "python -m pip install --upgrade pip"
- Invoke-Expression "pip install setuptools twine wheel cython pybind11"
- - name: Build Windows Python wheels
- shell: pwsh
- run: |
- $env:PYTHONWARNINGS="ignore::UserWarning"
- Invoke-Expression "python setup.py --with-cython --with-distributable-extensions sdist --format=gztar bdist_wheel"
- - name: Upload artifact
- uses: actions/upload-artifact@v3
- with:
- name: win-wheels
- path: dist
diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml
index e773587ec85..5063571c65f 100644
--- a/.github/workflows/test_branches.yml
+++ b/.github/workflows/test_branches.yml
@@ -33,14 +33,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Pyomo source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up Python
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
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
@@ -56,17 +57,17 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
- python: ['3.11']
+ python: ['3.12']
other: [""]
category: [""]
include:
- os: ubuntu-latest
- python: '3.11'
+ python: '3.12'
TARGET: linux
PYENV: pip
- - os: macos-latest
+ - os: macos-13
python: '3.10'
TARGET: osx
PYENV: pip
@@ -75,24 +76,24 @@ jobs:
python: 3.9
TARGET: win
PYENV: conda
- PACKAGES: glpk
+ PACKAGES: glpk pytest-qt filelock
- os: ubuntu-latest
- python: 3.9
+ python: '3.11'
other: /conda
skip_doctest: 1
TARGET: linux
PYENV: conda
- PACKAGES:
+ PACKAGES: pytest-qt
- os: ubuntu-latest
- python: 3.8
+ 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'
@@ -112,7 +113,7 @@ jobs:
steps:
- name: Checkout Pyomo source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Configure job parameters
run: |
@@ -134,7 +135,7 @@ jobs:
| tr '\n' ' ' | sed 's/ \+/ /g' >> $GITHUB_ENV
#- name: Pip package cache
- # uses: actions/cache@v3
+ # uses: actions/cache@v4
# if: matrix.PYENV == 'pip'
# id: pip-cache
# with:
@@ -142,7 +143,7 @@ jobs:
# key: pip-${{env.CACHE_VER}}.0-${{runner.os}}-${{matrix.python}}
#- name: OS package cache
- # uses: actions/cache@v3
+ # uses: actions/cache@v4
# if: matrix.TARGET != 'osx'
# id: os-cache
# with:
@@ -150,7 +151,7 @@ jobs:
# key: pkg-${{env.CACHE_VER}}.0-${{runner.os}}
- name: TPL package download cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
if: ${{ ! matrix.slim }}
id: download-cache
with:
@@ -180,7 +181,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 +193,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
@@ -202,17 +204,26 @@ jobs:
- name: Set up Python ${{ matrix.python }}
if: matrix.PYENV == 'pip'
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Set up Miniconda Python ${{ matrix.python }}
if: matrix.PYENV == 'conda'
- uses: conda-incubator/setup-miniconda@v2
+ uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: false
python-version: ${{ matrix.python }}
+ # This is necessary for qt (UI) tests; the package utilized here does not
+ # have support for OSX.
+ - name: Set up UI testing infrastructure
+ if: ${{ matrix.TARGET != 'osx' }}
+ uses: pyvista/setup-headless-display-action@v2
+ with:
+ qt: true
+ pyvista: false
+
# GitHub actions is very fragile when it comes to setting up various
# Python interpreters, expecially the setup-miniconda interface.
# Per the setup-miniconda documentation, it is important to always
@@ -235,6 +246,7 @@ jobs:
run: |
python -c 'import sys;print(sys.executable)'
python -m pip install --cache-dir cache/pip --upgrade pip
+ python -m pip install --cache-dir cache/pip setuptools
PYOMO_DEPENDENCIES=`python setup.py dependencies \
--extras "$EXTRAS" | tail -1`
PACKAGES="${PYTHON_CORE_PKGS} ${PYTHON_PACKAGES} ${PYOMO_DEPENDENCIES} "
@@ -253,11 +265,18 @@ 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 \
+ 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
+ python -m pip install wntr \
+ || echo "WARNING: WNTR is not available"
+ fi
fi
python -c 'import sys; print("PYTHON_EXE=%s" \
% (sys.executable,))' >> $GITHUB_ENV
@@ -302,7 +321,7 @@ jobs:
fi
# HACK: Remove problem packages on conda+Linux
if test "${{matrix.TARGET}}" == linux; then
- EXCLUDE="casadi numdifftools pint $EXCLUDE"
+ EXCLUDE="casadi numdifftools $EXCLUDE"
fi
EXCLUDE=`echo "$EXCLUDE" | xargs`
if test -n "$EXCLUDE"; then
@@ -317,6 +336,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)
@@ -324,7 +344,7 @@ jobs:
if test -z "${{matrix.slim}}"; then
PYVER=$(echo "py${{matrix.python}}" | sed 's/\.//g')
echo "Installing for $PYVER"
- for PKG in 'cplex>=12.10' docplex gurobi xpress cyipopt pymumps scip; do
+ for PKG in 'cplex>=12.10' docplex 'gurobi=10.0.3' xpress cyipopt pymumps scip; do
echo ""
echo "*** Install $PKG ***"
# conda can literally take an hour to determine that a
@@ -339,10 +359,11 @@ jobs:
| sed -r 's/\s+/ /g' | cut -d\ -f3) || echo ""
if test -n "$_BUILDS"; then
_ISPY=$(echo "$_BUILDS" | grep "^py") \
- || echo "No python build detected"
- _PYOK=$(echo "$_BUILDS" | grep "^$PYVER") \
- || echo "No python build matching $PYVER detected"
+ || echo "INFO: No python build detected."
+ _PYOK=$(echo "$_BUILDS" | grep -E "^($PYVER|pyh)") \
+ || echo "INFO: No python build matching $PYVER detected."
if test -z "$_ISPY" -o -n "$_PYOK"; then
+ echo ""
echo "... INSTALLING $PKG"
conda install -y "$PKG" || _BUILDS=""
fi
@@ -351,18 +372,6 @@ jobs:
echo "WARNING: $PKG is not available"
fi
done
- # TODO: This is a hack to stop test_qt.py from running until we
- # can better troubleshoot why it fails on GHA
- for QTPACKAGE in qt pyqt; do
- # Because conda is insane, removing packages can cause
- # unrelated packages to be updated (breaking version
- # specifications specified previously, e.g., in
- # setup.py). There doesn't appear to be a good
- # workaround, so we will just force-remove (recognizing
- # that it may break other conda cruft).
- conda remove --force-remove $QTPACKAGE \
- || echo "$QTPACKAGE not in this environment"
- done
fi
# Re-try Pyomo (optional) dependencies with pip
if test -n "$PYPI_DEPENDENCIES"; then
@@ -585,8 +594,8 @@ jobs:
echo "COVERAGE_PROCESS_START=$COVERAGE_RC" >> $GITHUB_ENV
cp ${GITHUB_WORKSPACE}/.coveragerc ${COVERAGE_RC}
echo "data_file=${COVERAGE_BASE}age" >> ${COVERAGE_RC}
- SITE_PACKAGES=$($PYTHON_EXE -c "from distutils.sysconfig import \
- get_python_lib; print(get_python_lib())")
+ SITE_PACKAGES=$($PYTHON_EXE -c \
+ "import sysconfig; print(sysconfig.get_path('purelib'))")
echo "Python site-packages: $SITE_PACKAGES"
echo 'import coverage; coverage.process_startup()' \
> ${SITE_PACKAGES}/run_coverage_at_startup.pth
@@ -616,7 +625,7 @@ jobs:
$PYTHON_EXE -m pytest -v \
-W ignore::Warning ${{matrix.category}} \
pyomo `pwd`/pyomo-model-libraries \
- `pwd`/examples/pyomobook --junitxml="TEST-pyomo.xml"
+ `pwd`/examples `pwd`/doc --junitxml="TEST-pyomo.xml"
- name: Run Pyomo MPI tests
if: matrix.mpi != 0
@@ -626,7 +635,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
@@ -643,7 +652,7 @@ jobs:
coverage xml -i
- name: Record build artifacts
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: ${{github.job}}_${{env.GHA_JOBGROUP}}-${{env.GHA_JOBNAME}}
path: |
@@ -660,10 +669,10 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout Pyomo source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up Python 3.8
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: 3.8
@@ -703,35 +712,35 @@ 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
steps:
- name: Checkout Pyomo source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
# We need the source for .codecov.yml and running "coverage xml"
#- name: Pip package cache
- # uses: actions/cache@v3
+ # uses: actions/cache@v4
# id: pip-cache
# with:
# path: cache/pip
# key: pip-${{env.CACHE_VER}}.0-${{runner.os}}-3.8
- name: Download build artifacts
- uses: actions/download-artifact@v3
+ uses: actions/download-artifact@v4
with:
path: artifacts
- name: Set up Python 3.8
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: 3.8
@@ -826,7 +835,7 @@ jobs:
- name: Upload codecov reports
if: github.repository_owner == 'Pyomo' || github.ref != 'refs/heads/main'
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
with:
files: coverage.xml
token: ${{ secrets.PYOMO_CODECOV_TOKEN }}
@@ -838,7 +847,7 @@ jobs:
if: |
hashFiles('coverage-other.xml') != '' &&
(github.repository_owner == 'Pyomo' || github.ref != 'refs/heads/main')
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
with:
files: coverage-other.xml
token: ${{ secrets.PYOMO_CODECOV_TOKEN }}
diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml
index 2885fd107a8..a45fdd54f03 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,16 +39,19 @@ 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@v3
+ uses: actions/checkout@v4
- name: Set up Python
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
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
@@ -59,8 +67,8 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
- python: [ 3.8, 3.9, '3.10', '3.11' ]
+ os: [ubuntu-latest, macos-13, windows-latest]
+ python: [ 3.8, 3.9, '3.10', '3.11', '3.12' ]
other: [""]
category: [""]
@@ -69,34 +77,34 @@ jobs:
TARGET: linux
PYENV: pip
- - os: macos-latest
+ - os: macos-13
TARGET: osx
PYENV: pip
- os: windows-latest
TARGET: win
PYENV: conda
- PACKAGES: glpk
+ PACKAGES: glpk pytest-qt filelock
- os: ubuntu-latest
- python: 3.9
+ python: '3.11'
other: /conda
skip_doctest: 1
TARGET: linux
PYENV: conda
- PACKAGES:
+ 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
+ python: '3.11'
other: /singletest
category: "-m 'neos or importtest'"
skip_doctest: 1
@@ -142,7 +150,7 @@ jobs:
steps:
- name: Checkout Pyomo source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Configure job parameters
run: |
@@ -164,7 +172,7 @@ jobs:
| tr '\n' ' ' | sed 's/ \+/ /g' >> $GITHUB_ENV
#- name: Pip package cache
- # uses: actions/cache@v3
+ # uses: actions/cache@v4
# if: matrix.PYENV == 'pip'
# id: pip-cache
# with:
@@ -172,7 +180,7 @@ jobs:
# key: pip-${{env.CACHE_VER}}.0-${{runner.os}}-${{matrix.python}}
#- name: OS package cache
- # uses: actions/cache@v3
+ # uses: actions/cache@v4
# if: matrix.TARGET != 'osx'
# id: os-cache
# with:
@@ -180,7 +188,7 @@ jobs:
# key: pkg-${{env.CACHE_VER}}.0-${{runner.os}}
- name: TPL package download cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
if: ${{ ! matrix.slim }}
id: download-cache
with:
@@ -210,7 +218,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 +230,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
@@ -232,17 +241,26 @@ jobs:
- name: Set up Python ${{ matrix.python }}
if: matrix.PYENV == 'pip'
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Set up Miniconda Python ${{ matrix.python }}
if: matrix.PYENV == 'conda'
- uses: conda-incubator/setup-miniconda@v2
+ uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: false
python-version: ${{ matrix.python }}
+ # This is necessary for qt (UI) tests; the package utilized here does not
+ # have support for OSX.
+ - name: Set up UI testing infrastructure
+ if: ${{ matrix.TARGET != 'osx' }}
+ uses: pyvista/setup-headless-display-action@v2
+ with:
+ qt: true
+ pyvista: false
+
# GitHub actions is very fragile when it comes to setting up various
# Python interpreters, expecially the setup-miniconda interface.
# Per the setup-miniconda documentation, it is important to always
@@ -265,6 +283,7 @@ jobs:
run: |
python -c 'import sys;print(sys.executable)'
python -m pip install --cache-dir cache/pip --upgrade pip
+ python -m pip install --cache-dir cache/pip setuptools
PYOMO_DEPENDENCIES=`python setup.py dependencies \
--extras "$EXTRAS" | tail -1`
PACKAGES="${PYTHON_CORE_PKGS} ${PYTHON_PACKAGES} ${PYOMO_DEPENDENCIES} "
@@ -283,11 +302,18 @@ 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 \
+ 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
+ python -m pip install wntr \
+ || echo "WARNING: WNTR is not available"
+ fi
fi
python -c 'import sys; print("PYTHON_EXE=%s" \
% (sys.executable,))' >> $GITHUB_ENV
@@ -332,7 +358,7 @@ jobs:
fi
# HACK: Remove problem packages on conda+Linux
if test "${{matrix.TARGET}}" == linux; then
- EXCLUDE="casadi numdifftools pint $EXCLUDE"
+ EXCLUDE="casadi numdifftools $EXCLUDE"
fi
EXCLUDE=`echo "$EXCLUDE" | xargs`
if test -n "$EXCLUDE"; then
@@ -347,6 +373,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)
@@ -354,7 +381,7 @@ jobs:
if test -z "${{matrix.slim}}"; then
PYVER=$(echo "py${{matrix.python}}" | sed 's/\.//g')
echo "Installing for $PYVER"
- for PKG in 'cplex>=12.10' docplex gurobi xpress cyipopt pymumps scip; do
+ for PKG in 'cplex>=12.10' docplex 'gurobi=10.0.3' xpress cyipopt pymumps scip; do
echo ""
echo "*** Install $PKG ***"
# conda can literally take an hour to determine that a
@@ -369,10 +396,11 @@ jobs:
| sed -r 's/\s+/ /g' | cut -d\ -f3) || echo ""
if test -n "$_BUILDS"; then
_ISPY=$(echo "$_BUILDS" | grep "^py") \
- || echo "No python build detected"
- _PYOK=$(echo "$_BUILDS" | grep "^$PYVER") \
- || echo "No python build matching $PYVER detected"
+ || echo "INFO: No python build detected."
+ _PYOK=$(echo "$_BUILDS" | grep -E "^($PYVER|pyh)") \
+ || echo "INFO: No python build matching $PYVER detected."
if test -z "$_ISPY" -o -n "$_PYOK"; then
+ echo ""
echo "... INSTALLING $PKG"
conda install -y "$PKG" || _BUILDS=""
fi
@@ -381,18 +409,6 @@ jobs:
echo "WARNING: $PKG is not available"
fi
done
- # TODO: This is a hack to stop test_qt.py from running until we
- # can better troubleshoot why it fails on GHA
- for QTPACKAGE in qt pyqt; do
- # Because conda is insane, removing packages can cause
- # unrelated packages to be updated (breaking version
- # specifications specified previously, e.g., in
- # setup.py). There doesn't appear to be a good
- # workaround, so we will just force-remove (recognizing
- # that it may break other conda cruft).
- conda remove --force-remove $QTPACKAGE \
- || echo "$QTPACKAGE not in this environment"
- done
fi
# Re-try Pyomo (optional) dependencies with pip
if test -n "$PYPI_DEPENDENCIES"; then
@@ -600,7 +616,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
@@ -615,8 +632,8 @@ jobs:
echo "COVERAGE_PROCESS_START=$COVERAGE_RC" >> $GITHUB_ENV
cp ${GITHUB_WORKSPACE}/.coveragerc ${COVERAGE_RC}
echo "data_file=${COVERAGE_BASE}age" >> ${COVERAGE_RC}
- SITE_PACKAGES=$($PYTHON_EXE -c "from distutils.sysconfig import \
- get_python_lib; print(get_python_lib())")
+ SITE_PACKAGES=$($PYTHON_EXE -c \
+ "import sysconfig; print(sysconfig.get_path('purelib'))")
echo "Python site-packages: $SITE_PACKAGES"
echo 'import coverage; coverage.process_startup()' \
> ${SITE_PACKAGES}/run_coverage_at_startup.pth
@@ -646,7 +663,7 @@ jobs:
$PYTHON_EXE -m pytest -v \
-W ignore::Warning ${{matrix.category}} \
pyomo `pwd`/pyomo-model-libraries \
- `pwd`/examples/pyomobook --junitxml="TEST-pyomo.xml"
+ `pwd`/examples `pwd`/doc --junitxml="TEST-pyomo.xml"
- name: Run Pyomo MPI tests
if: matrix.mpi != 0
@@ -656,7 +673,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
@@ -673,7 +690,7 @@ jobs:
coverage xml -i
- name: Record build artifacts
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: ${{github.job}}_${{env.GHA_JOBGROUP}}-${{env.GHA_JOBNAME}}
path: |
@@ -691,10 +708,10 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout Pyomo source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up Python 3.8
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: 3.8
@@ -728,41 +745,41 @@ 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
steps:
- name: Checkout Pyomo source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
# We need the source for .codecov.yml and running "coverage xml"
#- name: Pip package cache
- # uses: actions/cache@v3
+ # uses: actions/cache@v4
# id: pip-cache
# with:
# path: cache/pip
# key: pip-${{env.CACHE_VER}}.0-${{runner.os}}-3.8
- name: Download build artifacts
- uses: actions/download-artifact@v3
+ uses: actions/download-artifact@v4
with:
path: artifacts
- name: Set up Python 3.8
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: 3.8
@@ -857,7 +874,7 @@ jobs:
- name: Upload codecov reports
if: github.repository_owner == 'Pyomo' || github.ref != 'refs/heads/main'
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
with:
files: coverage.xml
token: ${{ secrets.PYOMO_CODECOV_TOKEN }}
@@ -869,7 +886,7 @@ jobs:
if: |
hashFiles('coverage-other.xml') != '' &&
(github.repository_owner == 'Pyomo' || github.ref != 'refs/heads/main')
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
with:
files: coverage-other.xml
token: ${{ secrets.PYOMO_CODECOV_TOKEN }}
diff --git a/.github/workflows/typos.toml b/.github/workflows/typos.toml
index 23f94fc8afd..7a38164898b 100644
--- a/.github/workflows/typos.toml
+++ b/.github/workflows/typos.toml
@@ -40,4 +40,31 @@ WRONLY = "WRONLY"
Hax = "Hax"
# 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"
# AS NEEDED: Add More Words Below
diff --git a/.gitignore b/.gitignore
index 09069552990..638dc70d13e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,4 +24,7 @@ gurobi.log
# Jupyterhub/Jupyterlab checkpoints
.ipynb_checkpoints
-cplex.log
\ No newline at end of file
+cplex.log
+
+# Mac tracking files
+*.DS_Store*
diff --git a/.jenkins.sh b/.jenkins.sh
index f31fef99377..696847fd92c 100644
--- a/.jenkins.sh
+++ b/.jenkins.sh
@@ -38,14 +38,11 @@ if test -z "$WORKSPACE"; then
export WORKSPACE=`pwd`
fi
if test -z "$TEST_SUITES"; then
- export TEST_SUITES="${WORKSPACE}/pyomo/pyomo ${WORKSPACE}/pyomo-model-libraries ${WORKSPACE}/pyomo/examples/pyomobook"
+ export TEST_SUITES="${WORKSPACE}/pyomo/pyomo ${WORKSPACE}/pyomo-model-libraries ${WORKSPACE}/pyomo/examples ${WORKSPACE}/pyomo/doc"
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"
@@ -77,7 +74,7 @@ if test -z "$MODE" -o "$MODE" == setup; then
source python/bin/activate
# Because modules set the PYTHONPATH, we need to make sure that the
# virtualenv appears first
- LOCAL_SITE_PACKAGES=`python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`
+ LOCAL_SITE_PACKAGES=`python -c "import sysconfig; print(sysconfig.get_path('purelib'))"`
export PYTHONPATH="$LOCAL_SITE_PACKAGES:$PYTHONPATH"
# Set up Pyomo checkouts
@@ -122,10 +119,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 +188,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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e0ba1f885cb..11b4ecbf785 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,218 @@ Pyomo CHANGELOG
===============
+-------------------------------------------------------------------------------
+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)
+-------------------------------------------------------------------------------
+
+- General
+ - Remove Python 3.7, add Python 3.12 Support (#3050, #2956)
+ - Update report_timing() to support context manager API (#3039)
+ - Add `Preformatted` class for logging preformatted messages (#2998)
+ - QuadraticRepnVisitor: Improve nonlinear expression expansion (#2997)
+ - Add `CITATION` file to main repository (#2992)
+ - Minor typo / formatting fixes (#3010, #2975)
+- Core
+ - Fix exception from interaction of Gurobi, Pint, Dask, and Threading (#3026)
+ - Fix differentiation of `Expressions` with `native_numeric_types` (#3017)
+ - Warn for explicit declaration of immutable params with units (#3004)
+ - Use `SetInitializer` for initializing `Param` domains; reinitializing
+ `IndexedVar` domains (#3001)
+ - Ensure templatize_constraint returns an expression (#2983)
+ - Prevent multiple applications of the scaling transform (#2979)
+- Solver Interfaces
+ - Remove presolve-eliminated variables from named expressions (#3056)
+ - Improve LP/NL writer determinism (#3054)
+ - Add "writer" for converting linear models to standard matrix form (#3046)
+ - NLv2/LPv2: Log which suffix values were skipped at the DEBUG level (#3043)
+ - NLv2: add linear presolve and general problem scaling support (#3037)
+ - Adjust mps writer format for integer variable declaration (#2946)
+ - Fix scip results processing (#3023)
+ - Fix quadratic objective off-diagonal-terms in cplex_direct interface (#3025)
+ - Consolidate walker logic in LP/NL representations (#3015)
+ - LP writer: warn user for ignored suffixes (#2982)
+ - Update handling of `0*` in linear, quadratic walkers (#2981)
+- Testing
+ - Pin `gurobipy` version for testing to 10.0.3 (#3053)
+ - Update Performance Plot URL (#3033)
+ - Track change in Black rules (#3021)
+ - Resolve build infrastructure errors (with mpi4py, gams, networkx) (#3018)
+ - Improve GHA conda env package setup (#3013, #2967)
+ - Update Gurobi license checks in tests (#3011)
+ - Skip `fileutils` test failure that persists in OSX 12.7 (#3008)
+ - LINTING: New Version of `crate-ci/typos` (#2987)
+- GDP
+ - Improve Disjunction construction error for invalid types (#3042)
+ - Adding new walker for compute_bounds_on_expr (#3027)
+ - Fix bugs in gdp.bound_pretransformation (#2973)
+ - Fix various bugs in GDP transformations (#3009)
+ - Add a few more GDP examples (#2932)
+- Contributed Packages
+ - APPSI: Add interface to WNTR (#2902)
+ - APPSI: Capture HiGHS output when initializing model (#3005)
+ - APPSI: Fix auto-update when unfixing variable and changing bounds (#2996)
+ - APPSI: Fix reference bug in HiGHS interface (#2995)
+ - FBBT: Add new walker for compute_bounds_on_expr (#3027)
+ - incidence_analysis: Fix bugs with subset ordering and 0 coefficients (#3041)
+ - incidence_analysis: Update paper reference (#2969)
+ - latex_printer: Add contrib.latex_printer package (#2984)
+ - MindtPy: Add support for GreyBox models (#2988)
+ - parmest: Cleanup examples and tests (#3028)
+ - PyNumero: Handle evaluation errors in CyIpopt solver (#2994)
+ - PyROS: Report relative variable shifts in solver logs (#3035)
+ - PyROS: Update logging system (#2990)
+
-------------------------------------------------------------------------------
Pyomo 6.6.2 (23 Aug 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 e544d854c71..707f1a06c5a 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ subproblems using Python parallel communication libraries.
* [About Pyomo](http://www.pyomo.org/about)
* [Download](http://www.pyomo.org/installation/)
* [Documentation](http://www.pyomo.org/documentation/)
-* [Performance Plots](https://software.sandia.gov/downloads/pub/pyomo/performance/index.html)
+* [Performance Plots](https://pyomo.github.io/performance/)
Pyomo was formerly released as the Coopr software library.
@@ -51,7 +51,7 @@ Pyomo is available under the BSD License - see the
Pyomo is currently tested with the following Python implementations:
-* CPython: 3.8, 3.9, 3.10, 3.11
+* CPython: 3.8, 3.9, 3.10, 3.11, 3.12
* PyPy: 3.9
_Testing and support policy_:
@@ -71,8 +71,11 @@ version, we will remove testing for that Python version.
### Tutorials and Examples
-* [Pyomo Workshop Slides](https://software.sandia.gov/downloads/pub/pyomo/Pyomo-Workshop-Summer-2018.pdf)
+* [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 da97ba78701..b0228e53944 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -1,34 +1,24 @@
-We are pleased to announce the release of Pyomo 6.6.2.
+We are pleased to announce the release of Pyomo 6.7.2.
Pyomo is a collection of Python software packages that supports a
diverse set of optimization capabilities for formulating and analyzing
optimization models.
-The following are highlights of the 6.0 release series:
-
- - Improved stability and robustness of core Pyomo code and solver interfaces
- - Integration of Boolean variables into GDP
- - Integration of NumPy support into the Pyomo expression system
- - Implemented a more performant and robust expression generation system
- - Implemented a more performant NL file writer (NLv2)
- - Implemented a more performant LP file writer (LPv2)
- - Applied [PEP8 standards](https://peps.python.org/pep-0008/) throughout the
- codebase
- - Added support for Python 3.10, 3.11
- - Removed support for Python 3.6
- - Removed the `pyomo check` command
+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:
- - APPSI (Auto-Persistent Pyomo Solver Interfaces)
- - CP (Constraint programming models and solver interfaces)
- - DoE (Model based design of experiments)
- - External grey box models
- - IIS (Standard interface to solver IIS capabilities)
- - MPC (Data structures/utils for rolling horizon dynamic optimization)
- - piecewise (Modeling with and reformulating multivariate piecewise linear
- functions)
- - PyROS (Pyomo Robust Optimization Solver)
- - Structural model analysis
- - Rewrite of the TrustRegion Solver
+ - 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
[`CHANGELOG.md`](https://github.com/Pyomo/pyomo/blob/main/CHANGELOG.md).
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/Makefile b/doc/OnlineDocs/Makefile
index 604903631b2..3625325ef73 100644
--- a/doc/OnlineDocs/Makefile
+++ b/doc/OnlineDocs/Makefile
@@ -23,4 +23,4 @@ clean clean_tests:
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "Removing *.spy, *.out"
@find . -name \*.spy -delete
- @find tests -name \*.out -delete
+ @find src -name \*.out -delete
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/advanced_topics/linearexpression.rst b/doc/OnlineDocs/advanced_topics/linearexpression.rst
index a320b66590f..8b43c3fa03a 100644
--- a/doc/OnlineDocs/advanced_topics/linearexpression.rst
+++ b/doc/OnlineDocs/advanced_topics/linearexpression.rst
@@ -2,7 +2,7 @@ LinearExpression
================
Significant speed
-improvements can be obtained using the ``LinearExpression`` object
+improvements can sometimes be obtained using the ``LinearExpression`` object
when there are long, dense, linear expressions. The arguments are
::
@@ -11,7 +11,9 @@ when there are long, dense, linear expressions. The arguments are
where the second and third arguments are lists that must be of the
same length. Here is a simple example that illustrates the
-syntax. This example creates two constraints that are the same:
+syntax. This example creates two constraints that are the same; in this
+particular case the LinearExpression component would offer very little improvement
+because Pyomo would be able to detect that `campe2` is a linear expression:
.. doctest::
@@ -38,5 +40,5 @@ syntax. This example creates two constraints that are the same:
.. warning::
- The lists that are passed to ``LinearModel`` are not copied, so caution must
+ The lists that are passed to ``LinearExpression`` are not copied, so caution must
be exercised if they are modified after the component is constructed.
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 d8939cf61dd..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 -*-
#
@@ -26,12 +37,12 @@
sys.path.insert(0, os.path.abspath('../..'))
# -- Rebuild SPY files ----------------------------------------------------
-sys.path.insert(0, os.path.abspath('tests'))
+sys.path.insert(0, os.path.abspath('src'))
try:
print("Regenerating SPY files...")
from strip_examples import generate_spy_files
- generate_spy_files(os.path.abspath('tests'))
+ generate_spy_files(os.path.abspath('src'))
generate_spy_files(
os.path.abspath(os.path.join('library_reference', 'kernel', 'examples'))
)
@@ -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/doe/doe.rst b/doc/OnlineDocs/contributed_packages/doe/doe.rst
index 354a9916e9b..8c22ff7370d 100644
--- a/doc/OnlineDocs/contributed_packages/doe/doe.rst
+++ b/doc/OnlineDocs/contributed_packages/doe/doe.rst
@@ -266,7 +266,7 @@ It allows users to define any number of design decisions. Heatmaps can be drawn
The function ``run_grid_search`` enumerates over the design space, each MBDoE problem accomplished by ``compute_FIM`` method.
Therefore, ``run_grid_search`` supports only two modes: ``sequential_finite`` and ``direct_kaug``.
-.. literalinclude:: ../../../../pyomo/contrib/doe/examples/reactor_compute_FIM.py
+.. literalinclude:: ../../../../pyomo/contrib/doe/examples/reactor_grid_search.py
:language: python
:pyobject: main
@@ -284,7 +284,7 @@ Pyomo.DoE accomplishes gradient-based optimization with the ``stochastic_program
This function solves twice: It solves the square version of the MBDoE problem first, and then unfixes the design variables as degree of freedoms and solves again. In this way the optimization problem can be well initialized.
-.. literalinclude:: ../../../../pyomo/contrib/doe/examples/reactor_compute_FIM.py
+.. literalinclude:: ../../../../pyomo/contrib/doe/examples/reactor_optimize_doe.py
:language: python
:pyobject: main
diff --git a/doc/OnlineDocs/contributed_packages/gdpopt.rst b/doc/OnlineDocs/contributed_packages/gdpopt.rst
index 5e5b8ccce5d..d550b0ced76 100644
--- a/doc/OnlineDocs/contributed_packages/gdpopt.rst
+++ b/doc/OnlineDocs/contributed_packages/gdpopt.rst
@@ -175,7 +175,10 @@ To use the GDPopt-LBB solver, define your Pyomo GDP model as usual:
>>> m.djn = Disjunction(expr=[m.y1, m.y2])
Invoke the GDPopt-LBB solver
+
>>> results = SolverFactory('gdpopt.lbb').solve(m)
+ WARNING: 09/06/22: The GDPopt LBB algorithm currently has known issues. Please
+ use the results with caution and report any bugs!
>>> print(results) # doctest: +SKIP
>>> print(results.solver.status)
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/index.rst b/doc/OnlineDocs/contributed_packages/index.rst
index f893753780e..b1d9cbbad3b 100644
--- a/doc/OnlineDocs/contributed_packages/index.rst
+++ b/doc/OnlineDocs/contributed_packages/index.rst
@@ -20,6 +20,7 @@ Contributed packages distributed with Pyomo:
gdpopt.rst
iis.rst
incidence/index.rst
+ latex_printer.rst
mindtpy.rst
mpc/index.rst
multistart.rst
diff --git a/doc/OnlineDocs/contributed_packages/latex_printer.rst b/doc/OnlineDocs/contributed_packages/latex_printer.rst
new file mode 100644
index 00000000000..ff3f628c0c8
--- /dev/null
+++ b/doc/OnlineDocs/contributed_packages/latex_printer.rst
@@ -0,0 +1,127 @@
+Latex Printing
+==============
+
+Pyomo models can be printed to a LaTeX compatible format using the ``pyomo.contrib.latex_printer.latex_printer`` function:
+
+.. autofunction:: pyomo.contrib.latex_printer.latex_printer.latex_printer
+
+.. note::
+
+ If operating in a Jupyter Notebook, it may be helpful to use:
+
+ ``from IPython.display import display, Math``
+
+ ``display(Math(latex_printer(m))``
+
+Examples
+--------
+
+A Model
++++++++
+
+.. doctest::
+
+ >>> import pyomo.environ as pyo
+ >>> from pyomo.contrib.latex_printer import latex_printer
+
+ >>> m = pyo.ConcreteModel(name = 'basicFormulation')
+ >>> m.x = pyo.Var()
+ >>> m.y = pyo.Var()
+ >>> m.z = pyo.Var()
+ >>> m.c = pyo.Param(initialize=1.0, mutable=True)
+ >>> m.objective = pyo.Objective( expr = m.x + m.y + m.z )
+ >>> m.constraint_1 = pyo.Constraint(expr = m.x**2 + m.y**2.0 - m.z**2.0 <= m.c )
+
+ >>> pstr = latex_printer(m)
+
+
+A Constraint
+++++++++++++
+
+.. doctest::
+
+ >>> import pyomo.environ as pyo
+ >>> from pyomo.contrib.latex_printer import latex_printer
+
+ >>> m = pyo.ConcreteModel(name = 'basicFormulation')
+ >>> m.x = pyo.Var()
+ >>> m.y = pyo.Var()
+
+ >>> m.constraint_1 = pyo.Constraint(expr = m.x**2 + m.y**2 <= 1.0)
+
+ >>> pstr = latex_printer(m.constraint_1)
+
+A Constraint with Set Summation
++++++++++++++++++++++++++++++++
+
+.. doctest::
+
+ >>> import pyomo.environ as pyo
+ >>> from pyomo.contrib.latex_printer import latex_printer
+ >>> m = pyo.ConcreteModel(name='basicFormulation')
+ >>> m.I = pyo.Set(initialize=[1, 2, 3, 4, 5])
+ >>> m.v = pyo.Var(m.I)
+
+ >>> def ruleMaker(m): return sum(m.v[i] for i in m.I) <= 0
+
+ >>> m.constraint = pyo.Constraint(rule=ruleMaker)
+
+ >>> pstr = latex_printer(m.constraint)
+
+Using a ComponentMap to Specify Names
++++++++++++++++++++++++++++++++++++++
+
+.. doctest::
+
+ >>> import pyomo.environ as pyo
+ >>> from pyomo.contrib.latex_printer import latex_printer
+ >>> from pyomo.common.collections.component_map import ComponentMap
+
+ >>> m = pyo.ConcreteModel(name='basicFormulation')
+ >>> m.I = pyo.Set(initialize=[1, 2, 3, 4, 5])
+ >>> m.v = pyo.Var(m.I)
+
+ >>> def ruleMaker(m): return sum(m.v[i] for i in m.I) <= 0
+
+ >>> m.constraint = pyo.Constraint(rule=ruleMaker)
+
+ >>> lcm = ComponentMap()
+ >>> lcm[m.v] = 'x'
+ >>> lcm[m.I] = ['\\mathcal{A}',['j','k']]
+
+ >>> pstr = latex_printer(m.constraint, latex_component_map=lcm)
+
+
+An Expression
++++++++++++++
+
+.. doctest::
+
+ >>> import pyomo.environ as pyo
+ >>> from pyomo.contrib.latex_printer import latex_printer
+
+ >>> m = pyo.ConcreteModel(name = 'basicFormulation')
+ >>> m.x = pyo.Var()
+ >>> m.y = pyo.Var()
+
+ >>> m.expression_1 = pyo.Expression(expr = m.x**2 + m.y**2)
+
+ >>> pstr = latex_printer(m.expression_1)
+
+
+A Simple Expression
++++++++++++++++++++
+
+.. doctest::
+
+ >>> import pyomo.environ as pyo
+ >>> from pyomo.contrib.latex_printer import latex_printer
+
+ >>> m = pyo.ConcreteModel(name = 'basicFormulation')
+ >>> m.x = pyo.Var()
+ >>> m.y = pyo.Var()
+
+ >>> pstr = latex_printer(m.x + m.y)
+
+
+
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/pyros.rst b/doc/OnlineDocs/contributed_packages/pyros.rst
index 4ef57fbf26c..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,
... ]
@@ -538,12 +539,16 @@ correspond to first-stage degrees of freedom.
... solve_master_globally=True,
... load_solution=False,
... )
- ===========================================================================================
- PyROS: Pyomo Robust Optimization Solver ...
- ===========================================================================================
+ ==============================================================================
+ PyROS: The Pyomo Robust Optimization Solver...
...
- INFO: Robust optimal solution identified. Exiting PyROS.
-
+ ------------------------------------------------------------------------------
+ Robust optimal solution identified.
+ ------------------------------------------------------------------------------
+ ...
+ ------------------------------------------------------------------------------
+ All done. Exiting PyROS.
+ ==============================================================================
>>> # === Query results ===
>>> time = results_1.time
>>> iterations = results_1.iterations
@@ -604,6 +609,8 @@ optional keyword argument ``decision_rule_order`` to the PyROS
In this example, we select affine decision rules by setting
``decision_rule_order=1``:
+.. _example-two-stg:
+
.. doctest::
:skipif: not (baron.available() and baron.license_is_valid())
@@ -625,11 +632,16 @@ In this example, we select affine decision rules by setting
... solve_master_globally=True,
... decision_rule_order=1,
... )
- ===========================================================================================
- PyROS: Pyomo Robust Optimization Solver ...
+ ==============================================================================
+ PyROS: The Pyomo Robust Optimization Solver...
...
- INFO: Robust optimal solution identified. Exiting PyROS.
-
+ ------------------------------------------------------------------------------
+ Robust optimal solution identified.
+ ------------------------------------------------------------------------------
+ ...
+ ------------------------------------------------------------------------------
+ All done. Exiting PyROS.
+ ==============================================================================
>>> # === Compare final objective to the single-stage solution
>>> two_stage_final_objective = round(
... pyo.value(results_2.final_objective_value),
@@ -646,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,
@@ -712,11 +772,11 @@ For this example, we obtain the following price of robustness results:
+==========================================+==============================+=============================+
| 0.00 | 35,837,659.18 | 0.00 % |
+------------------------------------------+------------------------------+-----------------------------+
- | 0.10 | 36,135,191.59 | 0.82 % |
+ | 0.10 | 36,135,182.66 | 0.83 % |
+------------------------------------------+------------------------------+-----------------------------+
- | 0.20 | 36,437,979.81 | 1.64 % |
+ | 0.20 | 36,437,979.81 | 1.68 % |
+------------------------------------------+------------------------------+-----------------------------+
- | 0.30 | 43,478,190.92 | 17.57 % |
+ | 0.30 | 43,478,190.91 | 21.32 % |
+------------------------------------------+------------------------------+-----------------------------+
| 0.40 | ``robust_infeasible`` | :math:`\text{-----}` |
+------------------------------------------+------------------------------+-----------------------------+
@@ -733,7 +793,286 @@ set size on the robust optimal objective function value
and demonstrates the ease of implementing a price of robustness study
for a given optimization problem under uncertainty.
-.. note::
+PyROS Solver Log Output
+-------------------------------
+
+The PyROS solver log output is controlled through the optional
+``progress_logger`` argument, itself cast to
+a standard Python logger (:py:class:`logging.Logger`) object
+at the outset of a :meth:`~pyomo.contrib.pyros.PyROS.solve` call.
+The level of detail of the solver log output
+can be adjusted by adjusting the level of the
+logger object; see :ref:`the following table `.
+Note that by default, ``progress_logger`` is cast to a logger of level
+:py:obj:`logging.INFO`.
+
+We refer the reader to the
+:doc:`official Python logging library documentation `
+for customization of Python logger objects;
+for a basic tutorial, see the :doc:`logging HOWTO `.
+
+.. _table-logging-levels:
+
+.. list-table:: PyROS solver log output at the various standard Python :py:mod:`logging` levels.
+ :widths: 10 50
+ :header-rows: 1
+
+ * - Logging Level
+ - Output Messages
+ * - :py:obj:`logging.ERROR`
+ - * Information on the subproblem for which an exception was raised
+ by a subordinate solver
+ * Details about failure of the PyROS coefficient matching routine
+ * - :py:obj:`logging.WARNING`
+ - * Information about a subproblem not solved to an acceptable status
+ by the user-provided subordinate optimizers
+ * Invocation of a backup solver for a particular subproblem
+ * Caution about solution robustness guarantees in event that
+ user passes ``bypass_global_separation=True``
+ * - :py:obj:`logging.INFO`
+ - * PyROS version, author, and disclaimer information
+ * Summary of user options
+ * Breakdown of model component statistics
+ * Iteration log table
+ * Termination details: message, timing breakdown, summary of statistics
+ * - :py:obj:`logging.DEBUG`
+ - * Termination outcomes and summary of statistics for
+ every master feasility, master, and DR polishing problem
+ * Progress updates for the separation procedure
+ * Separation subproblem initial point infeasibilities
+ * Summary of separation loop outcomes: performance constraints
+ violated, uncertain parameter scenario added to the
+ master problem
+ * Uncertain parameter scenarios added to the master problem
+ thus far
+
+An example of an output log produced through the default PyROS
+progress logger is shown in
+:ref:`the snippet that follows `.
+Observe that the log contains the following information:
+
+
+* **Introductory information** (lines 1--18).
+ Includes the version number, author
+ information, (UTC) time at which the solver was invoked,
+ and, if available, information on the local Git branch and
+ commit hash.
+* **Summary of solver options** (lines 19--38).
+* **Preprocessing information** (lines 39--41).
+ Wall time required for preprocessing
+ the deterministic model and associated components,
+ i.e. standardizing model components and adding the decision rule
+ variables and equations.
+* **Model component statistics** (lines 42--58).
+ Breakdown of model component statistics.
+ Includes components added by PyROS, such as the decision rule variables
+ and equations.
+* **Iteration log table** (lines 59--69).
+ Summary information on the problem iterates and subproblem outcomes.
+ The constituent columns are defined in detail in
+ :ref:`the table following the snippet `.
+* **Termination message** (lines 70--71). Very brief summary of the termination outcome.
+* **Timing statistics** (lines 72--88).
+ Tabulated breakdown of the solver timing statistics, based on a
+ :class:`pyomo.common.timing.HierarchicalTimer` printout.
+ The identifiers are as follows:
+
+ * ``main``: Total time elapsed by the solver.
+ * ``main.dr_polishing``: Total time elapsed by the subordinate solvers
+ on polishing of the decision rules.
+ * ``main.global_separation``: Total time elapsed by the subordinate solvers
+ on global separation subproblems.
+ * ``main.local_separation``: Total time elapsed by the subordinate solvers
+ on local separation subproblems.
+ * ``main.master``: Total time elapsed by the subordinate solvers on
+ the master problems.
+ * ``main.master_feasibility``: Total time elapsed by the subordinate solvers
+ on the master feasibility problems.
+ * ``main.preprocessing``: Total preprocessing time.
+ * ``main.other``: Total overhead time.
+
+* **Termination statistics** (lines 89--94). Summary of statistics related to the
+ iterate at which PyROS terminates.
+* **Exit message** (lines 95--96).
+
+
+.. _solver-log-snippet:
+
+.. code-block:: text
+ :caption: PyROS solver output log for the :ref:`two-stage problem example `.
+ :linenos:
+
+ ==============================================================================
+ PyROS: The Pyomo Robust Optimization Solver, v1.2.11.
+ Pyomo version: 6.7.2
+ Commit hash: unknown
+ 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)
+ (1) Carnegie Mellon University, Department of Chemical Engineering
+ (2) Sandia National Laboratories, Center for Computing Research
+
+ The developers gratefully acknowledge support from the U.S. Department
+ of Energy's Institute for the Design of Advanced Energy Systems (IDAES).
+ ==============================================================================
+ ================================= DISCLAIMER =================================
+ PyROS is still under development.
+ Please provide feedback and/or report any issues by creating a ticket at
+ https://github.com/Pyomo/pyomo/issues/new/choose
+ ==============================================================================
+ Solver options:
+ time_limit=None
+ 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
+ solve_master_globally=True
+ max_iter=-1
+ robust_feasibility_tolerance=0.0001
+ separation_priority_order={}
+ progress_logger=
+ backup_local_solvers=[]
+ backup_global_solvers=[]
+ subproblem_file_directory=None
+ bypass_local_separation=False
+ bypass_global_separation=False
+ p_robustness={}
+ ------------------------------------------------------------------------------
+ Preprocessing...
+ Done preprocessing; required wall time of 0.175s.
+ ------------------------------------------------------------------------------
+ Model statistics:
+ Number of variables : 62
+ Epigraph variable : 1
+ First-stage variables : 7
+ Second-stage variables : 6
+ State variables : 18
+ Decision rule variables : 30
+ Number of uncertain parameters : 4
+ Number of constraints : 81
+ Equality constraints : 24
+ Coefficient matching constraints : 0
+ Decision rule equations : 6
+ All other equality constraints : 18
+ Inequality constraints : 57
+ First-stage inequalities (incl. certain var bounds) : 10
+ Performance constraints (incl. var bounds) : 47
+ ------------------------------------------------------------------------------
+ Itn Objective 1-Stg Shift 2-Stg Shift #CViol Max Viol Wall Time (s)
+ ------------------------------------------------------------------------------
+ 0 3.5838e+07 - - 5 1.8832e+04 1.741
+ 1 3.5838e+07 3.5184e-15 3.9404e-15 10 4.2516e+06 3.766
+ 2 3.5993e+07 1.8105e-01 7.1406e-01 13 5.2004e+06 6.288
+ 3 3.6285e+07 5.1968e-01 7.7753e-01 4 1.7892e+04 8.247
+ 4 3.6285e+07 9.1166e-13 1.9702e-15 0 7.1157e-10g 11.456
+ ------------------------------------------------------------------------------
+ Robust optimal solution identified.
+ ------------------------------------------------------------------------------
+ Timing breakdown:
+
+ Identifier ncalls cumtime percall %
+ -----------------------------------------------------------
+ main 1 11.457 11.457 100.0
+ ------------------------------------------------------
+ dr_polishing 4 0.682 0.171 6.0
+ global_separation 47 1.109 0.024 9.7
+ local_separation 235 5.810 0.025 50.7
+ master 5 1.353 0.271 11.8
+ master_feasibility 4 0.247 0.062 2.2
+ preprocessing 1 0.429 0.429 3.7
+ other n/a 1.828 n/a 16.0
+ ======================================================
+ ===========================================================
+
+ ------------------------------------------------------------------------------
+ Termination stats:
+ Iterations : 5
+ Solve time (wall s) : 11.457
+ Final objective value : 3.6285e+07
+ Termination condition : pyrosTerminationCondition.robust_optimal
+ ------------------------------------------------------------------------------
+ All done. Exiting PyROS.
+ ==============================================================================
+
+
+The iteration log table is designed to provide, in a concise manner,
+important information about the progress of the iterative algorithm for
+the problem of interest.
+The constituent columns are defined in the
+:ref:`table that follows `.
+
+.. _table-iteration-log-columns:
+
+.. list-table:: PyROS iteration log table columns.
+ :widths: 10 50
+ :header-rows: 1
- Please provide feedback and/or report any problems by opening an issue on
- the `Pyomo GitHub page `_.
+ * - Column Name
+ - Definition
+ * - Itn
+ - Iteration number.
+ * - Objective
+ - Master solution objective function value.
+ If the objective of the deterministic model provided
+ has a maximization sense,
+ then the negative of the objective function value is displayed.
+ Expect this value to trend upward as the iteration number
+ increases.
+ If the master problems are solved globally
+ (by passing ``solve_master_globally=True``),
+ then after the iteration number exceeds the number of uncertain parameters,
+ this value should be monotonically nondecreasing
+ as the iteration number is increased.
+ A dash ("-") is produced in lieu of a value if the master
+ problem of the current iteration is not solved successfully.
+ * - 1-Stg Shift
+ - Infinity norm of the relative difference between the first-stage
+ variable vectors of the master solutions of the current
+ and previous iterations. Expect this value to trend
+ downward as the iteration number increases.
+ A dash ("-") is produced in lieu of a value
+ if the current iteration number is 0,
+ there are no first-stage variables,
+ or the master problem of the current iteration is not solved successfully.
+ * - 2-Stg Shift
+ - Infinity norm of the relative difference between the second-stage
+ variable vectors (evaluated subject to the nominal uncertain
+ parameter realization) of the master solutions of the current
+ and previous iterations. Expect this value to trend
+ downward as the iteration number increases.
+ A dash ("-") is produced in lieu of a value
+ if the current iteration number is 0,
+ there are no second-stage variables,
+ or the master problem of the current iteration is not solved successfully.
+ * - #CViol
+ - Number of performance constraints found to be violated during
+ the separation step of the current iteration.
+ Unless a custom prioritization of the model's performance constraints
+ is specified (through the ``separation_priority_order`` argument),
+ expect this number to trend downward as the iteration number increases.
+ A "+" is appended if not all of the separation problems
+ were solved successfully, either due to custom prioritization, a time out,
+ or an issue encountered by the subordinate optimizers.
+ A dash ("-") is produced in lieu of a value if the separation
+ routine is not invoked during the current iteration.
+ * - Max Viol
+ - Maximum scaled performance constraint violation.
+ Expect this value to trend downward as the iteration number increases.
+ A 'g' is appended to the value if the separation problems were solved
+ globally during the current iteration.
+ A dash ("-") is produced in lieu of a value if the separation
+ routine is not invoked during the current iteration, or if there are
+ no performance constraints.
+ * - Wall time (s)
+ - Total time elapsed by the solver, in seconds, up to the end of the
+ current iteration.
+
+
+Feedback and Reporting Issues
+-------------------------------
+Please provide feedback and/or report any problems by opening an issue on
+the `Pyomo GitHub page `_.
diff --git a/doc/OnlineDocs/contribution_guide.rst b/doc/OnlineDocs/contribution_guide.rst
index 10670627546..b98dcc3d014 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
++++++++++++++++++++++
diff --git a/doc/OnlineDocs/developer_reference/expressions/design.rst b/doc/OnlineDocs/developer_reference/expressions/design.rst
index 9a6d5b9412f..ddecb39ad0c 100644
--- a/doc/OnlineDocs/developer_reference/expressions/design.rst
+++ b/doc/OnlineDocs/developer_reference/expressions/design.rst
@@ -73,7 +73,7 @@ Expression trees can be categorized in four different ways:
These three categories are illustrated with the following example:
-.. literalinclude:: ../../tests/expr/design_categories.spy
+.. literalinclude:: ../../src/expr/design_categories.spy
The following table describes four different simple expressions
that consist of a single model component, and it shows how they
@@ -107,7 +107,7 @@ Named expressions allow for changes to an expression after it has
been constructed. For example, consider the expression ``f`` defined
with the :class:`Expression ` component:
-.. literalinclude:: ../../tests/expr/design_named_expression.spy
+.. literalinclude:: ../../src/expr/design_named_expression.spy
Although ``f`` is an immutable expression, whose definition is
fixed, a sub-expressions is the named expression ``M.e``. Named
@@ -227,7 +227,7 @@ The :data:`linear_expression `
object is a context manager that can be used to declare a linear sum. For
example, consider the following two loops:
-.. literalinclude:: ../../tests/expr/design_cm1.spy
+.. literalinclude:: ../../src/expr/design_cm1.spy
The first apparent difference in these loops is that the value of
``s`` is explicitly initialized while ``e`` is initialized when the
@@ -250,7 +250,7 @@ construct different expressions with different context declarations.
Finally, note that these context managers can be passed into the :attr:`start`
method for the :func:`quicksum ` function. For example:
-.. literalinclude:: ../../tests/expr/design_cm2.spy
+.. literalinclude:: ../../src/expr/design_cm2.spy
This sum contains terms for ``M.x[i]`` and ``M.y[i]``. The syntax
in this example is not intuitive because the sum is being stored
diff --git a/doc/OnlineDocs/developer_reference/expressions/index.rst b/doc/OnlineDocs/developer_reference/expressions/index.rst
index 769639d50eb..685fde25173 100644
--- a/doc/OnlineDocs/developer_reference/expressions/index.rst
+++ b/doc/OnlineDocs/developer_reference/expressions/index.rst
@@ -21,7 +21,7 @@ nodes contain operators. Pyomo relies on so-called magic methods
to automate the construction of symbolic expressions. For example,
consider an expression ``e`` declared as follows:
-.. literalinclude:: ../../tests/expr/index_simple.spy
+.. literalinclude:: ../../src/expr/index_simple.spy
Python determines that the magic method ``__mul__`` is called on
the ``M.v`` object, with the argument ``2``. This method returns
diff --git a/doc/OnlineDocs/developer_reference/expressions/managing.rst b/doc/OnlineDocs/developer_reference/expressions/managing.rst
index db045e55b6c..a4dd2a51436 100644
--- a/doc/OnlineDocs/developer_reference/expressions/managing.rst
+++ b/doc/OnlineDocs/developer_reference/expressions/managing.rst
@@ -23,19 +23,21 @@ mimics the Python operations used to construct an expression. The
:data:`verbose` flag can be set to :const:`True` to generate a
string representation that is a nested functional form. For example:
-.. literalinclude:: ../../tests/expr/managing_ex1.spy
+.. literalinclude:: ../../src/expr/managing_ex1.spy
Labeler and Symbol Map
~~~~~~~~~~~~~~~~~~~~~~
-The string representation used for variables in expression can be customized to
-define different label formats. If the :data:`labeler` option is specified, then this
-function (or class functor) is used to generate a string label used to represent the variable. Pyomo
-defines a variety of labelers in the `pyomo.core.base.label` module. For example, the
-:class:`NumericLabeler` defines a functor that can be used to sequentially generate
-simple labels with a prefix followed by the variable count:
+The string representation used for variables in expression can be
+customized to define different label formats. If the :data:`labeler`
+option is specified, then this function (or class functor) is used to
+generate a string label used to represent the variable. Pyomo defines a
+variety of labelers in the `pyomo.core.base.label` module. For example,
+the :class:`NumericLabeler` defines a functor that can be used to
+sequentially generate simple labels with a prefix followed by the
+variable count:
-.. literalinclude:: ../../tests/expr/managing_ex2.spy
+.. literalinclude:: ../../src/expr/managing_ex2.spy
The :data:`smap` option is used to specify a symbol map object
(:class:`SymbolMap `), which
@@ -46,60 +48,22 @@ variables in different expressions have a consistent label in their
associated string representations.
-Standardized String Representations
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The :data:`standardize` option can be used to re-order the string
-representation to print polynomial terms before nonlinear terms. By
-default, :data:`standardize` is :const:`False`, and the string
-representation reflects the order in which terms were combined to
-form the expression. Pyomo does not guarantee that the string
-representation exactly matches the Python expression order, since
-some simplification and re-ordering of terms is done automatically to
-improve the efficiency of expression generation. But in most cases
-the string representation will closely correspond to the
-Python expression order.
-
-If :data:`standardize` is :const:`True`, then the pyomo expression
-is processed to identify polynomial terms, and the string representation
-consists of the constant and linear terms followed by
-an expression that contains other nonlinear terms. For example:
-
-.. literalinclude:: ../../tests/expr/managing_ex3.spy
-
Other Ways to Generate String Representations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are two other standard ways to generate string representations:
-* Call the :func:`__str__` magic method (e.g. using the Python :func:`str()` function. This
- calls :func:`expression_to_string ` with
- the option :data:`standardize` equal to :const:`True` (see below).
-
-* Call the :func:`to_string` method on the :class:`ExpressionBase ` class.
- This defaults to calling :func:`expression_to_string ` with
- the option :data:`standardize` equal to :const:`False` (see below).
+* Call the :func:`__str__` magic method (e.g. using the Python
+ :func:`str()` function. This calls :func:`expression_to_string
+ `, using the default values for
+ all arguments.
-In practice, we expect at the :func:`__str__` magic method will be
-used by most users, and the standardization of the output provides
-a consistent ordering of terms that should make it easier to interpret
-expressions.
+* Call the :func:`to_string` method on the
+ :class:`ExpressionBase` class. This
+ calls :func:`expression_to_string
+ ` and accepts the same arguments.
-Cloning Expressions
--------------------
-
-Expressions are automatically cloned only during certain expression
-transformations. Since this can be an expensive operation, the
-:data:`clone_counter ` context
-manager object is provided to track the number of times the
-:func:`clone_expression `
-function is executed.
-
-For example:
-
-.. literalinclude:: ../../tests/expr/managing_ex4.spy
-
Evaluating Expressions
----------------------
@@ -108,21 +72,21 @@ the expression have a value. The :func:`value `
function can be used to walk the expression tree and compute the
value of an expression. For example:
-.. literalinclude:: ../../tests/expr/managing_ex5.spy
+.. literalinclude:: ../../src/expr/managing_ex5.spy
Additionally, expressions define the :func:`__call__` method, so the
following is another way to compute the value of an expression:
-.. literalinclude:: ../../tests/expr/managing_ex6.spy
+.. literalinclude:: ../../src/expr/managing_ex6.spy
If a parameter or variable is undefined, then the :func:`value
` function and :func:`__call__` method will
raise an exception. This exception can be suppressed using the
:attr:`exception` option. For example:
-.. literalinclude:: ../../tests/expr/managing_ex7.spy
+.. literalinclude:: ../../src/expr/managing_ex7.spy
-This option is useful in contexts where adding a try block is inconvenient
+This option is useful in contexts where adding a try block is inconvenient
in your modeling script.
.. note::
@@ -141,10 +105,10 @@ Expression transformations sometimes need to find all nodes in an
expression tree that are of a given type. Pyomo contains two utility
functions that support this functionality. First, the
:func:`identify_components `
-function is a generator function that walks the expression tree and yields all
+function is a generator function that walks the expression tree and yields all
nodes whose type is in a specified set of node types. For example:
-.. literalinclude:: ../../tests/expr/managing_ex8.spy
+.. literalinclude:: ../../src/expr/managing_ex8.spy
The :func:`identify_variables `
function is a generator function that yields all nodes that are
@@ -153,7 +117,7 @@ but this set of variable types does not need to be specified by the user.
However, the :attr:`include_fixed` flag can be specified to omit fixed
variables. For example:
-.. literalinclude:: ../../tests/expr/managing_ex9.spy
+.. literalinclude:: ../../src/expr/managing_ex9.spy
Walking an Expression Tree with a Visitor Class
-----------------------------------------------
@@ -166,8 +130,15 @@ is computed using the values of its children.
Walking an expression tree can be tricky, and the code requires intimate
knowledge of the design of the expression system. Pyomo includes
-several classes that define so-called visitor patterns for walking
-expression tree:
+several classes that define visitor patterns for walking expression
+tree:
+
+:class:`StreamBasedExpressionVisitor `
+ The most general and extensible visitor class. This visitor
+ implements an event-based approach for walking the tree inspired by
+ the ``expat`` library for processing XML files. The visitor has
+ seven event callbacks that users can hook into, providing very
+ fine-grained control over the expression walker.
:class:`SimpleExpressionVisitor `
A :func:`visitor` method is called for each node in the tree,
@@ -187,33 +158,39 @@ expression tree:
These classes define a variety of suitable tree search methods:
-* :class:`SimpleExpressionVisitor `
+* :class:`StreamBasedExpressionVisitor `
- * **xbfs**: breadth-first search where leaf nodes are immediately visited
- * **xbfs_yield_leaves**: breadth-first search where leaf nodes are immediately visited, and the visit method yields a value
+ * ``walk_expression``: depth-first traversal of the expression tree.
-* :class:`ExpressionValueVisitor `
+* :class:`ExpressionReplacementVisitor `
- * **dfs_postorder_stack**: postorder depth-first search using a stack
+ * ``walk_expression``: depth-first traversal of the expression tree.
-* :class:`ExpressionReplacementVisitor `
+* :class:`SimpleExpressionVisitor `
- * **dfs_postorder_stack**: postorder depth-first search using a stack
+ * ``xbfs``: breadth-first search where leaf nodes are immediately visited
+ * ``xbfs_yield_leaves``: breadth-first search where leaf nodes are
+ immediately visited, and the visit method yields a value
-.. note::
+* :class:`ExpressionValueVisitor `
- The PyUtilib visitor classes define several other search methods
- that could be used with Pyomo expressions. But these are the
- only search methods currently used within Pyomo.
+ * ``dfs_postorder_stack``: postorder depth-first search using a
+ nonrecursive stack
-To implement a visitor object, a user creates a subclass of one of these
-classes. Only one of a few methods will need to be defined to
-implement the visitor:
+
+To implement a visitor object, a user needs to provide specializations
+for specific events. For legacy visitors based on the PyUtilib
+visitor pattern (e.g., :class:`SimpleExpressionVisitor` and
+:class:`ExpressionValueVisitor`), one must create a subclass of one of these
+classes and override at least one of the following:
:func:`visitor`
Defines the operation that is performed when a node is visited. In
- the :class:`ExpressionValueVisitor ` and :class:`ExpressionReplacementVisitor ` visitor classes, this
- method returns a value that is used by its parent node.
+ the :class:`ExpressionValueVisitor
+ ` and
+ :class:`ExpressionReplacementVisitor
+ ` visitor classes,
+ this method returns a value that is used by its parent node.
:func:`visiting_potential_leaf`
Checks if the search should terminate with this node. If no,
@@ -225,9 +202,17 @@ implement the visitor:
class.
:func:`finalize`
- This method defines the final value that is returned from the
+ This method defines the final value that is returned from the
visitor. This is not normally redefined.
+For modern visitors based on the :class:`StreamBasedExpressionVisitor
+`, one can either define a
+subclass, pass the callbacks to an instance of the base class, or assign
+the callbacks as attributes on an instance of the base class. The
+:class:`StreamBasedExpressionVisitor
+` provides seven
+callbacks, which are documented in the class documentation.
+
Detailed documentation of the APIs for these methods is provided
with the class documentation for these visitors.
@@ -238,14 +223,14 @@ In this example, we describe an visitor class that counts the number
of nodes in an expression (including leaf nodes). Consider the following
class:
-.. literalinclude:: ../../tests/expr/managing_visitor1.spy
+.. literalinclude:: ../../src/expr/managing_visitor1.spy
-The class constructor creates a counter, and the :func:`visit` method
+The class constructor creates a counter, and the :func:`visit` method
increments this counter for every node that is visited. The :func:`finalize`
method returns the value of this counter after the tree has been walked. The
following function illustrates this use of this visitor class:
-.. literalinclude:: ../../tests/expr/managing_visitor2.spy
+.. literalinclude:: ../../src/expr/managing_visitor2.spy
ExpressionValueVisitor Example
@@ -255,14 +240,14 @@ In this example, we describe an visitor class that clones the
expression tree (including leaf nodes). Consider the following
class:
-.. literalinclude:: ../../tests/expr/managing_visitor3.spy
+.. literalinclude:: ../../src/expr/managing_visitor3.spy
The :func:`visit` method creates a new expression node with children
specified by :attr:`values`. The :func:`visiting_potential_leaf`
method performs a :func:`deepcopy` on leaf nodes, which are native
Python types or non-expression objects.
-.. literalinclude:: ../../tests/expr/managing_visitor4.spy
+.. literalinclude:: ../../src/expr/managing_visitor4.spy
ExpressionReplacementVisitor Example
@@ -273,18 +258,15 @@ variables with scaled variables, using a mutable parameter that
can be modified later. the following
class:
-.. literalinclude:: ../../tests/expr/managing_visitor5.spy
+.. literalinclude:: ../../src/expr/managing_visitor5.spy
-No :func:`visit` method needs to be defined. The
-:func:`visiting_potential_leaf` function identifies variable nodes
+No other method need to be defined. The
+:func:`beforeChild` method identifies variable nodes
and returns a product expression that contains a mutable parameter.
-The :class:`_LinearExpression` class has a different representation
-that embeds variables. Hence, this class must be handled
-in a separate condition that explicitly transforms this sub-expression.
-.. literalinclude:: ../../tests/expr/managing_visitor6.spy
+.. literalinclude:: ../../src/expr/managing_visitor6.spy
-The :func:`scale_expression` function is called with an expression and
+The :func:`scale_expression` function is called with an expression and
a dictionary, :attr:`scale`, that maps variable ID to model parameter. For example:
-.. literalinclude:: ../../tests/expr/managing_visitor7.spy
+.. literalinclude:: ../../src/expr/managing_visitor7.spy
diff --git a/doc/OnlineDocs/developer_reference/expressions/overview.rst b/doc/OnlineDocs/developer_reference/expressions/overview.rst
index 58808a813f1..c1962edec22 100644
--- a/doc/OnlineDocs/developer_reference/expressions/overview.rst
+++ b/doc/OnlineDocs/developer_reference/expressions/overview.rst
@@ -50,13 +50,13 @@ are:
example, the following two loops had dramatically different
runtime:
- .. literalinclude:: ../../tests/expr/overview_example1.spy
+ .. literalinclude:: ../../src/expr/overview_example1.spy
* Coopr3 eliminates side effects by automatically cloning sub-expressions.
Unfortunately, this can easily lead to unexpected cloning in models, which
can dramatically slow down Pyomo model generation. For example:
- .. literalinclude:: ../../tests/expr/overview_example2.spy
+ .. literalinclude:: ../../src/expr/overview_example2.spy
* Coopr3 leverages recursion in many operations, including expression
cloning. Even simple non-linear expressions can result in deep
@@ -82,7 +82,7 @@ control for how expressions are managed in Python. For example:
* Python variables can point to the same expression tree
- .. literalinclude:: ../../tests/expr/overview_tree1.spy
+ .. literalinclude:: ../../src/expr/overview_tree1.spy
This is illustrated as follows:
@@ -102,7 +102,7 @@ control for how expressions are managed in Python. For example:
* A variable can point to a sub-tree that another variable points to
- .. literalinclude:: ../../tests/expr/overview_tree2.spy
+ .. literalinclude:: ../../src/expr/overview_tree2.spy
This is illustrated as follows:
@@ -124,7 +124,7 @@ control for how expressions are managed in Python. For example:
* Two expression trees can point to the same sub-tree
- .. literalinclude:: ../../tests/expr/overview_tree3.spy
+ .. literalinclude:: ../../src/expr/overview_tree3.spy
This is illustrated as follows:
@@ -169,7 +169,7 @@ between expressions, we do not consider those expressions entangled.
Expression entanglement is problematic because shared expressions complicate
the expected behavior when sub-expressions are changed. Consider the following example:
-.. literalinclude:: ../../tests/expr/overview_tree4.spy
+.. literalinclude:: ../../src/expr/overview_tree4.spy
What is the value of ``e`` after ``M.w`` is added to it? What is the
value of ``f``? The answers to these questions are not immediately
@@ -244,7 +244,7 @@ There is one important exception to the entanglement property
described above. The ``Expression`` component is treated as a
mutable expression when shared between expressions. For example:
-.. literalinclude:: ../../tests/expr/overview_tree5.spy
+.. literalinclude:: ../../src/expr/overview_tree5.spy
Here, the expression ``M.e`` is a so-called *named expression* that
the user has declared. Named expressions are explicitly intended
diff --git a/doc/OnlineDocs/developer_reference/expressions/performance.rst b/doc/OnlineDocs/developer_reference/expressions/performance.rst
index 4b2c691b729..8e344e50982 100644
--- a/doc/OnlineDocs/developer_reference/expressions/performance.rst
+++ b/doc/OnlineDocs/developer_reference/expressions/performance.rst
@@ -11,14 +11,14 @@ Expression Generation
Pyomo expressions can be constructed using native binary operators
in Python. For example, a sum can be created in a simple loop:
-.. literalinclude:: ../../tests/expr/performance_loop1.spy
+.. literalinclude:: ../../src/expr/performance_loop1.spy
Additionally, Pyomo expressions can be constructed using functions
that iteratively apply Python binary operators. For example, the
Python :func:`sum` function can be used to replace the previous
loop:
-.. literalinclude:: ../../tests/expr/performance_loop2.spy
+.. literalinclude:: ../../src/expr/performance_loop2.spy
The :func:`sum` function is both more compact and more efficient.
Using :func:`sum` avoids the creation of temporary variables, and
@@ -47,7 +47,7 @@ expressions.
For example, consider the following quadratic polynomial:
-.. literalinclude:: ../../tests/expr/performance_loop3.spy
+.. literalinclude:: ../../src/expr/performance_loop3.spy
This quadratic polynomial is treated as a nonlinear expression
unless the expression is explicitly processed to identify quadratic
@@ -78,7 +78,7 @@ The :func:`prod ` function is analogous to the builtin
argument list, :attr:`args`, which represents expressions that are multiplied
together. For example:
-.. literalinclude:: ../../tests/expr/performance_prod.spy
+.. literalinclude:: ../../src/expr/performance_prod.spy
quicksum
~~~~~~~~
@@ -89,7 +89,7 @@ generates a more compact Pyomo expression. Its main argument is a
variable length argument list, :attr:`args`, which represents
expressions that are summed together. For example:
-.. literalinclude:: ../../tests/expr/performance_quicksum.spy
+.. literalinclude:: ../../src/expr/performance_quicksum.spy
The summation is customized based on the :attr:`start` and
:attr:`linear` arguments. The :attr:`start` defines the initial
@@ -111,13 +111,13 @@ more quickly.
Consider the following example:
-.. literalinclude:: ../../tests/expr/quicksum_runtime.spy
+.. literalinclude:: ../../src/expr/quicksum_runtime.spy
The sum consists of linear terms because the exponents are one.
The following output illustrates that quicksum can identify this
linear structure to generate expressions more quickly:
-.. literalinclude:: ../../tests/expr/quicksum.log
+.. literalinclude:: ../../src/expr/quicksum.log
:language: none
If :attr:`start` is not a numeric value, then the :func:`quicksum
@@ -134,7 +134,7 @@ to be stored in an object that is passed into the function (e.g. the linear cont
term in :attr:`args` is misleading. Consider the following
example:
- .. literalinclude:: ../../tests/expr/performance_warning.spy
+ .. literalinclude:: ../../src/expr/performance_warning.spy
The first term created by the generator is linear, but the
subsequent terms are nonlinear. Pyomo gracefully transitions
@@ -153,12 +153,12 @@ calling :func:`quicksum `. If two or more components
provided, then the result is the summation of their terms multiplied
together. For example:
-.. literalinclude:: ../../tests/expr/performance_sum_product1.spy
+.. literalinclude:: ../../src/expr/performance_sum_product1.spy
The :attr:`denom` argument specifies components whose terms are in
the denominator. For example:
-.. literalinclude:: ../../tests/expr/performance_sum_product2.spy
+.. literalinclude:: ../../src/expr/performance_sum_product2.spy
The terms summed by this function are explicitly specified, so
:func:`sum_product ` can identify
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 323d7be1632..83cd08e7a4a 100644
--- a/doc/OnlineDocs/installation.rst
+++ b/doc/OnlineDocs/installation.rst
@@ -3,7 +3,7 @@ Installation
Pyomo currently supports the following versions of Python:
-* CPython: 3.8, 3.9, 3.10, 3.11
+* CPython: 3.8, 3.9, 3.10, 3.11, 3.12
* PyPy: 3
At the time of the first Pyomo release after the end-of-life of a minor Python
@@ -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 521334aef16..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.clone_counter
- :members:
-
diff --git a/doc/OnlineDocs/library_reference/expressions/visitors.rst b/doc/OnlineDocs/library_reference/expressions/visitors.rst
index f91107a6e8d..77cffe7905f 100644
--- a/doc/OnlineDocs/library_reference/expressions/visitors.rst
+++ b/doc/OnlineDocs/library_reference/expressions/visitors.rst
@@ -2,10 +2,19 @@
Visitor Classes
===============
+.. autoclass:: pyomo.core.expr.StreamBasedExpressionVisitor
+ :members:
+ :inherited-members:
+
.. autoclass:: pyomo.core.expr.SimpleExpressionVisitor
:members:
+ :inherited-members:
+
.. autoclass:: pyomo.core.expr.ExpressionValueVisitor
:members:
+ :inherited-members:
+
.. autoclass:: pyomo.core.expr.ExpressionReplacementVisitor
:members:
+ :inherited-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 3d8449a191d..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
@@ -37,7 +48,7 @@ def connect_v_out(self, v_out):
# @kernel
-print(_fmt(pympler.asizeof.asizeof(Transformer())))
+print("Memory:", _fmt(pympler.asizeof.asizeof(Transformer())))
# @aml
@@ -52,4 +63,4 @@ def Transformer():
# @aml
-print(_fmt(pympler.asizeof.asizeof(Transformer())))
+print("Memory:", _fmt(pympler.asizeof.asizeof(Transformer())))
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/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/pyomo_modeling_components/Constraints.rst b/doc/OnlineDocs/pyomo_modeling_components/Constraints.rst
index a79d380dcab..0cc42cb2abe 100644
--- a/doc/OnlineDocs/pyomo_modeling_components/Constraints.rst
+++ b/doc/OnlineDocs/pyomo_modeling_components/Constraints.rst
@@ -6,7 +6,7 @@ that are created using a rule, which is a Python function. For example,
if the variable ``model.x`` has the indexes 'butter' and 'scones', then
this constraint limits the sum over these indexes to be exactly three:
-.. literalinclude:: ../tests/scripting/spy4Constraints_Constraint_example.spy
+.. literalinclude:: ../src/scripting/spy4Constraints_Constraint_example.spy
:language: python
Instead of expressions involving equality (==) or inequalities (`<=` or
@@ -16,7 +16,7 @@ lb `<=` expr `<=` ub. Variables can appear only in the middle expr. For
example, the following two constraint declarations have the same
meaning:
-.. literalinclude:: ../tests/scripting/spy4Constraints_Inequality_constraints_2expressions.spy
+.. literalinclude:: ../src/scripting/spy4Constraints_Inequality_constraints_2expressions.spy
:language: python
For this simple example, it would also be possible to declare
@@ -30,7 +30,7 @@ interpreted as placing a budget of :math:`i` on the
:math:`i^{\mbox{th}}` item to buy where the cost per item is given by
the parameter ``model.a``:
-.. literalinclude:: ../tests/scripting/spy4Constraints_Passing_elements_crossproduct.spy
+.. literalinclude:: ../src/scripting/spy4Constraints_Passing_elements_crossproduct.spy
:language: python
.. note::
diff --git a/doc/OnlineDocs/pyomo_modeling_components/Expressions.rst b/doc/OnlineDocs/pyomo_modeling_components/Expressions.rst
index f0558621316..16c206e2fe8 100644
--- a/doc/OnlineDocs/pyomo_modeling_components/Expressions.rst
+++ b/doc/OnlineDocs/pyomo_modeling_components/Expressions.rst
@@ -20,7 +20,7 @@ possible to build up expressions. The following example illustrates
this, along with a reference to global Python data in the form of a
Python variable called ``switch``:
-.. literalinclude:: ../tests/scripting/spy4Expressions_Buildup_expression_switch.spy
+.. literalinclude:: ../src/scripting/spy4Expressions_Buildup_expression_switch.spy
:language: python
In this example, the constraint that is generated depends on the value
@@ -33,7 +33,7 @@ otherwise, the ``model.d`` term is not present.
Because model elements result in expressions, not values, the
following does not work as expected in an abstract model!
- .. literalinclude:: ../tests/scripting/spy4Expressions_Abstract_wrong_usage.spy
+ .. literalinclude:: ../src/scripting/spy4Expressions_Abstract_wrong_usage.spy
:language: python
The trouble is that ``model.d >= 2`` results in an expression, not
@@ -58,7 +58,7 @@ as described in the paper [Vielma_et_al]_.
There are two basic forms for the declaration of the constraint:
-.. literalinclude:: ../tests/scripting/spy4Expressions_Declare_piecewise_constraints.spy
+.. literalinclude:: ../src/scripting/spy4Expressions_Declare_piecewise_constraints.spy
:language: python
where ``pwconst`` can be replaced by a name appropriate for the
@@ -124,7 +124,7 @@ Keywords:
indexing set is used or when all indices use an identical piecewise
function). Examples:
- .. literalinclude:: ../tests/scripting/spy4Expressions_f_rule_Function_examples.spy
+ .. literalinclude:: ../src/scripting/spy4Expressions_f_rule_Function_examples.spy
:language: python
* **force_pw=True/False**
@@ -163,7 +163,7 @@ Keywords:
Here is an example of an assignment to a Python dictionary variable that
has keywords for a picewise constraint:
-.. literalinclude:: ../tests/scripting/spy4Expressions_Keyword_assignment_example.spy
+.. literalinclude:: ../src/scripting/spy4Expressions_Keyword_assignment_example.spy
:language: python
Here is a simple example based on the example given earlier in
@@ -175,7 +175,7 @@ whimsically just to make the example. The important thing to note is
that variables that are going to appear as the independent variable in a
piecewise constraint must have bounds.
-.. literalinclude:: ../tests/scripting/abstract2piece.py
+.. literalinclude:: ../src/scripting/abstract2piece.py
:language: python
A more advanced example is provided in abstract2piecebuild.py in
@@ -193,13 +193,13 @@ variable x times the index. Later in the model file, just to illustrate
how to do it, the expression is changed but just for the first index to
be x squared.
-.. literalinclude:: ../tests/scripting/spy4Expressions_Expression_objects_illustration.spy
+.. literalinclude:: ../src/scripting/spy4Expressions_Expression_objects_illustration.spy
:language: python
An alternative is to create Python functions that, potentially,
manipulate model objects. E.g., if you define a function
-.. literalinclude:: ../tests/scripting/spy4Expressions_Define_python_function.spy
+.. literalinclude:: ../src/scripting/spy4Expressions_Define_python_function.spy
:language: python
You can call this function with or without Pyomo modeling components as
@@ -211,7 +211,7 @@ expression is used to generate another expression (e.g., f(model.x, 3) +
5), the initial expression is always cloned so that the new generated
expression is independent of the old. For example:
-.. literalinclude:: ../tests/scripting/spy4Expressions_Generate_new_expression.spy
+.. literalinclude:: ../src/scripting/spy4Expressions_Generate_new_expression.spy
:language: python
If you want to create an expression that is shared between other
diff --git a/doc/OnlineDocs/pyomo_modeling_components/Sets.rst b/doc/OnlineDocs/pyomo_modeling_components/Sets.rst
index f9a692fcb10..73c3539d79d 100644
--- a/doc/OnlineDocs/pyomo_modeling_components/Sets.rst
+++ b/doc/OnlineDocs/pyomo_modeling_components/Sets.rst
@@ -443,13 +443,13 @@ model is:
for this model, a toy data file (in AMPL "``.dat``" format) would be:
-.. literalinclude:: ../tests/scripting/Isinglecomm.dat
+.. literalinclude:: ../src/scripting/Isinglecomm.dat
:language: text
.. doctest::
:hide:
- >>> inst = model.create_instance('tests/scripting/Isinglecomm.dat')
+ >>> inst = model.create_instance('src/scripting/Isinglecomm.dat')
This can also be done somewhat more efficiently, and perhaps more clearly,
using a :class:`BuildAction` (for more information, see :ref:`BuildAction`):
diff --git a/doc/OnlineDocs/pyomo_modeling_components/Variables.rst b/doc/OnlineDocs/pyomo_modeling_components/Variables.rst
index 038f5769705..7f7ee74af5f 100644
--- a/doc/OnlineDocs/pyomo_modeling_components/Variables.rst
+++ b/doc/OnlineDocs/pyomo_modeling_components/Variables.rst
@@ -20,13 +20,13 @@ declaring a *singleton* (i.e. unindexed) variable named
``model.LumberJack`` that will take on real values between zero and 6
and it initialized to be 1.5:
-.. literalinclude:: ../tests/scripting/spy4Variables_Declare_singleton_variable.spy
+.. literalinclude:: ../src/scripting/spy4Variables_Declare_singleton_variable.spy
:language: python
Instead of the ``initialize`` option, initialization is sometimes done
with a Python assignment statement as in
-.. literalinclude:: ../tests/scripting/spy4Variables_Assign_value.spy
+.. literalinclude:: ../src/scripting/spy4Variables_Assign_value.spy
:language: python
For indexed variables, bounds and initial values are often specified by
@@ -36,7 +36,7 @@ followed by the indexes. This is illustrated in the following code
snippet that makes use of Python dictionaries declared as lb and ub that
are used by a function to provide bounds:
-.. literalinclude:: ../tests/scripting/spy4Variables_Declare_bounds.spy
+.. literalinclude:: ../src/scripting/spy4Variables_Declare_bounds.spy
:language: python
.. note::
diff --git a/doc/OnlineDocs/pyomo_overview/simple_examples.rst b/doc/OnlineDocs/pyomo_overview/simple_examples.rst
index 4358c87b678..11305884c54 100644
--- a/doc/OnlineDocs/pyomo_overview/simple_examples.rst
+++ b/doc/OnlineDocs/pyomo_overview/simple_examples.rst
@@ -91,7 +91,7 @@ One way to implement this in Pyomo is as shown as follows:
:hide:
>>> # Create an instance to verify that the rules fire correctly
- >>> inst = model.create_instance('tests/scripting/abstract1.dat')
+ >>> inst = model.create_instance('src/scripting/abstract1.dat')
.. note::
@@ -261,9 +261,9 @@ parameters. Here is one file that provides data (in AMPL "``.dat``" format).
:hide:
>>> # Create an instance to verify that the rules fire correctly
- >>> inst = model.create_instance('tests/scripting/abstract1.dat')
+ >>> inst = model.create_instance('src/scripting/abstract1.dat')
-.. literalinclude:: ../tests/scripting/abstract1.dat
+.. literalinclude:: ../src/scripting/abstract1.dat
:language: text
There are multiple formats that can be used to provide data to a Pyomo
@@ -327,18 +327,18 @@ the same model. To start with an illustration of general indexes,
consider a slightly different Pyomo implementation of the model we just
presented.
-.. literalinclude:: ../tests/scripting/abstract2.py
+.. literalinclude:: ../src/scripting/abstract2.py
:language: python
To get the same instantiated model, the following data file can be used.
-.. literalinclude:: ../tests/scripting/abstract2a.dat
+.. literalinclude:: ../src/scripting/abstract2a.dat
:language: none
However, this model can also be fed different data for problems of the
same general form using meaningful indexes.
-.. literalinclude:: ../tests/scripting/abstract2.dat
+.. literalinclude:: ../src/scripting/abstract2.dat
:language: none
diff --git a/doc/OnlineDocs/tests/data/A.tab b/doc/OnlineDocs/src/data/A.tab
similarity index 100%
rename from doc/OnlineDocs/tests/data/A.tab
rename to doc/OnlineDocs/src/data/A.tab
diff --git a/doc/OnlineDocs/tests/data/ABCD.tab b/doc/OnlineDocs/src/data/ABCD.tab
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD.tab
rename to doc/OnlineDocs/src/data/ABCD.tab
diff --git a/doc/OnlineDocs/tests/data/ABCD.txt b/doc/OnlineDocs/src/data/ABCD.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD.txt
rename to doc/OnlineDocs/src/data/ABCD.txt
diff --git a/doc/OnlineDocs/tests/data/ABCD.xls b/doc/OnlineDocs/src/data/ABCD.xls
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD.xls
rename to doc/OnlineDocs/src/data/ABCD.xls
diff --git a/doc/OnlineDocs/tests/data/ABCD1.dat b/doc/OnlineDocs/src/data/ABCD1.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD1.dat
rename to doc/OnlineDocs/src/data/ABCD1.dat
diff --git a/doc/OnlineDocs/src/data/ABCD1.py b/doc/OnlineDocs/src/data/ABCD1.py
new file mode 100644
index 00000000000..aa2f46e71fa
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD1.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.Z = Set(dimen=4)
+
+instance = model.create_instance('ABCD1.dat')
+
+print(sorted(list(instance.Z.data())))
diff --git a/doc/OnlineDocs/tests/data/ABCD1.txt b/doc/OnlineDocs/src/data/ABCD1.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD1.txt
rename to doc/OnlineDocs/src/data/ABCD1.txt
diff --git a/doc/OnlineDocs/tests/data/ABCD2.dat b/doc/OnlineDocs/src/data/ABCD2.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD2.dat
rename to doc/OnlineDocs/src/data/ABCD2.dat
diff --git a/doc/OnlineDocs/src/data/ABCD2.py b/doc/OnlineDocs/src/data/ABCD2.py
new file mode 100644
index 00000000000..ec0e7ccb15c
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD2.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.Z = Set(initialize=[('A1', 'B1', 1), ('A2', 'B2', 2), ('A3', 'B3', 3)])
+# model.Z = Set(dimen=3)
+model.D = Param(model.Z)
+
+instance = model.create_instance('ABCD2.dat')
+
+print('Z ' + str(sorted(list(instance.Z.data()))))
+print('D')
+for key in sorted(instance.D.keys()):
+ print(name(instance.D, key) + " " + str(value(instance.D[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD2.txt b/doc/OnlineDocs/src/data/ABCD2.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD2.txt
rename to doc/OnlineDocs/src/data/ABCD2.txt
diff --git a/doc/OnlineDocs/tests/data/ABCD3.dat b/doc/OnlineDocs/src/data/ABCD3.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD3.dat
rename to doc/OnlineDocs/src/data/ABCD3.dat
diff --git a/doc/OnlineDocs/src/data/ABCD3.py b/doc/OnlineDocs/src/data/ABCD3.py
new file mode 100644
index 00000000000..ba55fd970cc
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD3.py
@@ -0,0 +1,24 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.Z = Set(dimen=3)
+model.D = Param(model.Z)
+
+instance = model.create_instance('ABCD3.dat')
+
+print('Z ' + str(sorted(list(instance.Z.data()))))
+print('D')
+for key in sorted(instance.D.keys()):
+ print(name(instance.D, key) + " " + str(value(instance.D[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD3.txt b/doc/OnlineDocs/src/data/ABCD3.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD3.txt
rename to doc/OnlineDocs/src/data/ABCD3.txt
diff --git a/doc/OnlineDocs/tests/data/ABCD4.dat b/doc/OnlineDocs/src/data/ABCD4.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD4.dat
rename to doc/OnlineDocs/src/data/ABCD4.dat
diff --git a/doc/OnlineDocs/src/data/ABCD4.py b/doc/OnlineDocs/src/data/ABCD4.py
new file mode 100644
index 00000000000..2fb397aa3b0
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD4.py
@@ -0,0 +1,24 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.Z = Set(dimen=3)
+model.Y = Param(model.Z)
+
+instance = model.create_instance('ABCD4.dat')
+
+print('Z ' + str(sorted(list(instance.Z.data()))))
+print('Y')
+for key in sorted(instance.Y.keys()):
+ print(name(instance.Y, key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD4.txt b/doc/OnlineDocs/src/data/ABCD4.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD4.txt
rename to doc/OnlineDocs/src/data/ABCD4.txt
diff --git a/doc/OnlineDocs/tests/data/ABCD5.dat b/doc/OnlineDocs/src/data/ABCD5.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD5.dat
rename to doc/OnlineDocs/src/data/ABCD5.dat
diff --git a/doc/OnlineDocs/src/data/ABCD5.py b/doc/OnlineDocs/src/data/ABCD5.py
new file mode 100644
index 00000000000..abc03505e96
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD5.py
@@ -0,0 +1,30 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.Z = Set()
+model.Y = Param(model.Z)
+model.W = Param(model.Z)
+# @decl
+
+instance = model.create_instance('ABCD5.dat')
+
+print('Z ' + str(sorted(list(instance.Z.data()))))
+print('Y')
+for key in sorted(instance.Y.keys()):
+ print(name(instance.Y, key) + " " + str(value(instance.Y[key])))
+print('W')
+for key in sorted(instance.W.keys()):
+ print(name(instance.W, key) + " " + str(value(instance.W[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD5.txt b/doc/OnlineDocs/src/data/ABCD5.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD5.txt
rename to doc/OnlineDocs/src/data/ABCD5.txt
diff --git a/doc/OnlineDocs/tests/data/ABCD6.dat b/doc/OnlineDocs/src/data/ABCD6.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD6.dat
rename to doc/OnlineDocs/src/data/ABCD6.dat
diff --git a/doc/OnlineDocs/src/data/ABCD6.py b/doc/OnlineDocs/src/data/ABCD6.py
new file mode 100644
index 00000000000..59e0e8e98ae
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD6.py
@@ -0,0 +1,24 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.Z = Set(dimen=3)
+model.D = Param(model.Z)
+
+instance = model.create_instance('ABCD6.dat')
+
+print('Z ' + str(sorted(list(instance.Z.data()))))
+print('D')
+for key in sorted(instance.D.keys()):
+ print(name(instance.D, key) + " " + str(value(instance.D[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD6.txt b/doc/OnlineDocs/src/data/ABCD6.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD6.txt
rename to doc/OnlineDocs/src/data/ABCD6.txt
diff --git a/doc/OnlineDocs/tests/data/ABCD7.dat b/doc/OnlineDocs/src/data/ABCD7.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD7.dat
rename to doc/OnlineDocs/src/data/ABCD7.dat
diff --git a/doc/OnlineDocs/src/data/ABCD7.py b/doc/OnlineDocs/src/data/ABCD7.py
new file mode 100644
index 00000000000..1bfb4d1e3fb
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD7.py
@@ -0,0 +1,30 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
+
+model = AbstractModel()
+
+model.Z = Set(dimen=3)
+model.Y = Param(model.Z)
+
+try:
+ instance = model.create_instance('ABCD7.dat')
+except pyomo.common.errors.ApplicationError as e:
+ print("ERROR " + str(e))
+ sys.exit(1)
+
+print('Z ' + str(sorted(list(instance.Z.data()))))
+print('Y')
+for key in sorted(instance.Y.keys()):
+ print(name(instance.Y, key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD7.txt b/doc/OnlineDocs/src/data/ABCD7.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD7.txt
rename to doc/OnlineDocs/src/data/ABCD7.txt
diff --git a/doc/OnlineDocs/tests/data/ABCD8.bad b/doc/OnlineDocs/src/data/ABCD8.bad
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD8.bad
rename to doc/OnlineDocs/src/data/ABCD8.bad
diff --git a/doc/OnlineDocs/tests/data/ABCD8.dat b/doc/OnlineDocs/src/data/ABCD8.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD8.dat
rename to doc/OnlineDocs/src/data/ABCD8.dat
diff --git a/doc/OnlineDocs/src/data/ABCD8.py b/doc/OnlineDocs/src/data/ABCD8.py
new file mode 100644
index 00000000000..aa1ba0b4cf5
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD8.py
@@ -0,0 +1,30 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
+
+model = AbstractModel()
+
+model.Z = Set(dimen=3)
+model.Y = Param(model.Z)
+
+try:
+ instance = model.create_instance('ABCD8.dat')
+except pyomo.common.errors.ApplicationError as e:
+ print("ERROR " + str(e))
+ sys.exit(1)
+
+print('Z ' + str(sorted(list(instance.Z.data()))))
+print('Y')
+for key in sorted(instance.Y.keys()):
+ print(name(instance.Y, key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD9.bad b/doc/OnlineDocs/src/data/ABCD9.bad
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD9.bad
rename to doc/OnlineDocs/src/data/ABCD9.bad
diff --git a/doc/OnlineDocs/tests/data/ABCD9.dat b/doc/OnlineDocs/src/data/ABCD9.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ABCD9.dat
rename to doc/OnlineDocs/src/data/ABCD9.dat
diff --git a/doc/OnlineDocs/src/data/ABCD9.py b/doc/OnlineDocs/src/data/ABCD9.py
new file mode 100644
index 00000000000..194c71486d9
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ABCD9.py
@@ -0,0 +1,30 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
+
+model = AbstractModel()
+
+model.Z = Set(dimen=3)
+model.Y = Param(model.Z)
+
+try:
+ instance = model.create_instance('ABCD9.dat')
+except pyomo.common.errors.ApplicationError as e:
+ print("ERROR " + str(e))
+ sys.exit(1)
+
+print('Z ' + str(sorted(list(instance.Z.data()))))
+print('Y')
+for key in sorted(instance.Y.keys()):
+ print(instance.Y[key] + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/C.tab b/doc/OnlineDocs/src/data/C.tab
similarity index 100%
rename from doc/OnlineDocs/tests/data/C.tab
rename to doc/OnlineDocs/src/data/C.tab
diff --git a/doc/OnlineDocs/tests/data/D.tab b/doc/OnlineDocs/src/data/D.tab
similarity index 100%
rename from doc/OnlineDocs/tests/data/D.tab
rename to doc/OnlineDocs/src/data/D.tab
diff --git a/doc/OnlineDocs/tests/data/U.tab b/doc/OnlineDocs/src/data/U.tab
similarity index 100%
rename from doc/OnlineDocs/tests/data/U.tab
rename to doc/OnlineDocs/src/data/U.tab
diff --git a/doc/OnlineDocs/tests/data/Y.tab b/doc/OnlineDocs/src/data/Y.tab
similarity index 100%
rename from doc/OnlineDocs/tests/data/Y.tab
rename to doc/OnlineDocs/src/data/Y.tab
diff --git a/doc/OnlineDocs/tests/data/Z.tab b/doc/OnlineDocs/src/data/Z.tab
similarity index 100%
rename from doc/OnlineDocs/tests/data/Z.tab
rename to doc/OnlineDocs/src/data/Z.tab
diff --git a/doc/OnlineDocs/tests/data/data_managers.txt b/doc/OnlineDocs/src/data/data_managers.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/data_managers.txt
rename to doc/OnlineDocs/src/data/data_managers.txt
diff --git a/doc/OnlineDocs/tests/data/diet.dat b/doc/OnlineDocs/src/data/diet.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/diet.dat
rename to doc/OnlineDocs/src/data/diet.dat
diff --git a/doc/OnlineDocs/tests/data/diet.sql b/doc/OnlineDocs/src/data/diet.sql
similarity index 100%
rename from doc/OnlineDocs/tests/data/diet.sql
rename to doc/OnlineDocs/src/data/diet.sql
diff --git a/doc/OnlineDocs/tests/data/diet.sqlite b/doc/OnlineDocs/src/data/diet.sqlite
similarity index 100%
rename from doc/OnlineDocs/tests/data/diet.sqlite
rename to doc/OnlineDocs/src/data/diet.sqlite
diff --git a/doc/OnlineDocs/tests/data/diet.sqlite.dat b/doc/OnlineDocs/src/data/diet.sqlite.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/diet.sqlite.dat
rename to doc/OnlineDocs/src/data/diet.sqlite.dat
diff --git a/doc/OnlineDocs/tests/data/diet1.py b/doc/OnlineDocs/src/data/diet1.py
similarity index 76%
rename from doc/OnlineDocs/tests/data/diet1.py
rename to doc/OnlineDocs/src/data/diet1.py
index ef0d8096350..40582e16ba0 100644
--- a/doc/OnlineDocs/tests/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/tests/data/ex.dat b/doc/OnlineDocs/src/data/ex.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ex.dat
rename to doc/OnlineDocs/src/data/ex.dat
diff --git a/doc/OnlineDocs/src/data/ex.py b/doc/OnlineDocs/src/data/ex.py
new file mode 100644
index 00000000000..a66ee30b494
--- /dev/null
+++ b/doc/OnlineDocs/src/data/ex.py
@@ -0,0 +1,22 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.z = Param()
+# @decl
+
+instance = model.create_instance('ex.dat')
+
+print(value(instance.z))
diff --git a/doc/OnlineDocs/tests/data/ex.txt b/doc/OnlineDocs/src/data/ex.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/ex.txt
rename to doc/OnlineDocs/src/data/ex.txt
diff --git a/doc/OnlineDocs/tests/data/ex1.dat b/doc/OnlineDocs/src/data/ex1.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ex1.dat
rename to doc/OnlineDocs/src/data/ex1.dat
diff --git a/doc/OnlineDocs/tests/data/ex2.dat b/doc/OnlineDocs/src/data/ex2.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/ex2.dat
rename to doc/OnlineDocs/src/data/ex2.dat
diff --git a/doc/OnlineDocs/tests/data/import1.tab.dat b/doc/OnlineDocs/src/data/import1.tab.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/import1.tab.dat
rename to doc/OnlineDocs/src/data/import1.tab.dat
diff --git a/doc/OnlineDocs/src/data/import1.tab.py b/doc/OnlineDocs/src/data/import1.tab.py
new file mode 100644
index 00000000000..e160e4fdcde
--- /dev/null
+++ b/doc/OnlineDocs/src/data/import1.tab.py
@@ -0,0 +1,24 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set(initialize=['A1', 'A2', 'A3', 'A4'])
+model.Y = Param(model.A)
+
+instance = model.create_instance('import1.tab.dat')
+
+print('Y')
+keys = instance.Y.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/import1.tab.txt b/doc/OnlineDocs/src/data/import1.tab.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/import1.tab.txt
rename to doc/OnlineDocs/src/data/import1.tab.txt
diff --git a/doc/OnlineDocs/tests/data/import2.tab.dat b/doc/OnlineDocs/src/data/import2.tab.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/import2.tab.dat
rename to doc/OnlineDocs/src/data/import2.tab.dat
diff --git a/doc/OnlineDocs/src/data/import2.tab.py b/doc/OnlineDocs/src/data/import2.tab.py
new file mode 100644
index 00000000000..54339551279
--- /dev/null
+++ b/doc/OnlineDocs/src/data/import2.tab.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set()
+model.Y = Param(model.A)
+
+instance = model.create_instance('import2.tab.dat')
+
+print('A ' + str(sorted(list(instance.A.data()))))
+print('Y')
+keys = instance.Y.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/import2.tab.txt b/doc/OnlineDocs/src/data/import2.tab.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/import2.tab.txt
rename to doc/OnlineDocs/src/data/import2.tab.txt
diff --git a/doc/OnlineDocs/tests/data/import3.tab.dat b/doc/OnlineDocs/src/data/import3.tab.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/import3.tab.dat
rename to doc/OnlineDocs/src/data/import3.tab.dat
diff --git a/doc/OnlineDocs/src/data/import3.tab.py b/doc/OnlineDocs/src/data/import3.tab.py
new file mode 100644
index 00000000000..664151d1438
--- /dev/null
+++ b/doc/OnlineDocs/src/data/import3.tab.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set()
+
+instance = model.create_instance('import3.tab.dat')
+
+print('A ' + str(sorted(list(instance.A.data()))))
diff --git a/doc/OnlineDocs/tests/data/import3.tab.txt b/doc/OnlineDocs/src/data/import3.tab.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/import3.tab.txt
rename to doc/OnlineDocs/src/data/import3.tab.txt
diff --git a/doc/OnlineDocs/tests/data/import4.tab.dat b/doc/OnlineDocs/src/data/import4.tab.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/import4.tab.dat
rename to doc/OnlineDocs/src/data/import4.tab.dat
diff --git a/doc/OnlineDocs/src/data/import4.tab.py b/doc/OnlineDocs/src/data/import4.tab.py
new file mode 100644
index 00000000000..91dd3f26a42
--- /dev/null
+++ b/doc/OnlineDocs/src/data/import4.tab.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.C = Set(dimen=2)
+
+instance = model.create_instance('import4.tab.dat')
+
+print('C ' + str(sorted(list(instance.C.data()))))
diff --git a/doc/OnlineDocs/tests/data/import4.tab.txt b/doc/OnlineDocs/src/data/import4.tab.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/import4.tab.txt
rename to doc/OnlineDocs/src/data/import4.tab.txt
diff --git a/doc/OnlineDocs/tests/data/import5.tab.dat b/doc/OnlineDocs/src/data/import5.tab.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/import5.tab.dat
rename to doc/OnlineDocs/src/data/import5.tab.dat
diff --git a/doc/OnlineDocs/src/data/import5.tab.py b/doc/OnlineDocs/src/data/import5.tab.py
new file mode 100644
index 00000000000..263677c308c
--- /dev/null
+++ b/doc/OnlineDocs/src/data/import5.tab.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.B = Set(dimen=2)
+
+instance = model.create_instance('import5.tab.dat')
+
+print('B ' + str(list(sorted(instance.B.data()))))
diff --git a/doc/OnlineDocs/tests/data/import5.tab.txt b/doc/OnlineDocs/src/data/import5.tab.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/import5.tab.txt
rename to doc/OnlineDocs/src/data/import5.tab.txt
diff --git a/doc/OnlineDocs/tests/data/import6.tab.dat b/doc/OnlineDocs/src/data/import6.tab.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/import6.tab.dat
rename to doc/OnlineDocs/src/data/import6.tab.dat
diff --git a/doc/OnlineDocs/src/data/import6.tab.py b/doc/OnlineDocs/src/data/import6.tab.py
new file mode 100644
index 00000000000..8f4824ad3fe
--- /dev/null
+++ b/doc/OnlineDocs/src/data/import6.tab.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.p = Param()
+
+instance = model.create_instance('import6.tab.dat')
+
+print('p ' + str(value(instance.p)))
diff --git a/doc/OnlineDocs/tests/data/import6.tab.txt b/doc/OnlineDocs/src/data/import6.tab.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/import6.tab.txt
rename to doc/OnlineDocs/src/data/import6.tab.txt
diff --git a/doc/OnlineDocs/tests/data/import7.tab.dat b/doc/OnlineDocs/src/data/import7.tab.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/import7.tab.dat
rename to doc/OnlineDocs/src/data/import7.tab.dat
diff --git a/doc/OnlineDocs/src/data/import7.tab.py b/doc/OnlineDocs/src/data/import7.tab.py
new file mode 100644
index 00000000000..503f9224323
--- /dev/null
+++ b/doc/OnlineDocs/src/data/import7.tab.py
@@ -0,0 +1,28 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.I = Set(initialize=['I1', 'I2', 'I3', 'I4'])
+model.A = Set(initialize=['A1', 'A2', 'A3'])
+model.U = Param(model.I, model.A)
+# BUG: This should cause an error
+# model.U = Param(model.A,model.I)
+
+instance = model.create_instance('import7.tab.dat')
+
+print('I ' + str(sorted(list(instance.I.data()))))
+print('A ' + str(sorted(list(instance.A.data()))))
+print('U')
+for key in sorted(instance.U.keys()):
+ print(name(instance.U, key) + " " + str(value(instance.U[key])))
diff --git a/doc/OnlineDocs/tests/data/import7.tab.txt b/doc/OnlineDocs/src/data/import7.tab.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/import7.tab.txt
rename to doc/OnlineDocs/src/data/import7.tab.txt
diff --git a/doc/OnlineDocs/tests/data/import8.tab.dat b/doc/OnlineDocs/src/data/import8.tab.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/import8.tab.dat
rename to doc/OnlineDocs/src/data/import8.tab.dat
diff --git a/doc/OnlineDocs/src/data/import8.tab.py b/doc/OnlineDocs/src/data/import8.tab.py
new file mode 100644
index 00000000000..02b8724fe45
--- /dev/null
+++ b/doc/OnlineDocs/src/data/import8.tab.py
@@ -0,0 +1,26 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.I = Set(initialize=['I1', 'I2', 'I3', 'I4'])
+model.A = Set(initialize=['A1', 'A2', 'A3'])
+model.U = Param(model.A, model.I)
+
+instance = model.create_instance('import8.tab.dat')
+
+print('A ' + str(sorted(list(instance.A.data()))))
+print('I ' + str(sorted(list(instance.I.data()))))
+print('U')
+for key in sorted(instance.U.keys()):
+ print(name(instance.U, key) + " " + str(value(instance.U[key])))
diff --git a/doc/OnlineDocs/tests/data/import8.tab.txt b/doc/OnlineDocs/src/data/import8.tab.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/import8.tab.txt
rename to doc/OnlineDocs/src/data/import8.tab.txt
diff --git a/doc/OnlineDocs/tests/data/namespace1.dat b/doc/OnlineDocs/src/data/namespace1.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/namespace1.dat
rename to doc/OnlineDocs/src/data/namespace1.dat
diff --git a/doc/OnlineDocs/tests/data/param1.dat b/doc/OnlineDocs/src/data/param1.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param1.dat
rename to doc/OnlineDocs/src/data/param1.dat
diff --git a/doc/OnlineDocs/src/data/param1.py b/doc/OnlineDocs/src/data/param1.py
new file mode 100644
index 00000000000..336a04287b9
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param1.py
@@ -0,0 +1,30 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Param()
+model.B = Param()
+model.C = Param()
+model.D = Param()
+model.E = Param()
+# @decl
+
+instance = model.create_instance('param1.dat')
+
+print(value(instance.A))
+print(value(instance.B))
+print(value(instance.C))
+print(value(instance.D))
+print(value(instance.E))
diff --git a/doc/OnlineDocs/tests/data/param1.txt b/doc/OnlineDocs/src/data/param1.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param1.txt
rename to doc/OnlineDocs/src/data/param1.txt
diff --git a/doc/OnlineDocs/tests/data/param2.dat b/doc/OnlineDocs/src/data/param2.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param2.dat
rename to doc/OnlineDocs/src/data/param2.dat
diff --git a/doc/OnlineDocs/src/data/param2.py b/doc/OnlineDocs/src/data/param2.py
new file mode 100644
index 00000000000..a7d0feafff9
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param2.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set()
+model.B = Param(model.A)
+# @decl
+
+instance = model.create_instance('param2.dat')
+
+keys = instance.B.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param2.txt b/doc/OnlineDocs/src/data/param2.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param2.txt
rename to doc/OnlineDocs/src/data/param2.txt
diff --git a/doc/OnlineDocs/tests/data/param2a.dat b/doc/OnlineDocs/src/data/param2a.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param2a.dat
rename to doc/OnlineDocs/src/data/param2a.dat
diff --git a/doc/OnlineDocs/src/data/param2a.py b/doc/OnlineDocs/src/data/param2a.py
new file mode 100644
index 00000000000..42056793ffd
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param2a.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set()
+model.B = Param(model.A)
+# @decl
+
+instance = model.create_instance('param2a.dat')
+
+keys = instance.B.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param2a.txt b/doc/OnlineDocs/src/data/param2a.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param2a.txt
rename to doc/OnlineDocs/src/data/param2a.txt
diff --git a/doc/OnlineDocs/tests/data/param3.dat b/doc/OnlineDocs/src/data/param3.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param3.dat
rename to doc/OnlineDocs/src/data/param3.dat
diff --git a/doc/OnlineDocs/tests/data/param3.py b/doc/OnlineDocs/src/data/param3.py
similarity index 50%
rename from doc/OnlineDocs/tests/data/param3.py
rename to doc/OnlineDocs/src/data/param3.py
index 149155ce67d..952f9a9b707 100644
--- a/doc/OnlineDocs/tests/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/tests/data/param3.txt b/doc/OnlineDocs/src/data/param3.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param3.txt
rename to doc/OnlineDocs/src/data/param3.txt
diff --git a/doc/OnlineDocs/tests/data/param3a.dat b/doc/OnlineDocs/src/data/param3a.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param3a.dat
rename to doc/OnlineDocs/src/data/param3a.dat
diff --git a/doc/OnlineDocs/tests/data/param3a.py b/doc/OnlineDocs/src/data/param3a.py
similarity index 50%
rename from doc/OnlineDocs/tests/data/param3a.py
rename to doc/OnlineDocs/src/data/param3a.py
index 0e99cad0c7a..028e1d07296 100644
--- a/doc/OnlineDocs/tests/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/tests/data/param3a.txt b/doc/OnlineDocs/src/data/param3a.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param3a.txt
rename to doc/OnlineDocs/src/data/param3a.txt
diff --git a/doc/OnlineDocs/tests/data/param3b.dat b/doc/OnlineDocs/src/data/param3b.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param3b.dat
rename to doc/OnlineDocs/src/data/param3b.dat
diff --git a/doc/OnlineDocs/tests/data/param3b.py b/doc/OnlineDocs/src/data/param3b.py
similarity index 50%
rename from doc/OnlineDocs/tests/data/param3b.py
rename to doc/OnlineDocs/src/data/param3b.py
index deda175ea12..97f8598610a 100644
--- a/doc/OnlineDocs/tests/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/tests/data/param3b.txt b/doc/OnlineDocs/src/data/param3b.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param3b.txt
rename to doc/OnlineDocs/src/data/param3b.txt
diff --git a/doc/OnlineDocs/tests/data/param3c.dat b/doc/OnlineDocs/src/data/param3c.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param3c.dat
rename to doc/OnlineDocs/src/data/param3c.dat
diff --git a/doc/OnlineDocs/tests/data/param3c.py b/doc/OnlineDocs/src/data/param3c.py
similarity index 50%
rename from doc/OnlineDocs/tests/data/param3c.py
rename to doc/OnlineDocs/src/data/param3c.py
index 4056dc8107d..582b0f7db75 100644
--- a/doc/OnlineDocs/tests/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/tests/data/param3c.txt b/doc/OnlineDocs/src/data/param3c.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param3c.txt
rename to doc/OnlineDocs/src/data/param3c.txt
diff --git a/doc/OnlineDocs/tests/data/param4.dat b/doc/OnlineDocs/src/data/param4.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param4.dat
rename to doc/OnlineDocs/src/data/param4.dat
diff --git a/doc/OnlineDocs/src/data/param4.py b/doc/OnlineDocs/src/data/param4.py
new file mode 100644
index 00000000000..010c46fc9c5
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param4.py
@@ -0,0 +1,26 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set()
+model.B = Param(model.A)
+# @decl
+
+instance = model.create_instance('param4.dat')
+
+print('B')
+keys = instance.B.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param4.txt b/doc/OnlineDocs/src/data/param4.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param4.txt
rename to doc/OnlineDocs/src/data/param4.txt
diff --git a/doc/OnlineDocs/tests/data/param5.dat b/doc/OnlineDocs/src/data/param5.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param5.dat
rename to doc/OnlineDocs/src/data/param5.dat
diff --git a/doc/OnlineDocs/src/data/param5.py b/doc/OnlineDocs/src/data/param5.py
new file mode 100644
index 00000000000..2db07f3f990
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param5.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=2)
+model.B = Param(model.A)
+# @decl
+
+instance = model.create_instance('param5.dat')
+
+keys = instance.B.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param5.txt b/doc/OnlineDocs/src/data/param5.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param5.txt
rename to doc/OnlineDocs/src/data/param5.txt
diff --git a/doc/OnlineDocs/tests/data/param5a.dat b/doc/OnlineDocs/src/data/param5a.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param5a.dat
rename to doc/OnlineDocs/src/data/param5a.dat
diff --git a/doc/OnlineDocs/src/data/param5a.py b/doc/OnlineDocs/src/data/param5a.py
new file mode 100644
index 00000000000..32a53d24e9b
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param5a.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=2)
+model.B = Param(model.A)
+# @decl
+
+instance = model.create_instance('param5a.dat')
+
+keys = instance.B.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param5a.txt b/doc/OnlineDocs/src/data/param5a.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param5a.txt
rename to doc/OnlineDocs/src/data/param5a.txt
diff --git a/doc/OnlineDocs/tests/data/param6.dat b/doc/OnlineDocs/src/data/param6.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param6.dat
rename to doc/OnlineDocs/src/data/param6.dat
diff --git a/doc/OnlineDocs/tests/data/param6.py b/doc/OnlineDocs/src/data/param6.py
similarity index 51%
rename from doc/OnlineDocs/tests/data/param6.py
rename to doc/OnlineDocs/src/data/param6.py
index c3e4b25d144..e3364a933cf 100644
--- a/doc/OnlineDocs/tests/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/tests/data/param6.txt b/doc/OnlineDocs/src/data/param6.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param6.txt
rename to doc/OnlineDocs/src/data/param6.txt
diff --git a/doc/OnlineDocs/tests/data/param6a.dat b/doc/OnlineDocs/src/data/param6a.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param6a.dat
rename to doc/OnlineDocs/src/data/param6a.dat
diff --git a/doc/OnlineDocs/tests/data/param6a.py b/doc/OnlineDocs/src/data/param6a.py
similarity index 51%
rename from doc/OnlineDocs/tests/data/param6a.py
rename to doc/OnlineDocs/src/data/param6a.py
index 07e8280cc18..3d2fa645411 100644
--- a/doc/OnlineDocs/tests/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/tests/data/param6a.txt b/doc/OnlineDocs/src/data/param6a.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param6a.txt
rename to doc/OnlineDocs/src/data/param6a.txt
diff --git a/doc/OnlineDocs/tests/data/param7a.dat b/doc/OnlineDocs/src/data/param7a.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param7a.dat
rename to doc/OnlineDocs/src/data/param7a.dat
diff --git a/doc/OnlineDocs/src/data/param7a.py b/doc/OnlineDocs/src/data/param7a.py
new file mode 100644
index 00000000000..b3aba9ec23d
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param7a.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=2)
+model.B = Param(model.A)
+# @decl
+
+instance = model.create_instance('param7a.dat')
+
+keys = instance.B.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param7a.txt b/doc/OnlineDocs/src/data/param7a.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param7a.txt
rename to doc/OnlineDocs/src/data/param7a.txt
diff --git a/doc/OnlineDocs/tests/data/param7b.dat b/doc/OnlineDocs/src/data/param7b.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param7b.dat
rename to doc/OnlineDocs/src/data/param7b.dat
diff --git a/doc/OnlineDocs/src/data/param7b.py b/doc/OnlineDocs/src/data/param7b.py
new file mode 100644
index 00000000000..8b022f399a8
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param7b.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=2)
+model.B = Param(model.A)
+# @decl
+
+instance = model.create_instance('param7b.dat')
+
+keys = instance.B.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param7b.txt b/doc/OnlineDocs/src/data/param7b.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param7b.txt
rename to doc/OnlineDocs/src/data/param7b.txt
diff --git a/doc/OnlineDocs/tests/data/param8a.dat b/doc/OnlineDocs/src/data/param8a.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/param8a.dat
rename to doc/OnlineDocs/src/data/param8a.dat
diff --git a/doc/OnlineDocs/src/data/param8a.py b/doc/OnlineDocs/src/data/param8a.py
new file mode 100644
index 00000000000..abfa885ded4
--- /dev/null
+++ b/doc/OnlineDocs/src/data/param8a.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=4)
+model.B = Param(model.A)
+# @decl
+
+instance = model.create_instance('param8a.dat')
+
+keys = instance.B.keys()
+for key in sorted(keys):
+ print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param8a.txt b/doc/OnlineDocs/src/data/param8a.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/param8a.txt
rename to doc/OnlineDocs/src/data/param8a.txt
diff --git a/doc/OnlineDocs/tests/data/pyomo.diet1.sh b/doc/OnlineDocs/src/data/pyomo.diet1.sh
similarity index 100%
rename from doc/OnlineDocs/tests/data/pyomo.diet1.sh
rename to doc/OnlineDocs/src/data/pyomo.diet1.sh
diff --git a/doc/OnlineDocs/tests/data/pyomo.diet1.txt b/doc/OnlineDocs/src/data/pyomo.diet1.txt
similarity index 86%
rename from doc/OnlineDocs/tests/data/pyomo.diet1.txt
rename to doc/OnlineDocs/src/data/pyomo.diet1.txt
index 4b67e92c80c..fd8c87d51d9 100644
--- a/doc/OnlineDocs/tests/data/pyomo.diet1.txt
+++ b/doc/OnlineDocs/src/data/pyomo.diet1.txt
@@ -1,16 +1,16 @@
[ 0.00] Setting up Pyomo environment
[ 0.00] Applying Pyomo preprocessing actions
[ 0.00] Creating model
-[ 0.02] Applying solver
-[ 0.03] Processing results
+[ 0.01] Applying solver
+[ 0.02] Processing results
Number of solutions: 1
Solution Information
Gap: 0.0
Status: optimal
Function Value: 2.81
Solver results file: results.yml
-[ 0.04] Applying Pyomo postprocessing actions
-[ 0.04] Pyomo Finished
+[ 0.02] Applying Pyomo postprocessing actions
+[ 0.02] Pyomo Finished
# ==========================================================
# = Solver Results =
# ==========================================================
@@ -22,9 +22,9 @@ Problem:
Lower bound: 2.81
Upper bound: 2.81
Number of objectives: 1
- Number of constraints: 4
- Number of variables: 10
- Number of nonzeros: 10
+ Number of constraints: 3
+ Number of variables: 9
+ Number of nonzeros: 9
Sense: minimize
# ----------------------------------------------------------
# Solver Information
@@ -37,7 +37,7 @@ Solver:
Number of bounded subproblems: 1
Number of created subproblems: 1
Error rc: 0
- Time: 0.00816035270690918
+ Time: 0.002644062042236328
# ----------------------------------------------------------
# Solution Information
# ----------------------------------------------------------
diff --git a/doc/OnlineDocs/tests/data/pyomo.diet2.sh b/doc/OnlineDocs/src/data/pyomo.diet2.sh
similarity index 100%
rename from doc/OnlineDocs/tests/data/pyomo.diet2.sh
rename to doc/OnlineDocs/src/data/pyomo.diet2.sh
diff --git a/doc/OnlineDocs/tests/data/pyomo.diet2.txt b/doc/OnlineDocs/src/data/pyomo.diet2.txt
similarity index 86%
rename from doc/OnlineDocs/tests/data/pyomo.diet2.txt
rename to doc/OnlineDocs/src/data/pyomo.diet2.txt
index 00405216fe1..7ed879d500f 100644
--- a/doc/OnlineDocs/tests/data/pyomo.diet2.txt
+++ b/doc/OnlineDocs/src/data/pyomo.diet2.txt
@@ -1,16 +1,16 @@
[ 0.00] Setting up Pyomo environment
[ 0.00] Applying Pyomo preprocessing actions
[ 0.00] Creating model
-[ 0.03] Applying solver
-[ 0.05] Processing results
+[ 0.01] Applying solver
+[ 0.01] Processing results
Number of solutions: 1
Solution Information
Gap: 0.0
Status: optimal
Function Value: 2.81
Solver results file: results.yml
-[ 0.05] Applying Pyomo postprocessing actions
-[ 0.05] Pyomo Finished
+[ 0.01] Applying Pyomo postprocessing actions
+[ 0.01] Pyomo Finished
# ==========================================================
# = Solver Results =
# ==========================================================
@@ -22,9 +22,9 @@ Problem:
Lower bound: 2.81
Upper bound: 2.81
Number of objectives: 1
- Number of constraints: 4
- Number of variables: 10
- Number of nonzeros: 10
+ Number of constraints: 3
+ Number of variables: 9
+ Number of nonzeros: 9
Sense: minimize
# ----------------------------------------------------------
# Solver Information
@@ -37,7 +37,7 @@ Solver:
Number of bounded subproblems: 1
Number of created subproblems: 1
Error rc: 0
- Time: 0.006503582000732422
+ Time: 0.0018515586853027344
# ----------------------------------------------------------
# Solution Information
# ----------------------------------------------------------
diff --git a/doc/OnlineDocs/tests/data/set1.dat b/doc/OnlineDocs/src/data/set1.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/set1.dat
rename to doc/OnlineDocs/src/data/set1.dat
diff --git a/doc/OnlineDocs/src/data/set1.py b/doc/OnlineDocs/src/data/set1.py
new file mode 100644
index 00000000000..c84c1ef0819
--- /dev/null
+++ b/doc/OnlineDocs/src/data/set1.py
@@ -0,0 +1,24 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set()
+model.B = Set()
+model.C = Set()
+
+instance = model.create_instance('set1.dat')
+
+print(sorted(list(instance.A.data())))
+print(sorted((instance.B.data())))
+print(sorted(list((instance.C.data())), key=lambda x: x if type(x) is str else str(x)))
diff --git a/doc/OnlineDocs/tests/data/set1.txt b/doc/OnlineDocs/src/data/set1.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/set1.txt
rename to doc/OnlineDocs/src/data/set1.txt
diff --git a/doc/OnlineDocs/tests/data/set2.dat b/doc/OnlineDocs/src/data/set2.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/set2.dat
rename to doc/OnlineDocs/src/data/set2.dat
diff --git a/doc/OnlineDocs/src/data/set2.py b/doc/OnlineDocs/src/data/set2.py
new file mode 100644
index 00000000000..9048a49fecb
--- /dev/null
+++ b/doc/OnlineDocs/src/data/set2.py
@@ -0,0 +1,22 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=3)
+# @decl
+
+instance = model.create_instance('set2.dat')
+
+print(sorted(list(instance.A.data())))
diff --git a/doc/OnlineDocs/tests/data/set2.txt b/doc/OnlineDocs/src/data/set2.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/set2.txt
rename to doc/OnlineDocs/src/data/set2.txt
diff --git a/doc/OnlineDocs/tests/data/set2a.dat b/doc/OnlineDocs/src/data/set2a.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/set2a.dat
rename to doc/OnlineDocs/src/data/set2a.dat
diff --git a/doc/OnlineDocs/src/data/set2a.py b/doc/OnlineDocs/src/data/set2a.py
new file mode 100644
index 00000000000..f2fa4d71916
--- /dev/null
+++ b/doc/OnlineDocs/src/data/set2a.py
@@ -0,0 +1,22 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=3)
+# @decl
+
+instance = model.create_instance('set2a.dat')
+
+print(sorted(list(instance.A.data())))
diff --git a/doc/OnlineDocs/tests/data/set2a.txt b/doc/OnlineDocs/src/data/set2a.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/set2a.txt
rename to doc/OnlineDocs/src/data/set2a.txt
diff --git a/doc/OnlineDocs/tests/data/set3.dat b/doc/OnlineDocs/src/data/set3.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/set3.dat
rename to doc/OnlineDocs/src/data/set3.dat
diff --git a/doc/OnlineDocs/src/data/set3.py b/doc/OnlineDocs/src/data/set3.py
new file mode 100644
index 00000000000..9cdacbe39e0
--- /dev/null
+++ b/doc/OnlineDocs/src/data/set3.py
@@ -0,0 +1,30 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set()
+model.B = Set(model.A)
+# @decl
+# model.C = Set(model.A,model.A)
+
+instance = model.create_instance('set3.dat')
+
+print(sorted(list(instance.A.data()), key=lambda x: x if type(x) is str else str(x)))
+print(sorted(list(instance.B[1].data()), key=lambda x: x if type(x) is str else str(x)))
+print(
+ sorted(
+ list(instance.B['aaa'].data()), key=lambda x: x if type(x) is str else str(x)
+ )
+)
diff --git a/doc/OnlineDocs/tests/data/set3.txt b/doc/OnlineDocs/src/data/set3.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/set3.txt
rename to doc/OnlineDocs/src/data/set3.txt
diff --git a/doc/OnlineDocs/tests/data/set4.dat b/doc/OnlineDocs/src/data/set4.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/set4.dat
rename to doc/OnlineDocs/src/data/set4.dat
diff --git a/doc/OnlineDocs/src/data/set4.py b/doc/OnlineDocs/src/data/set4.py
new file mode 100644
index 00000000000..b3485638c6f
--- /dev/null
+++ b/doc/OnlineDocs/src/data/set4.py
@@ -0,0 +1,22 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=2)
+# @decl
+
+instance = model.create_instance('set4.dat')
+
+print(sorted(list(instance.A.data())))
diff --git a/doc/OnlineDocs/tests/data/set4.txt b/doc/OnlineDocs/src/data/set4.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/set4.txt
rename to doc/OnlineDocs/src/data/set4.txt
diff --git a/doc/OnlineDocs/tests/data/set5.dat b/doc/OnlineDocs/src/data/set5.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/set5.dat
rename to doc/OnlineDocs/src/data/set5.dat
diff --git a/doc/OnlineDocs/src/data/set5.py b/doc/OnlineDocs/src/data/set5.py
new file mode 100644
index 00000000000..d745d8408d0
--- /dev/null
+++ b/doc/OnlineDocs/src/data/set5.py
@@ -0,0 +1,24 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+# @decl
+model.A = Set(dimen=4)
+# @decl
+
+instance = model.create_instance('set5.dat')
+
+
+for tpl in sorted(list(instance.A.data()), key=lambda x: tuple(map(str, x))):
+ print(tpl)
diff --git a/doc/OnlineDocs/tests/data/set5.txt b/doc/OnlineDocs/src/data/set5.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/set5.txt
rename to doc/OnlineDocs/src/data/set5.txt
diff --git a/doc/OnlineDocs/tests/data/table0.dat b/doc/OnlineDocs/src/data/table0.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table0.dat
rename to doc/OnlineDocs/src/data/table0.dat
diff --git a/doc/OnlineDocs/src/data/table0.py b/doc/OnlineDocs/src/data/table0.py
new file mode 100644
index 00000000000..de0fae0c861
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table0.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set(initialize=['A1', 'A2', 'A3'])
+model.M = Param(model.A)
+
+instance = model.create_instance('table0.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table0.txt b/doc/OnlineDocs/src/data/table0.txt
similarity index 57%
rename from doc/OnlineDocs/tests/data/table0.txt
rename to doc/OnlineDocs/src/data/table0.txt
index ecd2417333d..c2e75dd97a6 100644
--- a/doc/OnlineDocs/tests/data/table0.txt
+++ b/doc/OnlineDocs/src/data/table0.txt
@@ -1,6 +1,7 @@
1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
1 Param Declarations
M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
diff --git a/doc/OnlineDocs/tests/data/table0.ul.dat b/doc/OnlineDocs/src/data/table0.ul.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table0.ul.dat
rename to doc/OnlineDocs/src/data/table0.ul.dat
diff --git a/doc/OnlineDocs/src/data/table0.ul.py b/doc/OnlineDocs/src/data/table0.ul.py
new file mode 100644
index 00000000000..524c3756782
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table0.ul.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set(initialize=['A1', 'A2', 'A3'])
+model.M = Param(model.A)
+
+instance = model.create_instance('table0.ul.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table0.ul.txt b/doc/OnlineDocs/src/data/table0.ul.txt
similarity index 57%
rename from doc/OnlineDocs/tests/data/table0.ul.txt
rename to doc/OnlineDocs/src/data/table0.ul.txt
index ecd2417333d..c2e75dd97a6 100644
--- a/doc/OnlineDocs/tests/data/table0.ul.txt
+++ b/doc/OnlineDocs/src/data/table0.ul.txt
@@ -1,6 +1,7 @@
1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
1 Param Declarations
M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
diff --git a/doc/OnlineDocs/tests/data/table1.dat b/doc/OnlineDocs/src/data/table1.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table1.dat
rename to doc/OnlineDocs/src/data/table1.dat
diff --git a/doc/OnlineDocs/src/data/table1.py b/doc/OnlineDocs/src/data/table1.py
new file mode 100644
index 00000000000..f36714b8f1f
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table1.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set(initialize=['A1', 'A2', 'A3'])
+model.M = Param(model.A)
+
+instance = model.create_instance('table1.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table1.txt b/doc/OnlineDocs/src/data/table1.txt
similarity index 57%
rename from doc/OnlineDocs/tests/data/table1.txt
rename to doc/OnlineDocs/src/data/table1.txt
index ecd2417333d..c2e75dd97a6 100644
--- a/doc/OnlineDocs/tests/data/table1.txt
+++ b/doc/OnlineDocs/src/data/table1.txt
@@ -1,6 +1,7 @@
1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
1 Param Declarations
M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
diff --git a/doc/OnlineDocs/tests/data/table2.dat b/doc/OnlineDocs/src/data/table2.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table2.dat
rename to doc/OnlineDocs/src/data/table2.dat
diff --git a/doc/OnlineDocs/src/data/table2.py b/doc/OnlineDocs/src/data/table2.py
new file mode 100644
index 00000000000..03648a00f8c
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table2.py
@@ -0,0 +1,23 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set(initialize=['A1', 'A2', 'A3'])
+model.B = Set(initialize=['B1', 'B2', 'B3'])
+
+model.M = Param(model.A)
+model.N = Param(model.A, model.B)
+
+instance = model.create_instance('table2.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/src/data/table2.txt b/doc/OnlineDocs/src/data/table2.txt
new file mode 100644
index 00000000000..a710b6b6042
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table2.txt
@@ -0,0 +1,21 @@
+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'}
+
+2 Param Declarations
+ M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 4.3
+ A2 : 4.4
+ A3 : 4.5
+ 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
+
+4 Declarations: A B M N
diff --git a/doc/OnlineDocs/tests/data/table3.dat b/doc/OnlineDocs/src/data/table3.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table3.dat
rename to doc/OnlineDocs/src/data/table3.dat
diff --git a/doc/OnlineDocs/src/data/table3.py b/doc/OnlineDocs/src/data/table3.py
new file mode 100644
index 00000000000..2c598f112df
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table3.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set()
+model.B = Set(initialize=['B1', 'B2', 'B3'])
+model.Z = Set(dimen=2)
+
+model.M = Param(model.A)
+model.N = Param(model.A, model.B)
+
+
+instance = model.create_instance('table3.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/src/data/table3.txt b/doc/OnlineDocs/src/data/table3.txt
new file mode 100644
index 00000000000..c0c61cd5a5b
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table3.txt
@@ -0,0 +1,24 @@
+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'}
+ Z : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
+
+2 Param Declarations
+ M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 4.3
+ A2 : 4.4
+ A3 : 4.5
+ 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 Z M N
diff --git a/doc/OnlineDocs/tests/data/table3.ul.dat b/doc/OnlineDocs/src/data/table3.ul.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table3.ul.dat
rename to doc/OnlineDocs/src/data/table3.ul.dat
diff --git a/doc/OnlineDocs/src/data/table3.ul.py b/doc/OnlineDocs/src/data/table3.ul.py
new file mode 100644
index 00000000000..18ced12b388
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table3.ul.py
@@ -0,0 +1,25 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set()
+model.B = Set(initialize=['B1', 'B2', 'B3'])
+model.Z = Set(dimen=2)
+
+model.M = Param(model.A)
+model.N = Param(model.A, model.B)
+
+
+instance = model.create_instance('table3.ul.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/src/data/table3.ul.txt b/doc/OnlineDocs/src/data/table3.ul.txt
new file mode 100644
index 00000000000..c0c61cd5a5b
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table3.ul.txt
@@ -0,0 +1,24 @@
+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'}
+ Z : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
+
+2 Param Declarations
+ M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 4.3
+ A2 : 4.4
+ A3 : 4.5
+ 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 Z M N
diff --git a/doc/OnlineDocs/tests/data/table4.dat b/doc/OnlineDocs/src/data/table4.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table4.dat
rename to doc/OnlineDocs/src/data/table4.dat
diff --git a/doc/OnlineDocs/src/data/table4.py b/doc/OnlineDocs/src/data/table4.py
new file mode 100644
index 00000000000..bd20682b5a9
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table4.py
@@ -0,0 +1,23 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set()
+model.Z = Set(dimen=2)
+
+model.M = Param(model.A)
+model.N = Param(model.Z)
+
+instance = model.create_instance('table4.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table4.txt b/doc/OnlineDocs/src/data/table4.txt
similarity index 54%
rename from doc/OnlineDocs/tests/data/table4.txt
rename to doc/OnlineDocs/src/data/table4.txt
index eb49be14de2..f86004c342a 100644
--- a/doc/OnlineDocs/tests/data/table4.txt
+++ b/doc/OnlineDocs/src/data/table4.txt
@@ -1,8 +1,10 @@
2 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- Z : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+ Z : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
2 Param Declarations
M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
diff --git a/doc/OnlineDocs/tests/data/table4.ul.dat b/doc/OnlineDocs/src/data/table4.ul.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table4.ul.dat
rename to doc/OnlineDocs/src/data/table4.ul.dat
diff --git a/doc/OnlineDocs/src/data/table4.ul.py b/doc/OnlineDocs/src/data/table4.ul.py
new file mode 100644
index 00000000000..9f16f21fe19
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table4.ul.py
@@ -0,0 +1,23 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set()
+model.Z = Set(dimen=2)
+
+model.M = Param(model.A)
+model.N = Param(model.Z)
+
+instance = model.create_instance('table4.ul.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table4.ul.txt b/doc/OnlineDocs/src/data/table4.ul.txt
similarity index 54%
rename from doc/OnlineDocs/tests/data/table4.ul.txt
rename to doc/OnlineDocs/src/data/table4.ul.txt
index eb49be14de2..f86004c342a 100644
--- a/doc/OnlineDocs/tests/data/table4.ul.txt
+++ b/doc/OnlineDocs/src/data/table4.ul.txt
@@ -1,8 +1,10 @@
2 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- Z : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+ Z : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
2 Param Declarations
M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
diff --git a/doc/OnlineDocs/tests/data/table5.dat b/doc/OnlineDocs/src/data/table5.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table5.dat
rename to doc/OnlineDocs/src/data/table5.dat
diff --git a/doc/OnlineDocs/src/data/table5.py b/doc/OnlineDocs/src/data/table5.py
new file mode 100644
index 00000000000..a3cb01209a2
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table5.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.Z = Set(dimen=2)
+model.Y = Set(dimen=2)
+
+instance = model.create_instance('table5.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/src/data/table5.txt b/doc/OnlineDocs/src/data/table5.txt
new file mode 100644
index 00000000000..084757b781b
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table5.txt
@@ -0,0 +1,9 @@
+2 Set Declarations
+ Y : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {(4.3, 5.3), (4.4, 5.4), (4.5, 5.5)}
+ Z : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
+
+2 Declarations: Z Y
diff --git a/doc/OnlineDocs/tests/data/table6.dat b/doc/OnlineDocs/src/data/table6.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table6.dat
rename to doc/OnlineDocs/src/data/table6.dat
diff --git a/doc/OnlineDocs/src/data/table6.py b/doc/OnlineDocs/src/data/table6.py
new file mode 100644
index 00000000000..1db0a764a23
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table6.py
@@ -0,0 +1,19 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.pi = Param()
+
+instance = model.create_instance('table6.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table6.txt b/doc/OnlineDocs/src/data/table6.txt
similarity index 100%
rename from doc/OnlineDocs/tests/data/table6.txt
rename to doc/OnlineDocs/src/data/table6.txt
diff --git a/doc/OnlineDocs/tests/data/table7.dat b/doc/OnlineDocs/src/data/table7.dat
similarity index 100%
rename from doc/OnlineDocs/tests/data/table7.dat
rename to doc/OnlineDocs/src/data/table7.dat
diff --git a/doc/OnlineDocs/src/data/table7.py b/doc/OnlineDocs/src/data/table7.py
new file mode 100644
index 00000000000..84a841aca86
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table7.py
@@ -0,0 +1,21 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.A = Set(initialize=['A1', 'A2', 'A3'])
+model.M = Param(model.A)
+model.Z = Set(dimen=2)
+
+instance = model.create_instance('table7.dat')
+instance.pprint()
diff --git a/doc/OnlineDocs/src/data/table7.txt b/doc/OnlineDocs/src/data/table7.txt
new file mode 100644
index 00000000000..8ddbfde38be
--- /dev/null
+++ b/doc/OnlineDocs/src/data/table7.txt
@@ -0,0 +1,16 @@
+2 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+ Z : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
+
+1 Param Declarations
+ M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 4.3
+ A2 : 4.4
+ A3 : 4.5
+
+3 Declarations: A M Z
diff --git a/doc/OnlineDocs/tests/dataportal/A.tab b/doc/OnlineDocs/src/dataportal/A.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/A.tab
rename to doc/OnlineDocs/src/dataportal/A.tab
diff --git a/doc/OnlineDocs/tests/dataportal/C.tab b/doc/OnlineDocs/src/dataportal/C.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/C.tab
rename to doc/OnlineDocs/src/dataportal/C.tab
diff --git a/doc/OnlineDocs/tests/dataportal/D.tab b/doc/OnlineDocs/src/dataportal/D.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/D.tab
rename to doc/OnlineDocs/src/dataportal/D.tab
diff --git a/doc/OnlineDocs/tests/dataportal/PP.csv b/doc/OnlineDocs/src/dataportal/PP.csv
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/PP.csv
rename to doc/OnlineDocs/src/dataportal/PP.csv
diff --git a/doc/OnlineDocs/tests/dataportal/PP.json b/doc/OnlineDocs/src/dataportal/PP.json
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/PP.json
rename to doc/OnlineDocs/src/dataportal/PP.json
diff --git a/doc/OnlineDocs/tests/dataportal/PP.sqlite b/doc/OnlineDocs/src/dataportal/PP.sqlite
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/PP.sqlite
rename to doc/OnlineDocs/src/dataportal/PP.sqlite
diff --git a/doc/OnlineDocs/tests/dataportal/PP.tab b/doc/OnlineDocs/src/dataportal/PP.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/PP.tab
rename to doc/OnlineDocs/src/dataportal/PP.tab
diff --git a/doc/OnlineDocs/tests/dataportal/PP.xml b/doc/OnlineDocs/src/dataportal/PP.xml
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/PP.xml
rename to doc/OnlineDocs/src/dataportal/PP.xml
diff --git a/doc/OnlineDocs/tests/dataportal/PP.yaml b/doc/OnlineDocs/src/dataportal/PP.yaml
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/PP.yaml
rename to doc/OnlineDocs/src/dataportal/PP.yaml
diff --git a/doc/OnlineDocs/tests/dataportal/PP_sqlite.py b/doc/OnlineDocs/src/dataportal/PP_sqlite.py
similarity index 97%
rename from doc/OnlineDocs/tests/dataportal/PP_sqlite.py
rename to doc/OnlineDocs/src/dataportal/PP_sqlite.py
index 9c6fc5ddc0b..1592e820900 100644
--- a/doc/OnlineDocs/tests/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/tests/dataportal/Pyomo_mysql b/doc/OnlineDocs/src/dataportal/Pyomo_mysql
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/Pyomo_mysql
rename to doc/OnlineDocs/src/dataportal/Pyomo_mysql
diff --git a/doc/OnlineDocs/tests/dataportal/S.tab b/doc/OnlineDocs/src/dataportal/S.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/S.tab
rename to doc/OnlineDocs/src/dataportal/S.tab
diff --git a/doc/OnlineDocs/tests/dataportal/T.json b/doc/OnlineDocs/src/dataportal/T.json
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/T.json
rename to doc/OnlineDocs/src/dataportal/T.json
diff --git a/doc/OnlineDocs/tests/dataportal/T.yaml b/doc/OnlineDocs/src/dataportal/T.yaml
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/T.yaml
rename to doc/OnlineDocs/src/dataportal/T.yaml
diff --git a/doc/OnlineDocs/tests/dataportal/U.tab b/doc/OnlineDocs/src/dataportal/U.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/U.tab
rename to doc/OnlineDocs/src/dataportal/U.tab
diff --git a/doc/OnlineDocs/tests/dataportal/XW.tab b/doc/OnlineDocs/src/dataportal/XW.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/XW.tab
rename to doc/OnlineDocs/src/dataportal/XW.tab
diff --git a/doc/OnlineDocs/tests/dataportal/Y.tab b/doc/OnlineDocs/src/dataportal/Y.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/Y.tab
rename to doc/OnlineDocs/src/dataportal/Y.tab
diff --git a/doc/OnlineDocs/tests/dataportal/Z.tab b/doc/OnlineDocs/src/dataportal/Z.tab
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/Z.tab
rename to doc/OnlineDocs/src/dataportal/Z.tab
diff --git a/doc/OnlineDocs/tests/dataportal/dataportal_tab.py b/doc/OnlineDocs/src/dataportal/dataportal_tab.py
similarity index 94%
rename from doc/OnlineDocs/tests/dataportal/dataportal_tab.py
rename to doc/OnlineDocs/src/dataportal/dataportal_tab.py
index d1a75196c99..655329d31de 100644
--- a/doc/OnlineDocs/tests/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
new file mode 100644
index 00000000000..a23c63d90c9
--- /dev/null
+++ b/doc/OnlineDocs/src/dataportal/dataportal_tab.txt
@@ -0,0 +1,315 @@
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+1 Declarations: A
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+1 Declarations: A
+1 Set Declarations
+ C : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
+
+1 Declarations: C
+1 Set Declarations
+ D : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 1), ('A2', 2), ('A3', 3)}
+
+1 Declarations: D
+1 Param Declarations
+ z : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ None : 1.1
+
+1 Declarations: z
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+1 Param Declarations
+ y : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 3.3
+ A2 : 3.4
+ A3 : 3.5
+
+2 Declarations: A y
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+2 Param Declarations
+ w : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 4.3
+ A2 : 4.4
+ A3 : 4.5
+ x : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 3.3
+ A2 : 3.4
+ A3 : 3.5
+
+3 Declarations: A x w
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+1 Param Declarations
+ y : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 3.3
+ A2 : 3.4
+ A3 : 3.5
+
+2 Declarations: A y
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+1 Param Declarations
+ w : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 4.3
+ A2 : 4.4
+ A3 : 4.5
+
+2 Declarations: A w
+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'}
+
+1 Param Declarations
+ u : Size=12, Index=I*A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ ('I1', 'A1') : 1.3
+ ('I1', 'A2') : 2.3
+ ('I1', 'A3') : 3.3
+ ('I2', 'A1') : 1.4
+ ('I2', 'A2') : 2.4
+ ('I2', 'A3') : 3.4
+ ('I3', 'A1') : 1.5
+ ('I3', 'A2') : 2.5
+ ('I3', 'A3') : 3.5
+ ('I4', 'A1') : 1.6
+ ('I4', 'A2') : 2.6
+ ('I4', 'A3') : 3.6
+
+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'}
+
+1 Param Declarations
+ t : Size=12, Index=A*I, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ ('A1', 'I1') : 1.3
+ ('A1', 'I2') : 1.4
+ ('A1', 'I3') : 1.5
+ ('A1', 'I4') : 1.6
+ ('A2', 'I1') : 2.3
+ ('A2', 'I2') : 2.4
+ ('A2', 'I3') : 2.5
+ ('A2', 'I4') : 2.6
+ ('A3', 'I1') : 3.3
+ ('A3', 'I2') : 3.4
+ ('A3', 'I3') : 3.5
+ ('A3', 'I4') : 3.6
+
+3 Declarations: A I t
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+1 Param Declarations
+ s : Size=2, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 3.3
+ A3 : 3.5
+
+2 Declarations: A s
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 4 : {'A1', 'A2', 'A3', 'A4'}
+
+1 Param Declarations
+ y : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 3.3
+ A2 : 3.4
+ A3 : 3.5
+
+2 Declarations: A y
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
+
+1 Param Declarations
+ p : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ ('A1', 'B1') : 4.3
+ ('A2', 'B2') : 4.4
+ ('A3', 'B3') : 4.5
+
+2 Declarations: A p
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+1 Declarations: A
+
+2 Param Declarations
+ y : Size=3, Index={A1, A2, A3}, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 3.3
+ A2 : 3.4
+ A3 : 3.5
+ z : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ None : 1.1
+
+2 Declarations: z y
+['A1', 'A2', 'A3']
+1.1
+A1 3.3
+A2 3.4
+A3 3.5
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
+
+1 Param Declarations
+ p : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ ('A1', 'B1') : 4.3
+ ('A2', 'B2') : 4.4
+ ('A3', 'B3') : 4.5
+
+2 Declarations: A p
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 0 : {}
+
+1 Param Declarations
+ p : Size=0, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+
+2 Declarations: A p
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')}
+
+1 Param Declarations
+ p : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ ('A1', 'B1') : 4.3
+ ('A2', 'B2') : 4.4
+ ('A3', 'B3') : 4.5
+
+2 Declarations: A p
+1 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {'A1', 'A2', 'A3'}
+
+1 Param Declarations
+ p : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 4.3
+ A2 : 4.4
+ A3 : 4.5
+
+2 Declarations: A p
+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 : 2 : Any : 3 : {(1, 'B1'), (2, 'B2'), (3, 'B3')}
+ C : Size=2, Index=A, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ A1 : 1 : Any : 3 : {1, 2, 3}
+ A3 : 1 : Any : 3 : {10, 20, 30}
+
+3 Param Declarations
+ p : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ None : 0.1
+ q : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 3.3
+ A2 : 3.4
+ A3 : 3.5
+ r : Size=3, Index=B, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ (1, 'B1') : 3.3
+ (2, 'B2') : 3.4
+ (3, 'B3') : 3.5
+
+6 Declarations: A B C p q r
+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 : 2 : Any : 3 : {(1, 'B1'), (2, 'B2'), (3, 'B3')}
+ C : Size=2, Index=A, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ A1 : 1 : Any : 3 : {1, 2, 3}
+ A3 : 1 : Any : 3 : {10, 20, 30}
+
+3 Param Declarations
+ p : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ None : 0.1
+ q : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ A1 : 3.3
+ A2 : 3.4
+ A3 : 3.5
+ r : Size=3, Index=B, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ (1, 'B1') : 3.3
+ (2, 'B2') : 3.4
+ (3, 'B3') : 3.5
+
+6 Declarations: A B C p q r
+1 Set Declarations
+ C : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 9 : {('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)}
+
+1 Declarations: C
+1 Set Declarations
+ C : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 2 : Any : 3 : {('A1', 1), ('A2', 2), ('A3', 3)}
+
+1 Declarations: C
diff --git a/doc/OnlineDocs/tests/dataportal/excel.xls b/doc/OnlineDocs/src/dataportal/excel.xls
similarity index 100%
rename from doc/OnlineDocs/tests/dataportal/excel.xls
rename to doc/OnlineDocs/src/dataportal/excel.xls
diff --git a/doc/OnlineDocs/src/dataportal/param_initialization.py b/doc/OnlineDocs/src/dataportal/param_initialization.py
new file mode 100644
index 00000000000..7f9270b5fda
--- /dev/null
+++ b/doc/OnlineDocs/src/dataportal/param_initialization.py
@@ -0,0 +1,36 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
+
+model = ConcreteModel()
+
+# @decl1
+model.a = Param(initialize=1.1)
+# @decl1
+
+# Initialize with a dictionary
+# @decl2
+model.b = Param([1, 2, 3], initialize={1: 1, 2: 2, 3: 3})
+# @decl2
+
+
+# Initialize with a function that returns native Python data
+# @decl3
+def c(model):
+ return {1: 1, 2: 2, 3: 3}
+
+
+model.c = Param([1, 2, 3], initialize=c)
+# @decl3
+
+model.pprint(verbose=True)
diff --git a/doc/OnlineDocs/src/dataportal/param_initialization.txt b/doc/OnlineDocs/src/dataportal/param_initialization.txt
new file mode 100644
index 00000000000..49ea105f120
--- /dev/null
+++ b/doc/OnlineDocs/src/dataportal/param_initialization.txt
@@ -0,0 +1,16 @@
+3 Param Declarations
+ a : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ None : 1.1
+ 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={1, 2, 3}, Domain=Any, Default=None, Mutable=False
+ Key : Value
+ 1 : 1
+ 2 : 2
+ 3 : 3
+
+3 Declarations: a b c
diff --git a/doc/OnlineDocs/tests/dataportal/set_initialization.py b/doc/OnlineDocs/src/dataportal/set_initialization.py
similarity index 60%
rename from doc/OnlineDocs/tests/dataportal/set_initialization.py
rename to doc/OnlineDocs/src/dataportal/set_initialization.py
index aa7b426fa82..a5ab03894e3 100644
--- a/doc/OnlineDocs/tests/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
new file mode 100644
index 00000000000..3c2960ce4ef
--- /dev/null
+++ b/doc/OnlineDocs/src/dataportal/set_initialization.txt
@@ -0,0 +1,31 @@
+WARNING: Initializing ordered Set B with a fundamentally unordered data source
+(type: set). This WILL potentially lead to nondeterministic behavior in Pyomo
+8 Set Declarations
+ A : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {2, 3, 5}
+ B : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {2, 3, 5}
+ C : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {2, 3, 5}
+ D : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 9 : {0, 1, 2, 3, 4, 5, 6, 7, 8}
+ E : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 1 : {2,}
+ F : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {2, 3, 5}
+ G : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 3 : {2, 3, 5}
+ 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}
+
+8 Declarations: A B C D E F G H
diff --git a/doc/OnlineDocs/tests/expr/design.py b/doc/OnlineDocs/src/expr/design.py
similarity index 64%
rename from doc/OnlineDocs/tests/expr/design.py
rename to doc/OnlineDocs/src/expr/design.py
index b122a5f2bf3..647a4537ca4 100644
--- a/doc/OnlineDocs/tests/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/tests/expr/design.txt b/doc/OnlineDocs/src/expr/design.txt
similarity index 100%
rename from doc/OnlineDocs/tests/expr/design.txt
rename to doc/OnlineDocs/src/expr/design.txt
diff --git a/doc/OnlineDocs/src/expr/index.py b/doc/OnlineDocs/src/expr/index.py
new file mode 100644
index 00000000000..fe5b03461c0
--- /dev/null
+++ b/doc/OnlineDocs/src/expr/index.py
@@ -0,0 +1,21 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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 *
+
+# ---------------------------------------------
+# @simple
+M = ConcreteModel()
+M.v = Var()
+
+e = M.v * 2
+# @simple
+print(e)
diff --git a/doc/OnlineDocs/tests/expr/index.txt b/doc/OnlineDocs/src/expr/index.txt
similarity index 100%
rename from doc/OnlineDocs/tests/expr/index.txt
rename to doc/OnlineDocs/src/expr/index.txt
diff --git a/doc/OnlineDocs/tests/expr/managing.py b/doc/OnlineDocs/src/expr/managing.py
similarity index 65%
rename from doc/OnlineDocs/tests/expr/managing.py
rename to doc/OnlineDocs/src/expr/managing.py
index 0a2709fe96f..ff149e4fd5c 100644
--- a/doc/OnlineDocs/tests/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
@@ -5,7 +16,7 @@
# ---------------------------------------------
# @ex1
-from pyomo.core.expr import current as EXPR
+import pyomo.core.expr as EXPR
M = ConcreteModel()
M.x = Var()
@@ -21,7 +32,7 @@
# ---------------------------------------------
# @ex2
-from pyomo.core.expr import current as EXPR
+import pyomo.core.expr as EXPR
M = ConcreteModel()
M.x = Var()
@@ -33,35 +44,6 @@
print(EXPR.expression_to_string(e, labeler=NumericLabeler('x')))
# @ex2
-# ---------------------------------------------
-# @ex3
-from pyomo.core.expr import current as EXPR
-
-M = ConcreteModel()
-M.x = Var()
-M.y = Var()
-
-e = sin(M.x) + 2 * M.y + M.x * M.y - 3
-
-# -3 + 2*y + sin(x) + x*y
-print(EXPR.expression_to_string(e, standardize=True))
-# @ex3
-
-# ---------------------------------------------
-# @ex4
-from pyomo.core.expr import current as EXPR
-
-M = ConcreteModel()
-M.x = Var()
-
-with EXPR.clone_counter() as counter:
- start = counter.count
- e1 = sin(M.x)
- e2 = e1.clone()
- total = counter.count - start
- assert total == 1
-# @ex4
-
# ---------------------------------------------
# @ex5
M = ConcreteModel()
@@ -85,7 +67,7 @@
# ---------------------------------------------
# @ex8
-from pyomo.core.expr import current as EXPR
+import pyomo.core.expr as EXPR
M = ConcreteModel()
M.x = Var()
@@ -98,7 +80,7 @@
# ---------------------------------------------
# @ex9
-from pyomo.core.expr import current as EXPR
+import pyomo.core.expr as EXPR
M = ConcreteModel()
M.x = Var()
@@ -116,7 +98,7 @@
# ---------------------------------------------
# @visitor1
-from pyomo.core.expr import current as EXPR
+import pyomo.core.expr as EXPR
class SizeofVisitor(EXPR.SimpleExpressionVisitor):
@@ -129,8 +111,7 @@ def visit(self, node):
def finalize(self):
return self.counter
-
-# @visitor1
+ # @visitor1
# ---------------------------------------------
@@ -144,13 +125,12 @@ def sizeof_expression(expr):
# Compute the value using the :func:`xbfs` search method.
#
return visitor.xbfs(expr)
+ # @visitor2
-# @visitor2
-
# ---------------------------------------------
# @visitor3
-from pyomo.core.expr import current as EXPR
+import pyomo.core.expr as EXPR
class CloneVisitor(EXPR.ExpressionValueVisitor):
@@ -161,22 +141,17 @@ def visit(self, node, values):
#
# Clone the interior node
#
- return node.construct_clone(tuple(values), self.memo)
+ return node.create_node_with_local_data(values)
def visiting_potential_leaf(self, node):
#
# Clone leaf nodes in the expression tree
#
- if (
- node.__class__ in native_numeric_types
- or node.__class__ not in pyomo5_expression_types
- ):
+ if node.__class__ in native_numeric_types or not node.is_expression_type():
return True, copy.deepcopy(node, self.memo)
return False, None
-
-
-# @visitor3
+ # @visitor3
# ---------------------------------------------
@@ -191,13 +166,29 @@ def clone_expression(expr):
# search method.
#
return visitor.dfs_postorder_stack(expr)
-
-
-# @visitor4
+ # @visitor4
+
+
+# Test:
+m = ConcreteModel()
+m.x = Var(range(2))
+m.p = Param(range(5), mutable=True)
+e = m.x[0] + 5 * m.x[1]
+ce = clone_expression(e)
+print(e is not ce)
+# True
+print(str(e))
+# x[0] + 5*x[1]
+print(str(ce))
+# x[0] + 5*x[1]
+print(e.arg(0) is ce.arg(0))
+# True
+print(e.arg(1) is not ce.arg(1))
+# True
# ---------------------------------------------
# @visitor5
-from pyomo.core.expr import current as EXPR
+import pyomo.core.expr as EXPR
class ScalingVisitor(EXPR.ExpressionReplacementVisitor):
@@ -205,29 +196,24 @@ def __init__(self, scale):
super(ScalingVisitor, self).__init__()
self.scale = scale
- def visiting_potential_leaf(self, node):
+ def beforeChild(self, node, child, child_idx):
#
- # Clone leaf nodes in the expression tree
+ # Native numeric types are terminal nodes; this also catches all
+ # nodes that do not conform to the ExpressionBase API (i.e.,
+ # define is_variable_type)
#
- if node.__class__ in native_numeric_types:
- return True, node
-
- if node.is_variable_type():
- return True, self.scale[id(node)] * node
-
- if isinstance(node, EXPR.LinearExpression):
- node_ = copy.deepcopy(node)
- node_.constant = node.constant
- node_.linear_vars = copy.copy(node.linear_vars)
- node_.linear_coefs = []
- for i, v in enumerate(node.linear_vars):
- node_.linear_coefs.append(node.linear_coefs[i] * self.scale[id(v)])
- return True, node_
-
- return False, None
-
-
-# @visitor5
+ if child.__class__ in native_numeric_types:
+ return False, child
+ #
+ # Replace leaf variables with scaled variables
+ #
+ if child.is_variable_type():
+ return False, self.scale[id(child)] * child
+ #
+ # Everything else can be processed normally
+ #
+ return True, None
+ # @visitor5
# ---------------------------------------------
@@ -241,11 +227,10 @@ def scale_expression(expr, scale):
# Scale the expression using the :func:`dfs_postorder_stack`
# search method.
#
- return visitor.dfs_postorder_stack(expr)
+ return visitor.walk_expression(expr)
+ # @visitor6
-# @visitor6
-
# ---------------------------------------------
# @visitor7
M = ConcreteModel()
diff --git a/doc/OnlineDocs/tests/expr/managing.txt b/doc/OnlineDocs/src/expr/managing.txt
similarity index 56%
rename from doc/OnlineDocs/tests/expr/managing.txt
rename to doc/OnlineDocs/src/expr/managing.txt
index 5a22c846a8b..d236c942d25 100644
--- a/doc/OnlineDocs/tests/expr/managing.txt
+++ b/doc/OnlineDocs/src/expr/managing.txt
@@ -1,5 +1,9 @@
sin(x) + 2*x
-sum(sin(x), prod(2, x))
+sum(sin(x), mon(2, x))
sin(x1) + 2*x2
--3 + 2*y + x*y + sin(x)
+True
+x[0] + 5*x[1]
+x[0] + 5*x[1]
+True
+True
p[0]*x[0] + p[1]*x[1] + p[2]*x[2] + p[3]*x[3] + p[4]*x[4]
diff --git a/doc/OnlineDocs/tests/expr/overview.py b/doc/OnlineDocs/src/expr/overview.py
similarity index 70%
rename from doc/OnlineDocs/tests/expr/overview.py
rename to doc/OnlineDocs/src/expr/overview.py
index 6207a4c4288..d33725edb88 100644
--- a/doc/OnlineDocs/tests/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/tests/expr/overview.txt b/doc/OnlineDocs/src/expr/overview.txt
similarity index 100%
rename from doc/OnlineDocs/tests/expr/overview.txt
rename to doc/OnlineDocs/src/expr/overview.txt
diff --git a/doc/OnlineDocs/tests/expr/performance.py b/doc/OnlineDocs/src/expr/performance.py
similarity index 77%
rename from doc/OnlineDocs/tests/expr/performance.py
rename to doc/OnlineDocs/src/expr/performance.py
index 53ac5bb4f9e..8936bd2ed8c 100644
--- a/doc/OnlineDocs/tests/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/tests/expr/performance.txt b/doc/OnlineDocs/src/expr/performance.txt
similarity index 62%
rename from doc/OnlineDocs/tests/expr/performance.txt
rename to doc/OnlineDocs/src/expr/performance.txt
index c1387a51ce4..6bfd0bd1d5a 100644
--- a/doc/OnlineDocs/tests/expr/performance.txt
+++ b/doc/OnlineDocs/src/expr/performance.txt
@@ -10,5 +10,5 @@ x[0] + x[1]**2 + x[2]**2 + x[3]**2 + x[4]**2
x[0] + x[1] + x[2] + x[3] + x[4] + x[5] + x[6] + x[7] + x[8] + x[9]
x[0]*y[0] + x[1]*y[1] + x[2]*y[2] + x[3]*y[3] + x[4]*y[4] + x[5]*y[5] + x[6]*y[6] + x[7]*y[7] + x[8]*y[8] + x[9]*y[9]
x[1]*y[1] + x[2]*y[2] + x[3]*y[3] + x[4]*y[4] + x[5]*y[5]
-x[0]*(1/y[0]) + x[1]*(1/y[1]) + x[2]*(1/y[2]) + x[3]*(1/y[3]) + x[4]*(1/y[4]) + x[5]*(1/y[5]) + x[6]*(1/y[6]) + x[7]*(1/y[7]) + x[8]*(1/y[8]) + x[9]*(1/y[9])
-(1/(x[0]*y[0])) + (1/(x[1]*y[1])) + (1/(x[2]*y[2])) + (1/(x[3]*y[3])) + (1/(x[4]*y[4])) + (1/(x[5]*y[5])) + (1/(x[6]*y[6])) + (1/(x[7]*y[7])) + (1/(x[8]*y[8])) + (1/(x[9]*y[9]))
+x[0]/y[0] + x[1]/y[1] + x[2]/y[2] + x[3]/y[3] + x[4]/y[4] + x[5]/y[5] + x[6]/y[6] + x[7]/y[7] + x[8]/y[8] + x[9]/y[9]
+1/(x[0]*y[0]) + 1/(x[1]*y[1]) + 1/(x[2]*y[2]) + 1/(x[3]*y[3]) + 1/(x[4]*y[4]) + 1/(x[5]*y[5]) + 1/(x[6]*y[6]) + 1/(x[7]*y[7]) + 1/(x[8]*y[8]) + 1/(x[9]*y[9])
diff --git a/doc/OnlineDocs/tests/expr/quicksum.log b/doc/OnlineDocs/src/expr/quicksum.log
similarity index 100%
rename from doc/OnlineDocs/tests/expr/quicksum.log
rename to doc/OnlineDocs/src/expr/quicksum.log
diff --git a/doc/OnlineDocs/tests/expr/quicksum.py b/doc/OnlineDocs/src/expr/quicksum.py
similarity index 53%
rename from doc/OnlineDocs/tests/expr/quicksum.py
rename to doc/OnlineDocs/src/expr/quicksum.py
index a1ad9660664..1b6cd3f9909 100644
--- a/doc/OnlineDocs/tests/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/tests/kernel/examples.sh b/doc/OnlineDocs/src/kernel/examples.sh
similarity index 100%
rename from doc/OnlineDocs/tests/kernel/examples.sh
rename to doc/OnlineDocs/src/kernel/examples.sh
diff --git a/doc/OnlineDocs/tests/kernel/examples.txt b/doc/OnlineDocs/src/kernel/examples.txt
similarity index 66%
rename from doc/OnlineDocs/tests/kernel/examples.txt
rename to doc/OnlineDocs/src/kernel/examples.txt
index c8a0cde2e36..8ba072d28b1 100644
--- a/doc/OnlineDocs/tests/kernel/examples.txt
+++ b/doc/OnlineDocs/src/kernel/examples.txt
@@ -1,20 +1,12 @@
-6 Set Declarations
- cd_index : Dim=0, Dimen=2, Size=6, Domain=None, Ordered=True, Bounds=None
- Virtual
- cl_index : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- [1, 2, 3]
- ol_index : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- [1, 2, 3]
- s : Dim=0, Dimen=1, Size=2, Domain=None, Ordered=Insertion, Bounds=(1, 2)
- [1, 2]
- sd_index : Dim=0, Dimen=1, Size=2, Domain=None, Ordered=False, Bounds=(1, 2)
- [1, 2]
- vl_index : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- [1, 2, 3]
+1 Set Declarations
+ s : Size=1, Index=None, Ordered=Insertion
+ Key : Dimen : Domain : Size : Members
+ None : 1 : Any : 2 : {1, 2}
1 RangeSet Declarations
- q : Dim=0, Dimen=1, Size=3, Domain=Integers, Ordered=True, Bounds=(1, 3)
- Virtual
+ q : Dimen=1, Size=3, Bounds=(1, 3)
+ Key : Finite : Members
+ None : True : [1:3]
2 Param Declarations
p : Size=1, Index=None, Domain=Any, Default=None, Mutable=True
@@ -36,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
@@ -59,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]
@@ -69,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
@@ -77,77 +69,72 @@
(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
- 1
- Type=1
- Weight : Variable
- 1 : vd[1]
- 2 : vd[2]
- 2
- Type=1
- Weight : Variable
- 1 : vl[1]
- 2 : vl[2]
- 3 : vl[3]
- sos1 : Size=1
- Type=1
- Weight : Variable
- 1 : vl[1]
- 2 : vl[2]
- 3 : vl[3]
- sos2 : Size=1
- Type=2
- Weight : Variable
- 1 : vd[1]
- 2 : vd[2]
+ sd : Size=2 Index= OrderedScalarSet
+ 1
+ Type=1
+ Weight : Variable
+ 1 : vd[1]
+ 2 : vd[2]
+ 2
+ Type=1
+ Weight : Variable
+ 1 : vl[1]
+ 2 : vl[2]
+ 3 : vl[3]
+ sos1 : Size=1
+ Type=1
+ Weight : Variable
+ 1 : vl[1]
+ 2 : vl[2]
+ 3 : vl[3]
+ sos2 : Size=1
+ Type=2
+ Weight : Variable
+ 1 : vd[1]
+ 2 : vd[2]
2 Block Declarations
b : Size=1, Index=None, Active=True
0 Declarations:
- 2 Set Declarations
- SOS2_constraint_index : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- [1, 2, 3]
- SOS2_y_index : Dim=0, Dimen=1, Size=4, Domain=None, Ordered=False, Bounds=(0, 3)
- [0, 1, 2, 3]
+ pw : Size=1, Index=None, Active=True
+ 1 Var Declarations
+ 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
+ 2 : 0 : None : None : False : True : NonNegativeReals
+ 3 : 0 : None : None : False : True : NonNegativeReals
- 1 Var Declarations
- SOS2_y : Size=4, Index=pw.SOS2_y_index
- Key : Lower : Value : Upper : Fixed : Stale : Domain
- 0 : 0 : None : None : False : True : NonNegativeReals
- 1 : 0 : None : None : False : True : NonNegativeReals
- 2 : 0 : None : None : False : True : NonNegativeReals
- 3 : 0 : None : None : False : True : NonNegativeReals
+ 1 Constraint Declarations
+ 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
+ 3 : 1.0 : pw.SOS2_y[0] + pw.SOS2_y[1] + pw.SOS2_y[2] + pw.SOS2_y[3] : 1.0 : True
- 1 Constraint Declarations
- SOS2_constraint : Size=3, Index=pw.SOS2_constraint_index, 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
- 3 : 1.0 : pw.SOS2_y[0] + pw.SOS2_y[1] + pw.SOS2_y[2] + pw.SOS2_y[3] : 1.0 : True
+ 1 SOSConstraint Declarations
+ SOS2_sosconstraint : Size=1
+ Type=2
+ Weight : Variable
+ 1 : pw.SOS2_y[0]
+ 2 : pw.SOS2_y[1]
+ 3 : pw.SOS2_y[2]
+ 4 : pw.SOS2_y[3]
- 1 SOSConstraint Declarations
- SOS2_sosconstraint : Size=1
- Type=2
- Weight : Variable
- 1 : pw.SOS2_y[0]
- 2 : pw.SOS2_y[1]
- 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=Suffix.IMPORT, Datatype=Suffix.FLOAT
+ 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)
@@ -166,14 +153,14 @@
- vl[0]: variable(active=True, value=None, bounds=(2,None), domain_type=RealSet, fixed=False, stale=True)
- vl[1]: variable(active=True, value=None, bounds=(2,None), domain_type=RealSet, fixed=False, stale=True)
- vl[2]: variable(active=True, value=None, bounds=(2,None), domain_type=RealSet, fixed=False, stale=True)
- - c: constraint(active=True, expr=vd[1] + vd[2] <= 9.0)
+ - c: constraint(active=True, expr=vd[1] + vd[2] <= 9)
- cd: constraint_dict(active=True, ctype=IConstraint)
- - cd[(1, 0)]: constraint(active=True, expr=vd[1] == 0.0)
- - cd[(1, 1)]: constraint(active=True, expr=vd[1] == 1.0)
- - cd[(1, 2)]: constraint(active=True, expr=vd[1] == 2.0)
- - cd[(2, 0)]: constraint(active=True, expr=vd[2] == 0.0)
- - cd[(2, 1)]: constraint(active=True, expr=vd[2] == 1.0)
- - cd[(2, 2)]: constraint(active=True, expr=vd[2] == 2.0)
+ - cd[(1, 0)]: constraint(active=True, expr=vd[1] == 0)
+ - cd[(1, 1)]: constraint(active=True, expr=vd[1] == 1)
+ - cd[(1, 2)]: constraint(active=True, expr=vd[1] == 2)
+ - cd[(2, 0)]: constraint(active=True, expr=vd[2] == 0)
+ - cd[(2, 1)]: constraint(active=True, expr=vd[2] == 1)
+ - cd[(2, 2)]: constraint(active=True, expr=vd[2] == 2)
- cl: constraint_list(active=True, ctype=IConstraint)
- cl[0]: constraint(active=True, expr=-5 <= vl[0] - v <= 5)
- cl[1]: constraint(active=True, expr=-5 <= vl[1] - v <= 5)
@@ -216,9 +203,9 @@
- pw.v[2]: variable(active=True, value=None, bounds=(0,None), domain_type=RealSet, fixed=False, stale=True)
- pw.v[3]: variable(active=True, value=None, bounds=(0,None), domain_type=RealSet, fixed=False, stale=True)
- pw.c: constraint_list(active=True, ctype=IConstraint)
- - pw.c[0]: linear_constraint(active=True, expr=pw.v[0] + 2*pw.v[1] + 3*pw.v[2] + 4*pw.v[3] - v == 0.0)
- - pw.c[1]: linear_constraint(active=True, expr=pw.v[0] + 2*pw.v[1] + pw.v[2] + 2*pw.v[3] - f == 0.0)
- - pw.c[2]: linear_constraint(active=True, expr=pw.v[0] + pw.v[1] + pw.v[2] + pw.v[3] == 1.0)
+ - pw.c[0]: linear_constraint(active=True, expr=pw.v[0] + 2*pw.v[1] + 3*pw.v[2] + 4*pw.v[3] - v == 0)
+ - pw.c[1]: linear_constraint(active=True, expr=pw.v[0] + 2*pw.v[1] + pw.v[2] + 2*pw.v[3] - f == 0)
+ - 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)'])
-2.0 KB
-8.4 KB
+Memory: 1.9 KB
+Memory: 9.7 KB
diff --git a/doc/OnlineDocs/src/scripting/AbstractSuffixes.py b/doc/OnlineDocs/src/scripting/AbstractSuffixes.py
new file mode 100644
index 00000000000..1c064042c6b
--- /dev/null
+++ b/doc/OnlineDocs/src/scripting/AbstractSuffixes.py
@@ -0,0 +1,35 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+model.I = RangeSet(1, 4)
+model.x = Var(model.I)
+
+
+def c_rule(m, i):
+ return m.x[i] >= i
+
+
+model.c = Constraint(model.I, rule=c_rule)
+
+
+def foo_rule(m):
+ return ((m.x[i], 3.0 * i) for i in m.I)
+
+
+model.foo = Suffix(rule=foo_rule)
+
+# instantiate the model
+inst = model.create_instance()
+for i in inst.I:
+ print(i, inst.foo[inst.x[i]])
diff --git a/doc/OnlineDocs/tests/scripting/Isinglebuild.py b/doc/OnlineDocs/src/scripting/Isinglebuild.py
similarity index 68%
rename from doc/OnlineDocs/tests/scripting/Isinglebuild.py
rename to doc/OnlineDocs/src/scripting/Isinglebuild.py
index 00f79c9a750..344f8905a4a 100644
--- a/doc/OnlineDocs/tests/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/tests/scripting/Isinglecomm.dat b/doc/OnlineDocs/src/scripting/Isinglecomm.dat
similarity index 100%
rename from doc/OnlineDocs/tests/scripting/Isinglecomm.dat
rename to doc/OnlineDocs/src/scripting/Isinglecomm.dat
diff --git a/doc/OnlineDocs/src/scripting/NodesIn_init.py b/doc/OnlineDocs/src/scripting/NodesIn_init.py
new file mode 100644
index 00000000000..c17b70150bc
--- /dev/null
+++ b/doc/OnlineDocs/src/scripting/NodesIn_init.py
@@ -0,0 +1,21 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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:
+ if j == node:
+ retval.append(i)
+ return retval
+
+
+model.NodesIn = Set(model.Nodes, initialize=NodesIn_init)
diff --git a/doc/OnlineDocs/src/scripting/Z_init.py b/doc/OnlineDocs/src/scripting/Z_init.py
new file mode 100644
index 00000000000..1dd2843f4f0
--- /dev/null
+++ b/doc/OnlineDocs/src/scripting/Z_init.py
@@ -0,0 +1,19 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
+ return 2 * i + 1
+
+
+model.Z = Set(initialize=Z_init)
diff --git a/doc/OnlineDocs/tests/scripting/abstract1.dat b/doc/OnlineDocs/src/scripting/abstract1.dat
similarity index 100%
rename from doc/OnlineDocs/tests/scripting/abstract1.dat
rename to doc/OnlineDocs/src/scripting/abstract1.dat
diff --git a/doc/OnlineDocs/tests/scripting/abstract2.dat b/doc/OnlineDocs/src/scripting/abstract2.dat
similarity index 100%
rename from doc/OnlineDocs/tests/scripting/abstract2.dat
rename to doc/OnlineDocs/src/scripting/abstract2.dat
diff --git a/doc/OnlineDocs/tests/scripting/abstract2.py b/doc/OnlineDocs/src/scripting/abstract2.py
similarity index 56%
rename from doc/OnlineDocs/tests/scripting/abstract2.py
rename to doc/OnlineDocs/src/scripting/abstract2.py
index 7eb444914db..544399a8a42 100644
--- a/doc/OnlineDocs/tests/scripting/abstract2.py
+++ b/doc/OnlineDocs/src/scripting/abstract2.py
@@ -1,6 +1,17 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
-from __future__ import division
+
from pyomo.environ import *
model = AbstractModel()
diff --git a/doc/OnlineDocs/tests/scripting/abstract2a.dat b/doc/OnlineDocs/src/scripting/abstract2a.dat
similarity index 100%
rename from doc/OnlineDocs/tests/scripting/abstract2a.dat
rename to doc/OnlineDocs/src/scripting/abstract2a.dat
diff --git a/doc/OnlineDocs/tests/scripting/abstract2piece.py b/doc/OnlineDocs/src/scripting/abstract2piece.py
similarity index 70%
rename from doc/OnlineDocs/tests/scripting/abstract2piece.py
rename to doc/OnlineDocs/src/scripting/abstract2piece.py
index 225ec0d1a64..03c5139004e 100644
--- a/doc/OnlineDocs/tests/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/tests/scripting/abstract2piecebuild.py b/doc/OnlineDocs/src/scripting/abstract2piecebuild.py
similarity index 77%
rename from doc/OnlineDocs/tests/scripting/abstract2piecebuild.py
rename to doc/OnlineDocs/src/scripting/abstract2piecebuild.py
index 1f00cdb0265..d454d7fbc79 100644
--- a/doc/OnlineDocs/tests/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/tests/scripting/block_iter_example.py b/doc/OnlineDocs/src/scripting/block_iter_example.py
similarity index 62%
rename from doc/OnlineDocs/tests/scripting/block_iter_example.py
rename to doc/OnlineDocs/src/scripting/block_iter_example.py
index 680e0d1728b..10c8a4ea43d 100644
--- a/doc/OnlineDocs/tests/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
new file mode 100644
index 00000000000..399715efde6
--- /dev/null
+++ b/doc/OnlineDocs/src/scripting/concrete1.py
@@ -0,0 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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()
+
+model.x = Var([1, 2], domain=NonNegativeReals)
+
+model.OBJ = Objective(expr=2 * model.x[1] + 3 * model.x[2])
+
+model.Constraint1 = Constraint(expr=3 * model.x[1] + 4 * model.x[2] >= 1)
diff --git a/doc/OnlineDocs/src/scripting/doubleA.py b/doc/OnlineDocs/src/scripting/doubleA.py
new file mode 100644
index 00000000000..abf35979a05
--- /dev/null
+++ b/doc/OnlineDocs/src/scripting/doubleA.py
@@ -0,0 +1,17 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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)
+
+
+model.C = Set(initialize=DoubleA_init)
diff --git a/doc/OnlineDocs/tests/scripting/driveabs2.py b/doc/OnlineDocs/src/scripting/driveabs2.py
similarity index 64%
rename from doc/OnlineDocs/tests/scripting/driveabs2.py
rename to doc/OnlineDocs/src/scripting/driveabs2.py
index 67ab7468864..f8f972460b1 100644
--- a/doc/OnlineDocs/tests/scripting/driveabs2.py
+++ b/doc/OnlineDocs/src/scripting/driveabs2.py
@@ -1,5 +1,16 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
-from __future__ import division
+
import pyomo.environ as pyo
from pyomo.opt import SolverFactory
diff --git a/doc/OnlineDocs/tests/scripting/driveconc1.py b/doc/OnlineDocs/src/scripting/driveconc1.py
similarity index 53%
rename from doc/OnlineDocs/tests/scripting/driveconc1.py
rename to doc/OnlineDocs/src/scripting/driveconc1.py
index ca5d6fc1593..49b92f32d09 100644
--- a/doc/OnlineDocs/tests/scripting/driveconc1.py
+++ b/doc/OnlineDocs/src/scripting/driveconc1.py
@@ -1,5 +1,16 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
-from __future__ import division
+
import pyomo.environ as pyo
from pyomo.opt import SolverFactory
diff --git a/doc/OnlineDocs/tests/scripting/iterative1.py b/doc/OnlineDocs/src/scripting/iterative1.py
similarity index 74%
rename from doc/OnlineDocs/tests/scripting/iterative1.py
rename to doc/OnlineDocs/src/scripting/iterative1.py
index 61b0fd3828e..939120e834f 100644
--- a/doc/OnlineDocs/tests/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/tests/scripting/iterative2.py b/doc/OnlineDocs/src/scripting/iterative2.py
similarity index 60%
rename from doc/OnlineDocs/tests/scripting/iterative2.py
rename to doc/OnlineDocs/src/scripting/iterative2.py
index e559a2c8400..7506337a491 100644
--- a/doc/OnlineDocs/tests/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/tests/scripting/noiteration1.py b/doc/OnlineDocs/src/scripting/noiteration1.py
similarity index 52%
rename from doc/OnlineDocs/tests/scripting/noiteration1.py
rename to doc/OnlineDocs/src/scripting/noiteration1.py
index be9fb529855..c7a86e9d1e9 100644
--- a/doc/OnlineDocs/tests/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/tests/scripting/parallel.py b/doc/OnlineDocs/src/scripting/parallel.py
similarity index 57%
rename from doc/OnlineDocs/tests/scripting/parallel.py
rename to doc/OnlineDocs/src/scripting/parallel.py
index cf9b55d9605..e6cfa002780 100644
--- a/doc/OnlineDocs/tests/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/tests/scripting/spy4Constraints.py b/doc/OnlineDocs/src/scripting/spy4Constraints.py
similarity index 64%
rename from doc/OnlineDocs/tests/scripting/spy4Constraints.py
rename to doc/OnlineDocs/src/scripting/spy4Constraints.py
index ac42b4d38b3..66f82802402 100644
--- a/doc/OnlineDocs/tests/scripting/spy4Constraints.py
+++ b/doc/OnlineDocs/src/scripting/spy4Constraints.py
@@ -1,7 +1,19 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
"""
+
from pyomo.environ import *
model = ConcreteModel()
diff --git a/doc/OnlineDocs/tests/scripting/spy4Expressions.py b/doc/OnlineDocs/src/scripting/spy4Expressions.py
similarity index 81%
rename from doc/OnlineDocs/tests/scripting/spy4Expressions.py
rename to doc/OnlineDocs/src/scripting/spy4Expressions.py
index d4a5cad321a..cf7ed1f112f 100644
--- a/doc/OnlineDocs/tests/scripting/spy4Expressions.py
+++ b/doc/OnlineDocs/src/scripting/spy4Expressions.py
@@ -1,7 +1,19 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
"""
+
from pyomo.environ import *
model = ConcreteModel()
diff --git a/doc/OnlineDocs/tests/scripting/spy4PyomoCommand.py b/doc/OnlineDocs/src/scripting/spy4PyomoCommand.py
similarity index 57%
rename from doc/OnlineDocs/tests/scripting/spy4PyomoCommand.py
rename to doc/OnlineDocs/src/scripting/spy4PyomoCommand.py
index c03ee1e5039..9f6698d63c9 100644
--- a/doc/OnlineDocs/tests/scripting/spy4PyomoCommand.py
+++ b/doc/OnlineDocs/src/scripting/spy4PyomoCommand.py
@@ -1,7 +1,19 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
"""
+
from pyomo.environ import *
model = ConcreteModel()
diff --git a/doc/OnlineDocs/tests/scripting/spy4Variables.py b/doc/OnlineDocs/src/scripting/spy4Variables.py
similarity index 52%
rename from doc/OnlineDocs/tests/scripting/spy4Variables.py
rename to doc/OnlineDocs/src/scripting/spy4Variables.py
index 802226247c5..1bc2dc9f1ef 100644
--- a/doc/OnlineDocs/tests/scripting/spy4Variables.py
+++ b/doc/OnlineDocs/src/scripting/spy4Variables.py
@@ -1,7 +1,19 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
"""
+
from pyomo.environ import *
model = ConcreteModel()
diff --git a/doc/OnlineDocs/tests/scripting/spy4scripts.py b/doc/OnlineDocs/src/scripting/spy4scripts.py
similarity index 91%
rename from doc/OnlineDocs/tests/scripting/spy4scripts.py
rename to doc/OnlineDocs/src/scripting/spy4scripts.py
index 48ba923d09c..f71a1b67b11 100644
--- a/doc/OnlineDocs/tests/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/tests/strip_examples.py b/doc/OnlineDocs/src/strip_examples.py
similarity index 78%
rename from doc/OnlineDocs/tests/strip_examples.py
rename to doc/OnlineDocs/src/strip_examples.py
index 045af6b87cc..2fd03256499 100644
--- a/doc/OnlineDocs/tests/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
new file mode 100644
index 00000000000..c5c9a135ee9
--- /dev/null
+++ b/doc/OnlineDocs/src/test_examples.py
@@ -0,0 +1,76 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
+import glob
+import os
+from pyomo.common.dependencies import attempt_import, matplotlib_available
+from pyomo.common.fileutils import this_file_dir
+import pyomo.environ as pyo
+
+
+currdir = this_file_dir()
+
+parameterized, param_available = attempt_import('parameterized')
+if not param_available:
+ raise unittest.SkipTest('Parameterized is not available.')
+
+# Needed for testing (triggers matplotlib import and switches its backend):
+bool(matplotlib_available)
+
+
+class TestOnlineDocExamples(unittest.BaselineTestDriver, unittest.TestCase):
+ # Only test files in directories ending in -ch. These directories
+ # contain the updated python and scripting files corresponding to
+ # each chapter in the book.
+ py_tests, sh_tests = unittest.BaselineTestDriver.gather_tests(
+ list(filter(os.path.isdir, glob.glob(os.path.join(currdir, '*'))))
+ )
+
+ solver_dependencies = {
+ 'test_data_pyomo_diet1': ['glpk'],
+ 'test_data_pyomo_diet2': ['glpk'],
+ 'test_kernel_examples': ['glpk'],
+ }
+ # Note on package dependencies: two tests actually need
+ # pyutilib.excel.spreadsheet; however, the pyutilib importer is
+ # broken on Python>=3.12, so instead of checking for spreadsheet, we
+ # will check for pyutilib.component, which triggers the importer
+ # (and catches the error on 3.12)
+ package_dependencies = {
+ # data
+ 'test_data_ABCD9': ['pyodbc'],
+ 'test_data_ABCD8': ['pyodbc'],
+ 'test_data_ABCD7': ['win32com', 'pyutilib.component'],
+ # dataportal
+ 'test_dataportal_dataportal_tab': ['xlrd', 'pyutilib.component'],
+ 'test_dataportal_set_initialization': ['numpy'],
+ 'test_dataportal_param_initialization': ['numpy'],
+ # kernel
+ 'test_kernel_examples': ['pympler'],
+ }
+
+ @parameterized.parameterized.expand(
+ sh_tests, name_func=unittest.BaselineTestDriver.custom_name_func
+ )
+ def test_sh(self, tname, test_file, base_file):
+ self.shell_test_driver(tname, test_file, base_file)
+
+ @parameterized.parameterized.expand(
+ py_tests, name_func=unittest.BaselineTestDriver.custom_name_func
+ )
+ def test_py(self, tname, test_file, base_file):
+ self.python_test_driver(tname, test_file, base_file)
+
+
+# Execute the tests
+if __name__ == '__main__':
+ unittest.main()
diff --git a/doc/OnlineDocs/tests/data/ABCD1.py b/doc/OnlineDocs/tests/data/ABCD1.py
deleted file mode 100644
index 32600b226e1..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD1.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.Z = Set(dimen=4)
-
-instance = model.create_instance('ABCD1.dat')
-
-print(sorted(list(instance.Z.data())))
diff --git a/doc/OnlineDocs/tests/data/ABCD2.py b/doc/OnlineDocs/tests/data/ABCD2.py
deleted file mode 100644
index 65a46415368..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD2.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.Z = Set(initialize=[('A1', 'B1', 1), ('A2', 'B2', 2), ('A3', 'B3', 3)])
-# model.Z = Set(dimen=3)
-model.D = Param(model.Z)
-
-instance = model.create_instance('ABCD2.dat')
-
-print('Z ' + str(sorted(list(instance.Z.data()))))
-print('D')
-for key in sorted(instance.D.keys()):
- print(name(instance.D, key) + " " + str(value(instance.D[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD3.py b/doc/OnlineDocs/tests/data/ABCD3.py
deleted file mode 100644
index 48797ced5bb..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD3.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.Z = Set(dimen=3)
-model.D = Param(model.Z)
-
-instance = model.create_instance('ABCD3.dat')
-
-print('Z ' + str(sorted(list(instance.Z.data()))))
-print('D')
-for key in sorted(instance.D.keys()):
- print(name(instance.D, key) + " " + str(value(instance.D[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD4.py b/doc/OnlineDocs/tests/data/ABCD4.py
deleted file mode 100644
index 20f6a21c011..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD4.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.Z = Set(dimen=3)
-model.Y = Param(model.Z)
-
-instance = model.create_instance('ABCD4.dat')
-
-print('Z ' + str(sorted(list(instance.Z.data()))))
-print('Y')
-for key in sorted(instance.Y.keys()):
- print(name(instance.Y, key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD5.py b/doc/OnlineDocs/tests/data/ABCD5.py
deleted file mode 100644
index 58461af056b..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD5.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.Z = Set()
-model.Y = Param(model.Z)
-model.W = Param(model.Z)
-# @decl
-
-instance = model.create_instance('ABCD5.dat')
-
-print('Z ' + str(sorted(list(instance.Z.data()))))
-print('Y')
-for key in sorted(instance.Y.keys()):
- print(name(instance.Y, key) + " " + str(value(instance.Y[key])))
-print('W')
-for key in sorted(instance.W.keys()):
- print(name(instance.W, key) + " " + str(value(instance.W[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD6.py b/doc/OnlineDocs/tests/data/ABCD6.py
deleted file mode 100644
index 961408dbc7e..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD6.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.Z = Set(dimen=3)
-model.D = Param(model.Z)
-
-instance = model.create_instance('ABCD6.dat')
-
-print('Z ' + str(sorted(list(instance.Z.data()))))
-print('D')
-for key in sorted(instance.D.keys()):
- print(name(instance.D, key) + " " + str(value(instance.D[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD7.py b/doc/OnlineDocs/tests/data/ABCD7.py
deleted file mode 100644
index a97e764fa5a..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD7.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from pyomo.environ import *
-import pyomo.common
-import sys
-
-model = AbstractModel()
-
-model.Z = Set(dimen=3)
-model.Y = Param(model.Z)
-
-try:
- instance = model.create_instance('ABCD7.dat')
-except pyomo.common.errors.ApplicationError as e:
- print("ERROR " + str(e))
- sys.exit(1)
-
-print('Z ' + str(sorted(list(instance.Z.data()))))
-print('Y')
-for key in sorted(instance.Y.keys()):
- print(name(instance.Y, key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD8.py b/doc/OnlineDocs/tests/data/ABCD8.py
deleted file mode 100644
index 9bcd950c681..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD8.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from pyomo.environ import *
-import pyomo.common
-import sys
-
-model = AbstractModel()
-
-model.Z = Set(dimen=3)
-model.Y = Param(model.Z)
-
-try:
- instance = model.create_instance('ABCD8.dat')
-except pyomo.common.errors.ApplicationError as e:
- print("ERROR " + str(e))
- sys.exit(1)
-
-print('Z ' + str(sorted(list(instance.Z.data()))))
-print('Y')
-for key in sorted(instance.Y.keys()):
- print(name(instance.Y, key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/ABCD9.py b/doc/OnlineDocs/tests/data/ABCD9.py
deleted file mode 100644
index 29fcb6426db..00000000000
--- a/doc/OnlineDocs/tests/data/ABCD9.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from pyomo.environ import *
-import pyomo.common
-import sys
-
-model = AbstractModel()
-
-model.Z = Set(dimen=3)
-model.Y = Param(model.Z)
-
-try:
- instance = model.create_instance('ABCD9.dat')
-except pyomo.common.errors.ApplicationError as e:
- print("ERROR " + str(e))
- sys.exit(1)
-
-print('Z ' + str(sorted(list(instance.Z.data()))))
-print('Y')
-for key in sorted(instance.Y.keys()):
- print(instance.Y[key] + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/ex.py b/doc/OnlineDocs/tests/data/ex.py
deleted file mode 100644
index 8c9473f2852..00000000000
--- a/doc/OnlineDocs/tests/data/ex.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.z = Param()
-# @decl
-
-instance = model.create_instance('ex.dat')
-
-print(value(instance.z))
diff --git a/doc/OnlineDocs/tests/data/import1.tab.py b/doc/OnlineDocs/tests/data/import1.tab.py
deleted file mode 100644
index c9164ab73ec..00000000000
--- a/doc/OnlineDocs/tests/data/import1.tab.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set(initialize=['A1', 'A2', 'A3', 'A4'])
-model.Y = Param(model.A)
-
-instance = model.create_instance('import1.tab.dat')
-
-print('Y')
-keys = instance.Y.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/import2.tab.py b/doc/OnlineDocs/tests/data/import2.tab.py
deleted file mode 100644
index d03f053d090..00000000000
--- a/doc/OnlineDocs/tests/data/import2.tab.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set()
-model.Y = Param(model.A)
-
-instance = model.create_instance('import2.tab.dat')
-
-print('A ' + str(sorted(list(instance.A.data()))))
-print('Y')
-keys = instance.Y.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.Y[key])))
diff --git a/doc/OnlineDocs/tests/data/import3.tab.py b/doc/OnlineDocs/tests/data/import3.tab.py
deleted file mode 100644
index e86557677ee..00000000000
--- a/doc/OnlineDocs/tests/data/import3.tab.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set()
-
-instance = model.create_instance('import3.tab.dat')
-
-print('A ' + str(sorted(list(instance.A.data()))))
diff --git a/doc/OnlineDocs/tests/data/import4.tab.py b/doc/OnlineDocs/tests/data/import4.tab.py
deleted file mode 100644
index 93df9c761ab..00000000000
--- a/doc/OnlineDocs/tests/data/import4.tab.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.C = Set(dimen=2)
-
-instance = model.create_instance('import4.tab.dat')
-
-print('C ' + str(sorted(list(instance.C.data()))))
diff --git a/doc/OnlineDocs/tests/data/import5.tab.py b/doc/OnlineDocs/tests/data/import5.tab.py
deleted file mode 100644
index 1d20476a16f..00000000000
--- a/doc/OnlineDocs/tests/data/import5.tab.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.B = Set(dimen=2)
-
-instance = model.create_instance('import5.tab.dat')
-
-print('B ' + str(list(sorted(instance.B.data()))))
diff --git a/doc/OnlineDocs/tests/data/import6.tab.py b/doc/OnlineDocs/tests/data/import6.tab.py
deleted file mode 100644
index 8a1ab232f86..00000000000
--- a/doc/OnlineDocs/tests/data/import6.tab.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.p = Param()
-
-instance = model.create_instance('import6.tab.dat')
-
-print('p ' + str(value(instance.p)))
diff --git a/doc/OnlineDocs/tests/data/import7.tab.py b/doc/OnlineDocs/tests/data/import7.tab.py
deleted file mode 100644
index 747d884be31..00000000000
--- a/doc/OnlineDocs/tests/data/import7.tab.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.I = Set(initialize=['I1', 'I2', 'I3', 'I4'])
-model.A = Set(initialize=['A1', 'A2', 'A3'])
-model.U = Param(model.I, model.A)
-# BUG: This should cause an error
-# model.U = Param(model.A,model.I)
-
-instance = model.create_instance('import7.tab.dat')
-
-print('I ' + str(sorted(list(instance.I.data()))))
-print('A ' + str(sorted(list(instance.A.data()))))
-print('U')
-for key in sorted(instance.U.keys()):
- print(name(instance.U, key) + " " + str(value(instance.U[key])))
diff --git a/doc/OnlineDocs/tests/data/import8.tab.py b/doc/OnlineDocs/tests/data/import8.tab.py
deleted file mode 100644
index b7866d7a3e5..00000000000
--- a/doc/OnlineDocs/tests/data/import8.tab.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.I = Set(initialize=['I1', 'I2', 'I3', 'I4'])
-model.A = Set(initialize=['A1', 'A2', 'A3'])
-model.U = Param(model.A, model.I)
-
-instance = model.create_instance('import8.tab.dat')
-
-print('A ' + str(sorted(list(instance.A.data()))))
-print('I ' + str(sorted(list(instance.I.data()))))
-print('U')
-for key in sorted(instance.U.keys()):
- print(name(instance.U, key) + " " + str(value(instance.U[key])))
diff --git a/doc/OnlineDocs/tests/data/param1.py b/doc/OnlineDocs/tests/data/param1.py
deleted file mode 100644
index c4bc8de5acc..00000000000
--- a/doc/OnlineDocs/tests/data/param1.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Param()
-model.B = Param()
-model.C = Param()
-model.D = Param()
-model.E = Param()
-# @decl
-
-instance = model.create_instance('param1.dat')
-
-print(value(instance.A))
-print(value(instance.B))
-print(value(instance.C))
-print(value(instance.D))
-print(value(instance.E))
diff --git a/doc/OnlineDocs/tests/data/param2.py b/doc/OnlineDocs/tests/data/param2.py
deleted file mode 100644
index f46f05ceebc..00000000000
--- a/doc/OnlineDocs/tests/data/param2.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set()
-model.B = Param(model.A)
-# @decl
-
-instance = model.create_instance('param2.dat')
-
-keys = instance.B.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param2a.py b/doc/OnlineDocs/tests/data/param2a.py
deleted file mode 100644
index 4557f63d841..00000000000
--- a/doc/OnlineDocs/tests/data/param2a.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set()
-model.B = Param(model.A)
-# @decl
-
-instance = model.create_instance('param2a.dat')
-
-keys = instance.B.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param4.py b/doc/OnlineDocs/tests/data/param4.py
deleted file mode 100644
index 1190dae8dec..00000000000
--- a/doc/OnlineDocs/tests/data/param4.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set()
-model.B = Param(model.A)
-# @decl
-
-instance = model.create_instance('param4.dat')
-
-print('B')
-keys = instance.B.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param5.py b/doc/OnlineDocs/tests/data/param5.py
deleted file mode 100644
index 69f6cc46552..00000000000
--- a/doc/OnlineDocs/tests/data/param5.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=2)
-model.B = Param(model.A)
-# @decl
-
-instance = model.create_instance('param5.dat')
-
-keys = instance.B.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param5a.py b/doc/OnlineDocs/tests/data/param5a.py
deleted file mode 100644
index 303b92f9f2e..00000000000
--- a/doc/OnlineDocs/tests/data/param5a.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=2)
-model.B = Param(model.A)
-# @decl
-
-instance = model.create_instance('param5a.dat')
-
-keys = instance.B.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param7a.py b/doc/OnlineDocs/tests/data/param7a.py
deleted file mode 100644
index 3bb68b3f3b7..00000000000
--- a/doc/OnlineDocs/tests/data/param7a.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=2)
-model.B = Param(model.A)
-# @decl
-
-instance = model.create_instance('param7a.dat')
-
-keys = instance.B.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param7b.py b/doc/OnlineDocs/tests/data/param7b.py
deleted file mode 100644
index 6e5c857851f..00000000000
--- a/doc/OnlineDocs/tests/data/param7b.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=2)
-model.B = Param(model.A)
-# @decl
-
-instance = model.create_instance('param7b.dat')
-
-keys = instance.B.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/param8a.py b/doc/OnlineDocs/tests/data/param8a.py
deleted file mode 100644
index 57c9b08ca43..00000000000
--- a/doc/OnlineDocs/tests/data/param8a.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=4)
-model.B = Param(model.A)
-# @decl
-
-instance = model.create_instance('param8a.dat')
-
-keys = instance.B.keys()
-for key in sorted(keys):
- print(str(key) + " " + str(value(instance.B[key])))
diff --git a/doc/OnlineDocs/tests/data/set1.py b/doc/OnlineDocs/tests/data/set1.py
deleted file mode 100644
index 5248e9d5dc9..00000000000
--- a/doc/OnlineDocs/tests/data/set1.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set()
-model.B = Set()
-model.C = Set()
-
-instance = model.create_instance('set1.dat')
-
-print(sorted(list(instance.A.data())))
-print(sorted((instance.B.data())))
-print(sorted(list((instance.C.data())), key=lambda x: x if type(x) is str else str(x)))
diff --git a/doc/OnlineDocs/tests/data/set2.py b/doc/OnlineDocs/tests/data/set2.py
deleted file mode 100644
index 82772f48e46..00000000000
--- a/doc/OnlineDocs/tests/data/set2.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=3)
-# @decl
-
-instance = model.create_instance('set2.dat')
-
-print(sorted(list(instance.A.data())))
diff --git a/doc/OnlineDocs/tests/data/set2a.py b/doc/OnlineDocs/tests/data/set2a.py
deleted file mode 100644
index edf28757f96..00000000000
--- a/doc/OnlineDocs/tests/data/set2a.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=3)
-# @decl
-
-instance = model.create_instance('set2a.dat')
-
-print(sorted(list(instance.A.data())))
diff --git a/doc/OnlineDocs/tests/data/set3.py b/doc/OnlineDocs/tests/data/set3.py
deleted file mode 100644
index d58e0c0dd43..00000000000
--- a/doc/OnlineDocs/tests/data/set3.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set()
-model.B = Set(model.A)
-# @decl
-# model.C = Set(model.A,model.A)
-
-instance = model.create_instance('set3.dat')
-
-print(sorted(list(instance.A.data()), key=lambda x: x if type(x) is str else str(x)))
-print(sorted(list(instance.B[1].data()), key=lambda x: x if type(x) is str else str(x)))
-print(
- sorted(
- list(instance.B['aaa'].data()), key=lambda x: x if type(x) is str else str(x)
- )
-)
diff --git a/doc/OnlineDocs/tests/data/set4.py b/doc/OnlineDocs/tests/data/set4.py
deleted file mode 100644
index 29548519571..00000000000
--- a/doc/OnlineDocs/tests/data/set4.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=2)
-# @decl
-
-instance = model.create_instance('set4.dat')
-
-print(sorted(list(instance.A.data())))
diff --git a/doc/OnlineDocs/tests/data/set5.py b/doc/OnlineDocs/tests/data/set5.py
deleted file mode 100644
index 35acd4e4317..00000000000
--- a/doc/OnlineDocs/tests/data/set5.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-# @decl
-model.A = Set(dimen=4)
-# @decl
-
-instance = model.create_instance('set5.dat')
-
-
-for tpl in sorted(list(instance.A.data()), key=lambda x: tuple(map(str, x))):
- print(tpl)
diff --git a/doc/OnlineDocs/tests/data/table0.py b/doc/OnlineDocs/tests/data/table0.py
deleted file mode 100644
index af7f634bd34..00000000000
--- a/doc/OnlineDocs/tests/data/table0.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set(initialize=['A1', 'A2', 'A3'])
-model.M = Param(model.A)
-
-instance = model.create_instance('table0.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table0.ul.py b/doc/OnlineDocs/tests/data/table0.ul.py
deleted file mode 100644
index 213407b071c..00000000000
--- a/doc/OnlineDocs/tests/data/table0.ul.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set(initialize=['A1', 'A2', 'A3'])
-model.M = Param(model.A)
-
-instance = model.create_instance('table0.ul.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table1.py b/doc/OnlineDocs/tests/data/table1.py
deleted file mode 100644
index 1f86508c60a..00000000000
--- a/doc/OnlineDocs/tests/data/table1.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set(initialize=['A1', 'A2', 'A3'])
-model.M = Param(model.A)
-
-instance = model.create_instance('table1.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table2.py b/doc/OnlineDocs/tests/data/table2.py
deleted file mode 100644
index d7708b9277f..00000000000
--- a/doc/OnlineDocs/tests/data/table2.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set(initialize=['A1', 'A2', 'A3'])
-model.B = Set(initialize=['B1', 'B2', 'B3'])
-
-model.M = Param(model.A)
-model.N = Param(model.A, model.B)
-
-instance = model.create_instance('table2.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table2.txt b/doc/OnlineDocs/tests/data/table2.txt
deleted file mode 100644
index 6621e27f70c..00000000000
--- a/doc/OnlineDocs/tests/data/table2.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-3 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- B : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['B1', 'B2', 'B3']
- N_index : Dim=0, Dimen=2, Size=9, Domain=None, Ordered=False, Bounds=None
- Virtual
-
-2 Param Declarations
- M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 4.3
- A2 : 4.4
- A3 : 4.5
- N : Size=3, Index=N_index, 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
diff --git a/doc/OnlineDocs/tests/data/table3.py b/doc/OnlineDocs/tests/data/table3.py
deleted file mode 100644
index fa871a4f79c..00000000000
--- a/doc/OnlineDocs/tests/data/table3.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set()
-model.B = Set(initialize=['B1', 'B2', 'B3'])
-model.Z = Set(dimen=2)
-
-model.M = Param(model.A)
-model.N = Param(model.A, model.B)
-
-
-instance = model.create_instance('table3.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table3.txt b/doc/OnlineDocs/tests/data/table3.txt
deleted file mode 100644
index e4194f6790d..00000000000
--- a/doc/OnlineDocs/tests/data/table3.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-4 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- B : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['B1', 'B2', 'B3']
- N_index : Dim=0, Dimen=2, Size=9, Domain=None, Ordered=False, Bounds=None
- Virtual
- Z : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
-
-2 Param Declarations
- M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 4.3
- A2 : 4.4
- A3 : 4.5
- N : Size=3, Index=N_index, 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
diff --git a/doc/OnlineDocs/tests/data/table3.ul.py b/doc/OnlineDocs/tests/data/table3.ul.py
deleted file mode 100644
index 713d36b9f3a..00000000000
--- a/doc/OnlineDocs/tests/data/table3.ul.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set()
-model.B = Set(initialize=['B1', 'B2', 'B3'])
-model.Z = Set(dimen=2)
-
-model.M = Param(model.A)
-model.N = Param(model.A, model.B)
-
-
-instance = model.create_instance('table3.ul.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table3.ul.txt b/doc/OnlineDocs/tests/data/table3.ul.txt
deleted file mode 100644
index e4194f6790d..00000000000
--- a/doc/OnlineDocs/tests/data/table3.ul.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-4 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- B : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['B1', 'B2', 'B3']
- N_index : Dim=0, Dimen=2, Size=9, Domain=None, Ordered=False, Bounds=None
- Virtual
- Z : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
-
-2 Param Declarations
- M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 4.3
- A2 : 4.4
- A3 : 4.5
- N : Size=3, Index=N_index, 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
diff --git a/doc/OnlineDocs/tests/data/table4.py b/doc/OnlineDocs/tests/data/table4.py
deleted file mode 100644
index 1af9fe47a44..00000000000
--- a/doc/OnlineDocs/tests/data/table4.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set()
-model.Z = Set(dimen=2)
-
-model.M = Param(model.A)
-model.N = Param(model.Z)
-
-instance = model.create_instance('table4.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table4.ul.py b/doc/OnlineDocs/tests/data/table4.ul.py
deleted file mode 100644
index 2acf8e21ca8..00000000000
--- a/doc/OnlineDocs/tests/data/table4.ul.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set()
-model.Z = Set(dimen=2)
-
-model.M = Param(model.A)
-model.N = Param(model.Z)
-
-instance = model.create_instance('table4.ul.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table5.py b/doc/OnlineDocs/tests/data/table5.py
deleted file mode 100644
index 2fe3d08fe91..00000000000
--- a/doc/OnlineDocs/tests/data/table5.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.Z = Set(dimen=2)
-model.Y = Set(dimen=2)
-
-instance = model.create_instance('table5.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table5.txt b/doc/OnlineDocs/tests/data/table5.txt
deleted file mode 100644
index 76d8c59010f..00000000000
--- a/doc/OnlineDocs/tests/data/table5.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-2 Set Declarations
- Y : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [(4.3, 5.3), (4.4, 5.4), (4.5, 5.5)]
- Z : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
-
-2 Declarations: Z Y
diff --git a/doc/OnlineDocs/tests/data/table6.py b/doc/OnlineDocs/tests/data/table6.py
deleted file mode 100644
index fcbc2f10860..00000000000
--- a/doc/OnlineDocs/tests/data/table6.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.pi = Param()
-
-instance = model.create_instance('table6.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table7.py b/doc/OnlineDocs/tests/data/table7.py
deleted file mode 100644
index f8f8e769b2e..00000000000
--- a/doc/OnlineDocs/tests/data/table7.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-
-model.A = Set(initialize=['A1', 'A2', 'A3'])
-model.M = Param(model.A)
-model.Z = Set(dimen=2)
-
-instance = model.create_instance('table7.dat')
-instance.pprint()
diff --git a/doc/OnlineDocs/tests/data/table7.txt b/doc/OnlineDocs/tests/data/table7.txt
deleted file mode 100644
index 275e8543528..00000000000
--- a/doc/OnlineDocs/tests/data/table7.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-2 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- Z : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
-
-1 Param Declarations
- M : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 4.3
- A2 : 4.4
- A3 : 4.5
-
-3 Declarations: A M Z
diff --git a/doc/OnlineDocs/tests/dataportal/dataportal_tab.txt b/doc/OnlineDocs/tests/dataportal/dataportal_tab.txt
deleted file mode 100644
index a3fa2bd8067..00000000000
--- a/doc/OnlineDocs/tests/dataportal/dataportal_tab.txt
+++ /dev/null
@@ -1,296 +0,0 @@
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-1 Declarations: A
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-1 Declarations: A
-1 Set Declarations
- C : Dim=0, Dimen=2, Size=9, Domain=None, Ordered=False, Bounds=None
- [('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)]
-
-1 Declarations: C
-1 Set Declarations
- D : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 1), ('A2', 2), ('A3', 3)]
-
-1 Declarations: D
-1 Param Declarations
- z : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
- Key : Value
- None : 1.1
-
-1 Declarations: z
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-1 Param Declarations
- y : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 3.3
- A2 : 3.4
- A3 : 3.5
-
-2 Declarations: A y
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-2 Param Declarations
- w : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 4.3
- A2 : 4.4
- A3 : 4.5
- x : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 3.3
- A2 : 3.4
- A3 : 3.5
-
-3 Declarations: A x w
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-1 Param Declarations
- y : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 3.3
- A2 : 3.4
- A3 : 3.5
-
-2 Declarations: A y
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-1 Param Declarations
- w : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 4.3
- A2 : 4.4
- A3 : 4.5
-
-2 Declarations: A w
-3 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- I : Dim=0, Dimen=1, Size=4, Domain=None, Ordered=False, Bounds=None
- ['I1', 'I2', 'I3', 'I4']
- u_index : Dim=0, Dimen=2, Size=12, Domain=None, Ordered=False, Bounds=None
- Virtual
-
-1 Param Declarations
- u : Size=12, Index=u_index, Domain=Any, Default=None, Mutable=False
- Key : Value
- ('I1', 'A1') : 1.3
- ('I1', 'A2') : 2.3
- ('I1', 'A3') : 3.3
- ('I2', 'A1') : 1.4
- ('I2', 'A2') : 2.4
- ('I2', 'A3') : 3.4
- ('I3', 'A1') : 1.5
- ('I3', 'A2') : 2.5
- ('I3', 'A3') : 3.5
- ('I4', 'A1') : 1.6
- ('I4', 'A2') : 2.6
- ('I4', 'A3') : 3.6
-
-4 Declarations: A I u_index u
-3 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- I : Dim=0, Dimen=1, Size=4, Domain=None, Ordered=False, Bounds=None
- ['I1', 'I2', 'I3', 'I4']
- t_index : Dim=0, Dimen=2, Size=12, Domain=None, Ordered=False, Bounds=None
- Virtual
-
-1 Param Declarations
- t : Size=12, Index=t_index, Domain=Any, Default=None, Mutable=False
- Key : Value
- ('A1', 'I1') : 1.3
- ('A1', 'I2') : 1.4
- ('A1', 'I3') : 1.5
- ('A1', 'I4') : 1.6
- ('A2', 'I1') : 2.3
- ('A2', 'I2') : 2.4
- ('A2', 'I3') : 2.5
- ('A2', 'I4') : 2.6
- ('A3', 'I1') : 3.3
- ('A3', 'I2') : 3.4
- ('A3', 'I3') : 3.5
- ('A3', 'I4') : 3.6
-
-4 Declarations: A I t_index t
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-1 Param Declarations
- s : Size=2, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 3.3
- A3 : 3.5
-
-2 Declarations: A s
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=4, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3', 'A4']
-
-1 Param Declarations
- y : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 3.3
- A2 : 3.4
- A3 : 3.5
-
-2 Declarations: A y
-1 Set Declarations
- A : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
-
-1 Param Declarations
- p : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- ('A1', 'B1') : 4.3
- ('A2', 'B2') : 4.4
- ('A3', 'B3') : 4.5
-
-2 Declarations: A p
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-1 Declarations: A
-1 Set Declarations
- y_index : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-2 Param Declarations
- y : Size=3, Index=y_index, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 3.3
- A2 : 3.4
- A3 : 3.5
- z : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
- Key : Value
- None : 1.1
-
-3 Declarations: z y_index y
-['A1', 'A2', 'A3']
-1.1
-A1 3.3
-A2 3.4
-A3 3.5
-1 Set Declarations
- A : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
-
-1 Param Declarations
- p : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- ('A1', 'B1') : 4.3
- ('A2', 'B2') : 4.4
- ('A3', 'B3') : 4.5
-
-2 Declarations: A p
-1 Set Declarations
- A : Dim=0, Dimen=2, Size=0, Domain=None, Ordered=False, Bounds=None
- []
-
-1 Param Declarations
- p : Size=0, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
-
-2 Declarations: A p
-1 Set Declarations
- A : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 'B1'), ('A2', 'B2'), ('A3', 'B3')]
-
-1 Param Declarations
- p : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- ('A1', 'B1') : 4.3
- ('A2', 'B2') : 4.4
- ('A3', 'B3') : 4.5
-
-2 Declarations: A p
-1 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
-
-1 Param Declarations
- p : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 4.3
- A2 : 4.4
- A3 : 4.5
-
-2 Declarations: A p
-3 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- B : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [(1, 'B1'), (2, 'B2'), (3, 'B3')]
- C : Dim=1, Dimen=1, Size=6, Domain=None, ArraySize=2, Ordered=False, Bounds=None
- Key : Members
- A1 : [1, 2, 3]
- A3 : [10, 20, 30]
-
-3 Param Declarations
- p : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
- Key : Value
- None : 0.1
- q : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 3.3
- A2 : 3.4
- A3 : 3.5
- r : Size=3, Index=B, Domain=Any, Default=None, Mutable=False
- Key : Value
- (1, 'B1') : 3.3
- (2, 'B2') : 3.4
- (3, 'B3') : 3.5
-
-6 Declarations: A B C p q r
-3 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=None
- ['A1', 'A2', 'A3']
- B : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [(1, 'B1'), (2, 'B2'), (3, 'B3')]
- C : Dim=1, Dimen=1, Size=6, Domain=None, ArraySize=2, Ordered=False, Bounds=None
- Key : Members
- A1 : [1, 2, 3]
- A3 : [10, 20, 30]
-
-3 Param Declarations
- p : Size=1, Index=None, Domain=Any, Default=None, Mutable=False
- Key : Value
- None : 0.1
- q : Size=3, Index=A, Domain=Any, Default=None, Mutable=False
- Key : Value
- A1 : 3.3
- A2 : 3.4
- A3 : 3.5
- r : Size=3, Index=B, Domain=Any, Default=None, Mutable=False
- Key : Value
- (1, 'B1') : 3.3
- (2, 'B2') : 3.4
- (3, 'B3') : 3.5
-
-6 Declarations: A B C p q r
-1 Set Declarations
- C : Dim=0, Dimen=2, Size=9, Domain=None, Ordered=False, Bounds=None
- [('A1', 1), ('A1', 2), ('A1', 3), ('A2', 1), ('A2', 2), ('A2', 3), ('A3', 1), ('A3', 2), ('A3', 3)]
-
-1 Declarations: C
-1 Set Declarations
- C : Dim=0, Dimen=2, Size=3, Domain=None, Ordered=False, Bounds=None
- [('A1', 1), ('A2', 2), ('A3', 3)]
-
-1 Declarations: C
diff --git a/doc/OnlineDocs/tests/dataportal/param_initialization.py b/doc/OnlineDocs/tests/dataportal/param_initialization.py
deleted file mode 100644
index 5567b01f284..00000000000
--- a/doc/OnlineDocs/tests/dataportal/param_initialization.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from pyomo.environ import *
-import numpy
-
-model = ConcreteModel()
-
-# @decl1
-model.a = Param(initialize=1.1)
-# @decl1
-
-# Initialize with a dictionary
-# @decl2
-model.b = Param([1, 2, 3], initialize={1: 1, 2: 2, 3: 3})
-# @decl2
-
-
-# Initialize with a function that returns native Python data
-# @decl3
-def c(model):
- return {1: 1, 2: 2, 3: 3}
-
-
-model.c = Param([1, 2, 3], initialize=c)
-# @decl3
-
-model.pprint(verbose=True)
diff --git a/doc/OnlineDocs/tests/dataportal/param_initialization.txt b/doc/OnlineDocs/tests/dataportal/param_initialization.txt
deleted file mode 100644
index baf24eac293..00000000000
--- a/doc/OnlineDocs/tests/dataportal/param_initialization.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-2 Set Declarations
- b_index : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(1, 3)
- [1, 2, 3]
- c_index : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(1, 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
- Key : Value
- 1 : 1
- 2 : 2
- 3 : 3
- c : Size=3, Index=c_index, Domain=Any, Default=None, Mutable=False
- Key : Value
- 1 : 1
- 2 : 2
- 3 : 3
-
-5 Declarations: a b_index b c_index c
diff --git a/doc/OnlineDocs/tests/dataportal/set_initialization.txt b/doc/OnlineDocs/tests/dataportal/set_initialization.txt
deleted file mode 100644
index 3bfbdad1cdc..00000000000
--- a/doc/OnlineDocs/tests/dataportal/set_initialization.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-9 Set Declarations
- A : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(2, 5)
- [2, 3, 5]
- B : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(2, 5)
- [2, 3, 5]
- C : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(2, 5)
- [2, 3, 5]
- D : Dim=0, Dimen=1, Size=9, Domain=None, Ordered=False, Bounds=(0, 8)
- [0, 1, 2, 3, 4, 5, 6, 7, 8]
- E : Dim=0, Dimen=1, Size=1, Domain=None, Ordered=False, Bounds=(2, 2)
- [2]
- F : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(2, 5)
- [2, 3, 5]
- G : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(2, 5)
- [2, 3, 5]
- H : Dim=1, Dimen=1, Size=9, Domain=None, ArraySize=3, Ordered=False, Bounds=None
- Key : Members
- 2 : [1, 3, 5]
- 3 : [2, 4, 6]
- 4 : [3, 5, 7]
- H_index : Dim=0, Dimen=1, Size=3, Domain=None, Ordered=False, Bounds=(2, 4)
- [2, 3, 4]
-
-9 Declarations: A B C D E F G H_index H
diff --git a/doc/OnlineDocs/tests/expr/index.py b/doc/OnlineDocs/tests/expr/index.py
deleted file mode 100644
index 9c9c79bf7be..00000000000
--- a/doc/OnlineDocs/tests/expr/index.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from pyomo.environ import *
-
-# ---------------------------------------------
-# @simple
-M = ConcreteModel()
-M.v = Var()
-
-e = M.v * 2
-# @simple
-print(e)
diff --git a/doc/OnlineDocs/tests/scripting/AbstractSuffixes.py b/doc/OnlineDocs/tests/scripting/AbstractSuffixes.py
deleted file mode 100644
index 20a4cc20581..00000000000
--- a/doc/OnlineDocs/tests/scripting/AbstractSuffixes.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from pyomo.environ import *
-
-model = AbstractModel()
-model.I = RangeSet(1, 4)
-model.x = Var(model.I)
-
-
-def c_rule(m, i):
- return m.x[i] >= i
-
-
-model.c = Constraint(model.I, rule=c_rule)
-
-
-def foo_rule(m):
- return ((m.x[i], 3.0 * i) for i in m.I)
-
-
-model.foo = Suffix(rule=foo_rule)
-
-# instantiate the model
-inst = model.create_instance()
-for i in inst.I:
- print(i, inst.foo[inst.x[i]])
diff --git a/doc/OnlineDocs/tests/scripting/NodesIn_init.py b/doc/OnlineDocs/tests/scripting/NodesIn_init.py
deleted file mode 100644
index 4a90029baa3..00000000000
--- a/doc/OnlineDocs/tests/scripting/NodesIn_init.py
+++ /dev/null
@@ -1,9 +0,0 @@
-def NodesIn_init(model, node):
- retval = []
- for i, j in model.Arcs:
- if j == node:
- retval.append(i)
- return retval
-
-
-model.NodesIn = Set(model.Nodes, initialize=NodesIn_init)
diff --git a/doc/OnlineDocs/tests/scripting/Z_init.py b/doc/OnlineDocs/tests/scripting/Z_init.py
deleted file mode 100644
index 426de6f7d08..00000000000
--- a/doc/OnlineDocs/tests/scripting/Z_init.py
+++ /dev/null
@@ -1,7 +0,0 @@
-def Z_init(model, i):
- if i > 10:
- return Set.End
- return 2 * i + 1
-
-
-model.Z = Set(initialize=Z_init)
diff --git a/doc/OnlineDocs/tests/scripting/concrete1.py b/doc/OnlineDocs/tests/scripting/concrete1.py
deleted file mode 100644
index 1c1f1517e17..00000000000
--- a/doc/OnlineDocs/tests/scripting/concrete1.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from __future__ import division
-from pyomo.environ import *
-
-model = ConcreteModel()
-
-model.x = Var([1, 2], domain=NonNegativeReals)
-
-model.OBJ = Objective(expr=2 * model.x[1] + 3 * model.x[2])
-
-model.Constraint1 = Constraint(expr=3 * model.x[1] + 4 * model.x[2] >= 1)
diff --git a/doc/OnlineDocs/tests/scripting/doubleA.py b/doc/OnlineDocs/tests/scripting/doubleA.py
deleted file mode 100644
index 12a07944db3..00000000000
--- a/doc/OnlineDocs/tests/scripting/doubleA.py
+++ /dev/null
@@ -1,5 +0,0 @@
-def doubleA_init(model):
- return (i * 2 for i in model.A)
-
-
-model.C = Set(initialize=DoubleA_init)
diff --git a/doc/OnlineDocs/tests/test_examples.py b/doc/OnlineDocs/tests/test_examples.py
deleted file mode 100644
index 0ee6a249c38..00000000000
--- a/doc/OnlineDocs/tests/test_examples.py
+++ /dev/null
@@ -1,270 +0,0 @@
-# Imports
-import pyomo.common.unittest as unittest
-import glob
-import os
-import os.path
-import sys
-import pyomo.environ
-
-try:
- import yaml
-
- yaml_available = True
-except:
- yaml_available = False
-
-# Find all *.txt files, and use them to define baseline tests
-currdir = os.path.dirname(os.path.abspath(__file__))
-datadir = currdir
-testdirs = [currdir]
-
-solver_dependencies = {
- 'Test_nonlinear_ch': {
- 'test_rosen_pyomo_rosen': 'ipopt',
- 'test_react_design_run_pyomo_reactor_table': 'ipopt',
- 'test_react_design_run_pyomo_reactor': 'ipopt',
- 'test_multimodal_pyomo_multimodal_init1': 'ipopt',
- 'test_multimodal_pyomo_multimodal_init2': 'ipopt',
- 'test_disease_est_run_disease_summary': 'ipopt',
- 'test_disease_est_run_disease_callback': 'ipopt',
- 'test_deer_run_deer': 'ipopt',
- },
- 'Test_mpec_ch': {'test_mpec_ch_path1': 'path'},
- 'Test_dae_ch': {'test_run_path_constraint_tester': 'ipopt'},
-}
-package_dependencies = {
- 'Test_data': {
- 'test_data_ABCD9': ['pyodbc'],
- 'test_data_ABCD8': ['pyodbc'],
- 'test_data_ABCD7': ['win32com'],
- },
- 'Test_dataportal': {
- 'test_dataportal_dataportal_tab': ['xlrd'],
- 'test_dataportal_set_initialization': ['numpy'],
- 'test_dataportal_param_initialization': ['numpy'],
- },
-}
-solver_available = {}
-package_available = {}
-
-only_book_tests = set(['Test_nonlinear_ch', 'Test_scripts_ch'])
-
-
-def _check_available(name):
- from pyomo.opt.base.solvers import check_available_solvers
-
- return bool(check_available_solvers(name))
-
-
-def check_skip(tfname_, name):
- #
- # Skip if YAML isn't installed
- #
- if not yaml_available:
- return "YAML is not available"
- #
- # Initialize the availability data
- #
- if len(solver_available) == 0:
- for tf_ in solver_dependencies:
- for n_ in solver_dependencies[tf_]:
- solver_ = solver_dependencies[tf_][n_]
- if not solver_ in solver_available:
- solver_available[solver_] = _check_available(solver_)
- for tf_ in package_dependencies:
- for n_ in package_dependencies[tf_]:
- packages_ = package_dependencies[tf_][n_]
- for package_ in packages_:
- if not package_ in package_available:
- try:
- __import__(package_)
- package_available[package_] = True
- except:
- package_available[package_] = False
- #
- # Return a boolean if the test should be skipped
- #
- if tfname_ in solver_dependencies:
- if (
- name in solver_dependencies[tfname_]
- and not solver_available[solver_dependencies[tfname_][name]]
- ):
- # Skip the test because a solver is not available
- # print('Skipping %s because of missing solver' %(name))
- return 'Solver "%s" is not available' % (
- solver_dependencies[tfname_][name],
- )
- if tfname_ in package_dependencies:
- if name in package_dependencies[tfname_]:
- packages_ = package_dependencies[tfname_][name]
- if not all([package_available[i] for i in packages_]):
- # Skip the test because a package is not available
- # print('Skipping %s because of missing package' %(name))
- _missing = []
- for i in packages_:
- if not package_available[i]:
- _missing.append(i)
- return "Package%s %s %s not available" % (
- 's' if len(_missing) > 1 else '',
- ", ".join(_missing),
- 'are' if len(_missing) > 1 else 'is',
- )
- return False
-
-
-def filter(line):
- # Ignore certain text when comparing output with baseline
-
- # Ipopt 3.12.4 puts BACKSPACE (chr(8) / ^H) into the output.
- line = line.strip(" \n\t" + chr(8))
-
- if not line:
- return True
- for field in (
- '[',
- 'password:',
- 'http:',
- 'Job ',
- 'Importing module',
- 'Function',
- 'File',
- ):
- if line.startswith(field):
- return True
- for field in (
- 'Total CPU',
- 'Ipopt',
- 'Status: optimal',
- 'Status: feasible',
- 'time:',
- 'Time:',
- 'with format cpxlp',
- 'usermodel = `_
+* `Pyomo — Optimization Modeling in Python
+ `_ ([PyomoBookIII]_)
-`Pyomo Gallery
-`_
+* `Pyomo Workshop Slides and Exercises
+ `_
+
+* `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/BuildAction.rst b/doc/OnlineDocs/working_abstractmodels/BuildAction.rst
index 5706ce97e6f..6840e15a1d5 100644
--- a/doc/OnlineDocs/working_abstractmodels/BuildAction.rst
+++ b/doc/OnlineDocs/working_abstractmodels/BuildAction.rst
@@ -13,7 +13,7 @@ trigger actions to be done as part of the model building process. The
takes as arguments optional index sets and a function to perform the
action. For example,
-.. literalinclude:: ../tests/scripting/abstract2piecebuild_BuildAction_example.spy
+.. literalinclude:: ../src/scripting/abstract2piecebuild_BuildAction_example.spy
:language: python
calls the function ``bpts_build`` for each member of ``model.J``. The
@@ -21,14 +21,14 @@ function ``bpts_build`` should have the model and a variable for the
members of ``model.J`` as formal arguments. In this example, the
following would be a valid declaration for the function:
-.. literalinclude:: ../tests/scripting/abstract2piecebuild_Function_valid_declaration.spy
+.. literalinclude:: ../src/scripting/abstract2piecebuild_Function_valid_declaration.spy
:language: python
A full example, which extends the :ref:`abstract2.py` and
:ref:`abstract2piece.py` examples, is
-.. literalinclude:: ../tests/scripting/abstract2piecebuild.spy
+.. literalinclude:: ../src/scripting/abstract2piecebuild.spy
:language: python
This example uses the build action to create a model component with
@@ -51,13 +51,13 @@ clearer, to use a build action.
The full model is:
-.. literalinclude:: ../tests/scripting/Isinglebuild.py
+.. literalinclude:: ../src/scripting/Isinglebuild.py
:language: python
for this model, the same data file can be used as for Isinglecomm.py in
:ref:`Isinglecomm.py` such as the toy data file:
-.. literalinclude:: ../tests/scripting/Isinglecomm.dat
+.. literalinclude:: ../src/scripting/Isinglecomm.dat
Build actions can also be a way to implement data validation,
particularly when multiple Sets or Parameters must be analyzed. However,
diff --git a/doc/OnlineDocs/working_abstractmodels/data/dataportals.rst b/doc/OnlineDocs/working_abstractmodels/data/dataportals.rst
index 88b89653a37..5ce907fda2a 100644
--- a/doc/OnlineDocs/working_abstractmodels/data/dataportals.rst
+++ b/doc/OnlineDocs/working_abstractmodels/data/dataportals.rst
@@ -62,14 +62,14 @@ can be used to initialize both concrete and abstract Pyomo models.
Consider the file ``A.tab``, which defines a simple set with a tabular
format:
-.. literalinclude:: ../../tests/dataportal/A.tab
+.. literalinclude:: ../../src/dataportal/A.tab
:language: none
The ``load`` method is used to load data into a :class:`~pyomo.environ.DataPortal` object. Components in a
concrete model can be explicitly initialized with data loaded by a
:class:`~pyomo.environ.DataPortal` object:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_concrete1.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_concrete1.spy
:language: python
All data needed to initialize an abstract model *must* be provided by a
@@ -77,7 +77,7 @@ All data needed to initialize an abstract model *must* be provided by a
and the use of the :class:`~pyomo.environ.DataPortal` object to initialize components
is automated for the user:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_load.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_load.spy
:language: python
Note the difference in the execution of the ``load`` method in these two
@@ -126,7 +126,7 @@ that are loaded from different data sources. The ``[]`` operator is
used to access set and parameter values. Consider the following
example, which loads data and prints the value of the ``[]`` operator:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_getitem.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_getitem.spy
:language: python
The :class:`~pyomo.environ.DataPortal`
@@ -162,12 +162,12 @@ with lists and dictionaries:
For example, consider the following JSON file:
-.. literalinclude:: ../../tests/dataportal/T.json
+.. literalinclude:: ../../src/dataportal/T.json
:language: none
The data in this file can be used to load the following model:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_json1.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_json1.spy
:language: python
Note that no ``set`` or ``param`` option needs to be specified when
@@ -178,13 +178,13 @@ needed for model construction is used.
The following YAML file has a similar structure:
-.. literalinclude:: ../../tests/dataportal/T.yaml
+.. literalinclude:: ../../src/dataportal/T.yaml
:language: none
The data in this file can be used to load a Pyomo model with the
same syntax as a JSON file:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_yaml1.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_yaml1.spy
:language: python
@@ -212,7 +212,7 @@ TAB files represent tabular data in an ascii file using whitespace as a
delimiter. A TAB file consists of rows of values, where each row has
the same length. For example, the file ``PP.tab`` has the format:
-.. literalinclude:: ../../tests/dataportal/PP.tab
+.. literalinclude:: ../../src/dataportal/PP.tab
:language: none
CSV files represent tabular data in a format that is very similar to TAB
@@ -220,7 +220,7 @@ files. Pyomo assumes that a CSV file consists of rows of values, where
each row has the same length. For example, the file ``PP.csv`` has the
format:
-.. literalinclude:: ../../tests/dataportal/PP.csv
+.. literalinclude:: ../../src/dataportal/PP.csv
:language: none
Excel spreadsheets can express complex data relationships. A *range* is
@@ -242,7 +242,7 @@ sub-element of a ``row`` element represents a different column, where
each row has the same length. For example, the file ``PP.xml`` has the
format:
-.. literalinclude:: ../../tests/dataportal/PP.xml
+.. literalinclude:: ../../src/dataportal/PP.xml
:language: none
Loading Set Data
@@ -256,13 +256,13 @@ Loading a Simple Set
Consider the file ``A.tab``, which defines a simple set:
-.. literalinclude:: ../../tests/dataportal/A.tab
+.. literalinclude:: ../../src/dataportal/A.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for a simple
set ``A``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_set1.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_set1.spy
:language: python
Loading a Set of Tuples
@@ -270,13 +270,13 @@ Loading a Set of Tuples
Consider the file ``C.tab``:
-.. literalinclude:: ../../tests/dataportal/C.tab
+.. literalinclude:: ../../src/dataportal/C.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for a
two-dimensional set ``C``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_set2.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_set2.spy
:language: python
In this example, the column titles do not directly impact the process of
@@ -289,13 +289,13 @@ Loading a Set Array
Consider the file ``D.tab``, which defines an array representation of a
two-dimensional set:
-.. literalinclude:: ../../tests/dataportal/D.tab
+.. literalinclude:: ../../src/dataportal/D.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for a
two-dimensional set ``D``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_set3.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_set3.spy
:language: python
The ``format`` option indicates that the set data is declared in a array
@@ -313,13 +313,13 @@ Loading a Simple Parameter
The simplest parameter is simply a singleton value. Consider the file
``Z.tab``:
-.. literalinclude:: ../../tests/dataportal/Z.tab
+.. literalinclude:: ../../src/dataportal/Z.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for a simple
parameter ``z``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param1.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param1.spy
:language: python
Loading an Indexed Parameter
@@ -328,13 +328,13 @@ Loading an Indexed Parameter
An indexed parameter can be defined by a single column in a table. For
example, consider the file ``Y.tab``:
-.. literalinclude:: ../../tests/dataportal/Y.tab
+.. literalinclude:: ../../src/dataportal/Y.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for an indexed
parameter ``y``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param2.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param2.spy
:language: python
When column names are not used to specify the index and parameter data,
@@ -351,19 +351,19 @@ The index set can be loaded with the parameter data using the ``index``
option. In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for set ``A``
and the indexed parameter ``y``
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param3.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param3.spy
:language: python
An index set with multiple dimensions can also be loaded with an indexed
parameter. Consider the file ``PP.tab``:
-.. literalinclude:: ../../tests/dataportal/PP.tab
+.. literalinclude:: ../../src/dataportal/PP.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for a tuple
set and an indexed parameter:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param10.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param10.spy
:language: python
Loading a Parameter with Missing Values
@@ -373,7 +373,7 @@ Missing parameter data can be expressed in two ways. First, parameter
data can be defined with indices that are a subset of valid indices in
the model. The following example loads the indexed parameter ``y``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param9.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param9.spy
:language: python
The model defines an index set with four values, but only three
@@ -382,13 +382,13 @@ parameter values are declared in the data file ``Y.tab``.
Parameter data can also be declared with missing values using the period
(``.``) symbol. For example, consider the file ``S.tab``:
-.. literalinclude:: ../../tests/dataportal/PP.tab
+.. literalinclude:: ../../src/dataportal/PP.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for the index
set ``A`` and indexed parameter ``y``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param8.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param8.spy
:language: python
The period (``.``) symbol indicates a missing parameter value, but the
@@ -400,13 +400,13 @@ Loading Multiple Parameters
Multiple parameters can be initialized at once by specifying a list (or
tuple) of component parameters. Consider the file ``XW.tab``:
-.. literalinclude:: ../../tests/dataportal/XW.tab
+.. literalinclude:: ../../src/dataportal/XW.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for parameters
``x`` and ``w``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param4.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param4.spy
:language: python
Selecting Parameter Columns
@@ -421,7 +421,7 @@ component data.
For example, consider the following load declaration:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param5.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param5.spy
:language: python
The columns ``A`` and ``W`` are selected from the file ``XW.tab``, and a
@@ -433,20 +433,20 @@ Loading a Parameter Array
Consider the file ``U.tab``, which defines an array representation of a
multiply-indexed parameter:
-.. literalinclude:: ../../tests/dataportal/U.tab
+.. literalinclude:: ../../src/dataportal/U.tab
:language: none
In the following example, a :class:`~pyomo.environ.DataPortal` object loads data for a
two-dimensional parameter ``u``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param6.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param6.spy
:language: python
The ``format`` option indicates that the parameter data is declared in a
array format. The ``format`` option can also indicate that the
parameter data should be transposed.
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_param7.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_param7.spy
:language: python
Note that the transposed parameter data changes the index set for the
@@ -467,7 +467,7 @@ the following range of cells, which is named ``PPtable``:
In the following example, a :class:`~pyomo.environ.DataPortal` object loads the named range
``PPtable`` from the file ``excel.xls``:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_excel1.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_excel1.spy
:language: python
Note that the ``range`` option is required to specify the table of cell
@@ -477,14 +477,14 @@ There are a variety of ways that data can be loaded from a relational
database. In the simplest case, a table can be specified within a
database:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_db1.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_db1.spy
:language: python
In this example, the interface ``sqlite3`` is used to load data from an
SQLite database in the file ``PP.sqlite``. More generally, an SQL query
can be specified to dynamically generate a table. For example:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_db2.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_db2.spy
:language: python
Data Namespaces
@@ -524,7 +524,7 @@ components. For example, the following script generates two model
instances from an abstract model using data loaded into different
namespaces:
-.. literalinclude:: ../../tests/dataportal/dataportal_tab_namespaces1.spy
+.. literalinclude:: ../../src/dataportal/dataportal_tab_namespaces1.spy
:language: python
diff --git a/doc/OnlineDocs/working_abstractmodels/data/datfiles.rst b/doc/OnlineDocs/working_abstractmodels/data/datfiles.rst
index 06d28093cf4..4982ed2fff0 100644
--- a/doc/OnlineDocs/working_abstractmodels/data/datfiles.rst
+++ b/doc/OnlineDocs/working_abstractmodels/data/datfiles.rst
@@ -104,7 +104,7 @@ A set may be empty, and it may contain any combination of numeric and
non-numeric string values. For example, the following are valid ``set``
commands:
-.. literalinclude:: ../../tests/data/set1.dat
+.. literalinclude:: ../../src/data/set1.dat
:language: python
@@ -115,19 +115,19 @@ The ``set`` data command can also specify tuple data with the standard
notation for tuples. For example, suppose that set ``A`` contains
3-tuples:
-.. literalinclude:: ../../tests/data/set2_decl.spy
+.. literalinclude:: ../../src/data/set2_decl.spy
:language: python
The following ``set`` data command then specifies that ``A`` is the set
containing the tuples ``(1,2,3)`` and ``(4,5,6)``:
-.. literalinclude:: ../../tests/data/set2a.dat
+.. literalinclude:: ../../src/data/set2a.dat
:language: none
Alternatively, set data can simply be listed in the order that the tuple
is represented:
-.. literalinclude:: ../../tests/data/set2.dat
+.. literalinclude:: ../../src/data/set2.dat
:language: none
Obviously, the number of data elements specified using this syntax
@@ -138,7 +138,7 @@ membership. For example, the following ``set`` data command declares
2-tuples in ``A`` using plus (``+``) to denote valid tuples and minus
(``-``) to denote invalid tuples:
-.. literalinclude:: ../../tests/data/set4.dat
+.. literalinclude:: ../../src/data/set4.dat
:language: none
This data command declares the following five 2-tuples: ``('A1',1)``,
@@ -148,13 +148,13 @@ Finally, a set of tuple data can be concisely represented with tuple
*templates* that represent a *slice* of tuple data. For example,
suppose that the set ``A`` contains 4-tuples:
-.. literalinclude:: ../../tests/data/set5_decl.spy
+.. literalinclude:: ../../src/data/set5_decl.spy
:language: python
The following ``set`` data command declares groups of tuples that are
defined by a template and data to complete this template:
-.. literalinclude:: ../../tests/data/set5.dat
+.. literalinclude:: ../../src/data/set5.dat
:language: none
A tuple template consists of a tuple that contains one or more asterisk
@@ -163,7 +163,7 @@ tuple value is replaced by the values from the list of values that
follows the tuple template. In this example, the following tuples are
in set ``A``:
-.. literalinclude:: ../../tests/data/set5.txt
+.. literalinclude:: ../../src/data/set5.txt
:language: none
Set Arrays
@@ -183,12 +183,12 @@ list of string values.
Suppose that a set ``A`` is used to index a set ``B`` as follows:
-.. literalinclude:: ../../tests/data/set3_decl.spy
+.. literalinclude:: ../../src/data/set3_decl.spy
:language: python
Then set ``B`` is indexed using the values declared for set ``A``:
-.. literalinclude:: ../../tests/data/set3.dat
+.. literalinclude:: ../../src/data/set3.dat
:language: none
The ``param`` Command
@@ -197,7 +197,7 @@ The ``param`` Command
Simple or non-indexed parameters are declared in an obvious way, as
shown by these examples:
-.. literalinclude:: ../../tests/data/param1.dat
+.. literalinclude:: ../../src/data/param1.dat
:language: none
Parameters can be defined with numeric data, simple strings and quoted
@@ -213,33 +213,33 @@ parameter data. One-dimensional parameter data is indexed over a single
set. Suppose that the parameter ``B`` is a parameter indexed by the set
``A``:
-.. literalinclude:: ../../tests/data/param2_decl.spy
+.. literalinclude:: ../../src/data/param2_decl.spy
:language: python
A ``param`` data command can specify values for ``B`` with a list of
index-value pairs:
-.. literalinclude:: ../../tests/data/param2.dat
+.. literalinclude:: ../../src/data/param2.dat
:language: none
Because whitespace is ignored, this example data command file can be
reorganized to specify the same data in a tabular format:
-.. literalinclude:: ../../tests/data/param2a.dat
+.. literalinclude:: ../../src/data/param2a.dat
:language: none
Multiple parameters can be defined using a single ``param`` data
command. For example, suppose that parameters ``B``, ``C``, and ``D``
are one-dimensional parameters all indexed by the set ``A``:
-.. literalinclude:: ../../tests/data/param3_decl.spy
+.. literalinclude:: ../../src/data/param3_decl.spy
:language: python
Values for these parameters can be specified using a single ``param``
data command that declares these parameter names followed by a list of
index and parameter values:
-.. literalinclude:: ../../tests/data/param3.dat
+.. literalinclude:: ../../src/data/param3.dat
:language: none
The values in the ``param`` data command are interpreted as a list of
@@ -249,7 +249,7 @@ corresponding numeric value.
Note that parameter values do not need to be defined for all indices.
For example, the following data command file is valid:
-.. literalinclude:: ../../tests/data/param3a.dat
+.. literalinclude:: ../../src/data/param3a.dat
:language: none
The index ``g`` is omitted from the ``param`` command, and consequently
@@ -259,7 +259,7 @@ More complex patterns of missing data can be specified using the period
specifying multiple parameters that do not necessarily have the same
index values:
-.. literalinclude:: ../../tests/data/param3b.dat
+.. literalinclude:: ../../src/data/param3b.dat
:language: none
This example provides a concise representation of parameters that share
@@ -270,13 +270,13 @@ Note that this data file specifies the data for set ``A`` twice:
defined. An alternate syntax for ``param`` allows the user to concisely
specify the definition of an index set along with associated parameters:
-.. literalinclude:: ../../tests/data/param3c.dat
+.. literalinclude:: ../../src/data/param3c.dat
:language: none
Finally, we note that default values for missing data can also be
specified using the ``default`` keyword:
-.. literalinclude:: ../../tests/data/param4.dat
+.. literalinclude:: ../../src/data/param4.dat
:language: none
Note that default values can only be specified in ``param`` commands
@@ -290,58 +290,58 @@ Multi-dimensional parameter data is indexed over either multiple sets or
a single multi-dimensional set. Suppose that parameter ``B`` is a
parameter indexed by set ``A`` that has dimension 2:
-.. literalinclude:: ../../tests/data/param5_decl.spy
+.. literalinclude:: ../../src/data/param5_decl.spy
:language: python
The syntax of the ``param`` data command remains essentially the same
when specifying values for ``B`` with a list of index and parameter
values:
-.. literalinclude:: ../../tests/data/param5.dat
+.. literalinclude:: ../../src/data/param5.dat
:language: none
Missing and default values are also handled in the same way with
multi-dimensional index sets:
-.. literalinclude:: ../../tests/data/param5a.dat
+.. literalinclude:: ../../src/data/param5a.dat
:language: none
Similarly, multiple parameters can defined with a single ``param`` data
command. Suppose that parameters ``B``, ``C``, and ``D`` are parameters
indexed over set ``A`` that has dimension 2:
-.. literalinclude:: ../../tests/data/param6_decl.spy
+.. literalinclude:: ../../src/data/param6_decl.spy
:language: python
These parameters can be defined with a single ``param`` command that
declares the parameter names followed by a list of index and parameter
values:
-.. literalinclude:: ../../tests/data/param6.dat
+.. literalinclude:: ../../src/data/param6.dat
:language: none
Similarly, the following ``param`` data command defines the index set
along with the parameters:
-.. literalinclude:: ../../tests/data/param6a.dat
+.. literalinclude:: ../../src/data/param6a.dat
:language: none
The ``param`` command also supports a matrix syntax for specifying the
values in a parameter that has a 2-dimensional index. Suppose parameter
``B`` is indexed over set ``A`` that has dimension 2:
-.. literalinclude:: ../../tests/data/param7a_decl.spy
+.. literalinclude:: ../../src/data/param7a_decl.spy
:language: python
The following ``param`` command defines a matrix of parameter values:
-.. literalinclude:: ../../tests/data/param7a.dat
+.. literalinclude:: ../../src/data/param7a.dat
:language: none
Additionally, the following syntax can be used to specify a transposed
matrix of parameter values:
-.. literalinclude:: ../../tests/data/param7b.dat
+.. literalinclude:: ../../src/data/param7b.dat
:language: none
This functionality facilitates the presentation of parameter data in a
@@ -355,13 +355,13 @@ be specified as a series of slices. Each slice is defined by a template
followed by a list of index and parameter values. Suppose that
parameter ``B`` is indexed over set ``A`` that has dimension 4:
-.. literalinclude:: ../../tests/data/param8a_decl.spy
+.. literalinclude:: ../../src/data/param8a_decl.spy
:language: python
The following ``param`` command defines a matrix of parameter values
with multiple templates:
-.. literalinclude:: ../../tests/data/param8a.dat
+.. literalinclude:: ../../src/data/param8a.dat
:language: none
The ``B`` parameter consists of four values: ``B[a,1,a,1]=10``,
@@ -376,7 +376,7 @@ data declaration than is possible with a ``param`` declaration. The
following example illustrates a simple ``table`` command that declares
data for a single parameter:
-.. literalinclude:: ../../tests/data/table0.dat
+.. literalinclude:: ../../src/data/table0.dat
:language: none
The parameter ``M`` is indexed by column ``A``, which must be
@@ -385,20 +385,20 @@ are provided after the colon and before the colon-equal (``:=``).
Subsequently, the table data is provided. The syntax is not sensitive
to whitespace, so the following is an equivalent ``table`` command:
-.. literalinclude:: ../../tests/data/table1.dat
+.. literalinclude:: ../../src/data/table1.dat
:language: none
Multiple parameters can be declared by simply including additional
parameter names. For example:
-.. literalinclude:: ../../tests/data/table2.dat
+.. literalinclude:: ../../src/data/table2.dat
:language: none
This example declares data for the ``M`` and ``N`` parameters, which
have different indexing columns. The indexing columns represent set
data, which is specified separately. For example:
-.. literalinclude:: ../../tests/data/table3.dat
+.. literalinclude:: ../../src/data/table3.dat
:language: none
This example declares data for the ``M`` and ``N`` parameters, along
@@ -406,12 +406,12 @@ with the ``A`` and ``Z`` indexing sets. The correspondence between the
index set ``Z`` and the indices of parameter ``N`` can be made more
explicit by indexing ``N`` by ``Z``:
-.. literalinclude:: ../../tests/data/table4.dat
+.. literalinclude:: ../../src/data/table4.dat
:language: none
Set data can also be specified independent of parameter data:
-.. literalinclude:: ../../tests/data/table5.dat
+.. literalinclude:: ../../src/data/table5.dat
:language: none
.. warning::
@@ -423,13 +423,13 @@ Set data can also be specified independent of parameter data:
that is initialized. For example, the ``table`` command initializes
a set ``Z`` and a parameter ``M`` that are not related:
- .. literalinclude:: ../../tests/data/table7.dat
+ .. literalinclude:: ../../src/data/table7.dat
:language: none
Finally, simple parameter values can also be specified with a ``table``
command:
-.. literalinclude:: ../../tests/data/table6.dat
+.. literalinclude:: ../../src/data/table6.dat
:language: none
The previous examples considered examples of the ``table`` command where
@@ -437,7 +437,7 @@ column labels are provided. The ``table`` command can also be used
without column labels. For example, the first example can be revised to
omit column labels as follows:
-.. literalinclude:: ../../tests/data/table0.ul.dat
+.. literalinclude:: ../../src/data/table0.ul.dat
:language: none
The ``columns=4`` is a keyword-value pair that defines the number of
@@ -450,12 +450,12 @@ braces syntax declares the column where the ``M`` data is provided.
Similarly, set data can be declared referencing the integer column
labels:
-.. literalinclude:: ../../tests/data/table3.ul.dat
+.. literalinclude:: ../../src/data/table3.ul.dat
:language: none
Declared set names can also be used to index parameters:
-.. literalinclude:: ../../tests/data/table4.ul.dat
+.. literalinclude:: ../../src/data/table4.ul.dat
:language: none
Finally, we compare and contrast the ``table`` and ``param`` commands.
@@ -521,13 +521,13 @@ Simple Load Examples
The simplest illustration of the ``load`` command is specifying data for
an indexed parameter. Consider the file ``Y.tab``:
-.. literalinclude:: ../../tests/data/Y.tab
+.. literalinclude:: ../../src/data/Y.tab
:language: none
This file specifies the values of parameter ``Y`` which is indexed by
set ``A``. The following ``load`` command loads the parameter data:
-.. literalinclude:: ../../tests/data/import1.tab.dat
+.. literalinclude:: ../../src/data/import1.tab.dat
:language: none
The first argument is the filename. The options after the colon
@@ -538,7 +538,7 @@ indicates the parameter that is initialized.
Similarly, the following load command loads both the parameter data as
well as the index set ``A``:
-.. literalinclude:: ../../tests/data/import2.tab.dat
+.. literalinclude:: ../../src/data/import2.tab.dat
:language: none
The difference is the specification of the index set, ``A=[A]``, which
@@ -548,24 +548,24 @@ ASCII table file.
Set data can also be loaded from a ASCII table file that contains a
single column of data:
-.. literalinclude:: ../../tests/data/A.tab
+.. literalinclude:: ../../src/data/A.tab
:language: none
The ``format`` option must be specified to denote the fact that the
relational data is being interpreted as a set:
-.. literalinclude:: ../../tests/data/import3.tab.dat
+.. literalinclude:: ../../src/data/import3.tab.dat
:language: none
Note that this allows for specifying set data that contains tuples.
Consider file ``C.tab``:
-.. literalinclude:: ../../tests/data/C.tab
+.. literalinclude:: ../../src/data/C.tab
:language: none
A similar ``load`` syntax will load this data into set ``C``:
-.. literalinclude:: ../../tests/data/import4.tab.dat
+.. literalinclude:: ../../src/data/import4.tab.dat
:language: none
Note that this example requires that ``C`` be declared with dimension
@@ -609,7 +609,7 @@ describes different specifications and how they define how data is
loaded into a model. Suppose file ``ABCD.tab`` defines the following
relational table:
-.. literalinclude:: ../../tests/data/ABCD.tab
+.. literalinclude:: ../../src/data/ABCD.tab
:language: none
There are many ways to interpret this relational table. It could
@@ -621,7 +621,7 @@ for specifying how a table is interpreted.
A simple specification is to interpret the relational table as a set:
-.. literalinclude:: ../../tests/data/ABCD1.dat
+.. literalinclude:: ../../src/data/ABCD1.dat
:language: none
Note that ``Z`` is a set in the model that the data is being loaded
@@ -631,7 +631,7 @@ data from this table.
Another simple specification is to interpret the relational table as a
parameter with indexed by 3-tuples:
-.. literalinclude:: ../../tests/data/ABCD2.dat
+.. literalinclude:: ../../src/data/ABCD2.dat
:language: none
Again, this requires that ``D`` be a parameter in the model that the
@@ -639,14 +639,14 @@ data is being loaded into. Additionally, the index set for ``D`` must
contain the indices that are specified in the table. The ``load``
command also allows for the specification of the index set:
-.. literalinclude:: ../../tests/data/ABCD3.dat
+.. literalinclude:: ../../src/data/ABCD3.dat
:language: none
This specifies that the index set is loaded into the ``Z`` set in the
model. Similarly, data can be loaded into another parameter than what
is specified in the relational table:
-.. literalinclude:: ../../tests/data/ABCD4.dat
+.. literalinclude:: ../../src/data/ABCD4.dat
:language: none
This specifies that the index set is loaded into the ``Z`` set and that
@@ -658,13 +658,13 @@ specification of data mappings from columns in a relational table into
index sets and parameters. For example, suppose that a model is defined
with set ``Z`` and parameters ``Y`` and ``W``:
-.. literalinclude:: ../../tests/data/ABCD5_decl.spy
+.. literalinclude:: ../../src/data/ABCD5_decl.spy
:language: python
Then the following command defines how these data items are loaded using
columns ``B``, ``C`` and ``D``:
-.. literalinclude:: ../../tests/data/ABCD5.dat
+.. literalinclude:: ../../src/data/ABCD5.dat
:language: none
When the ``using`` option is omitted the data manager is inferred from
@@ -672,13 +672,13 @@ the filename suffix. However, the filename suffix does not always
reflect the format of the data it contains. For example, consider the
relational table in the file ``ABCD.txt``:
-.. literalinclude:: ../../tests/data/ABCD.txt
+.. literalinclude:: ../../src/data/ABCD.txt
:language: none
We can specify the ``using`` option to load from this file into
parameter ``D`` and set ``Z``:
-.. literalinclude:: ../../tests/data/ABCD6.dat
+.. literalinclude:: ../../src/data/ABCD6.dat
:language: none
.. note::
@@ -692,7 +692,7 @@ parameter ``D`` and set ``Z``:
The following data managers are supported in Pyomo 5.1:
- .. literalinclude:: ../../tests/data/data_managers.txt
+ .. literalinclude:: ../../src/data/data_managers.txt
:language: none
Interpreting Tabular Data
@@ -725,12 +725,12 @@ A table with a single value can be interpreted as a simple parameter
using the ``param`` format value. Suppose that ``Z.tab`` contains the
following table:
-.. literalinclude:: ../../tests/data/Z.tab
+.. literalinclude:: ../../src/data/Z.tab
:language: none
The following load command then loads this value into parameter ``p``:
-.. literalinclude:: ../../tests/data/import6.tab.dat
+.. literalinclude:: ../../src/data/import6.tab.dat
:language: none
Sets with 2-tuple data can be represented with a matrix format that
@@ -739,12 +739,12 @@ relational table as a matrix that defines a set of 2-tuples where ``+``
denotes a valid tuple and ``-`` denotes an invalid tuple. Suppose that
``D.tab`` contains the following relational table:
-.. literalinclude:: ../../tests/data/D.tab
+.. literalinclude:: ../../src/data/D.tab
:language: none
Then the following load command loads data into set ``B``:
-.. literalinclude:: ../../tests/data/import5.tab.dat
+.. literalinclude:: ../../src/data/import5.tab.dat
:language: none
This command declares the following 2-tuples: ``('A1',1)``,
@@ -754,19 +754,19 @@ Parameters with 2-tuple indices can be interpreted with a matrix format
that where rows and columns are different indices. Suppose that
``U.tab`` contains the following table:
-.. literalinclude:: ../../tests/data/U.tab
+.. literalinclude:: ../../src/data/U.tab
:language: none
Then the following load command loads this value into parameter ``U``
with a 2-dimensional index using the ``array`` format value.:
-.. literalinclude:: ../../tests/data/import7.tab.dat
+.. literalinclude:: ../../src/data/import7.tab.dat
:language: none
The ``transpose_array`` format value also interprets the table as a
matrix, but it loads the data in a transposed format:
-.. literalinclude:: ../../tests/data/import8.tab.dat
+.. literalinclude:: ../../src/data/import8.tab.dat
:language: none
Note that these format values do not support the initialization of the
@@ -789,7 +789,7 @@ in the following figure:
The following command loads this data to initialize parameter ``D`` and
index ``Z``:
-.. literalinclude:: ../../tests/data/ABCD7.dat
+.. literalinclude:: ../../src/data/ABCD7.dat
:language: none
Thus, the syntax for loading data from spreadsheets only differs from
@@ -809,7 +809,7 @@ command loads data from the Excel spreadsheet ``ABCD.xls`` using the
``pyodbc`` interface. The command loads this data to initialize
parameter ``D`` and index ``Z``:
-.. literalinclude:: ../../tests/data/ABCD8.dat
+.. literalinclude:: ../../src/data/ABCD8.dat
:language: none
The ``using`` option specifies that the ``pyodbc`` package will be
@@ -818,7 +818,7 @@ specifies that the table ``ABCD`` is loaded from this spreadsheet.
Similarly, the following command specifies a data connection string
to specify the ODBC driver explicitly:
-.. literalinclude:: ../../tests/data/ABCD9.dat
+.. literalinclude:: ../../src/data/ABCD9.dat
:language: none
ODBC drivers are generally tailored to the type of data source that
@@ -836,7 +836,7 @@ task of minimizing the cost for a meal at a fast food restaurant -- they
must purchase a sandwich, side, and a drink for the lowest cost. The
following is a Pyomo model for this problem:
-.. literalinclude:: ../../tests/data/diet1.py
+.. literalinclude:: ../../src/data/diet1.py
:language: python
Suppose that the file ``diet1.sqlite`` be a SQLite database file that
@@ -884,7 +884,7 @@ We can solve the ``diet1`` model using the Python definition in
``diet.sqlite.dat`` specifies a ``load`` command that uses that
``sqlite3`` data manager and embeds a SQL query to retrieve the data:
-.. literalinclude:: ../../tests/data/diet.sqlite.dat
+.. literalinclude:: ../../src/data/diet.sqlite.dat
:language: none
The PyODBC driver module will pass the SQL query through an Access ODBC
@@ -904,7 +904,7 @@ The ``include`` command allows a data command file to execute data
commands from another file. For example, the following command file
executes data commands from ``ex1.dat`` and then ``ex2.dat``:
-.. literalinclude:: ../../tests/data/ex.dat
+.. literalinclude:: ../../src/data/ex.dat
:language: none
Pyomo is sensitive to the order of execution of data commands, since
@@ -921,7 +921,7 @@ to structure the specification of Pyomo's data commands. Specifically,
a namespace declaration is used to group data commands and to provide a
group label. Consider the following data command file:
-.. literalinclude:: ../../tests/data/namespace1.dat
+.. literalinclude:: ../../src/data/namespace1.dat
:language: none
This data file defines two namespaces: ``ns1`` and ``ns2`` that
diff --git a/doc/OnlineDocs/working_abstractmodels/data/native.rst b/doc/OnlineDocs/working_abstractmodels/data/native.rst
index 2a52c8356aa..ed92d78d78e 100644
--- a/doc/OnlineDocs/working_abstractmodels/data/native.rst
+++ b/doc/OnlineDocs/working_abstractmodels/data/native.rst
@@ -34,29 +34,29 @@ can be initialized with:
* list, set and tuple data:
- .. literalinclude:: ../../tests/dataportal/set_initialization_decl2.spy
+ .. literalinclude:: ../../src/dataportal/set_initialization_decl2.spy
:language: python
* generators:
- .. literalinclude:: ../../tests/dataportal/set_initialization_decl3.spy
+ .. literalinclude:: ../../src/dataportal/set_initialization_decl3.spy
:language: python
* numpy arrays:
- .. literalinclude:: ../../tests/dataportal/set_initialization_decl4.spy
+ .. literalinclude:: ../../src/dataportal/set_initialization_decl4.spy
:language: python
Sets can also be indirectly initialized with functions that return
native Python data:
-.. literalinclude:: ../../tests/dataportal/set_initialization_decl5.spy
+.. literalinclude:: ../../src/dataportal/set_initialization_decl5.spy
:language: python
Indexed sets can be initialized with dictionary data where the
dictionary values are iterable data:
-.. literalinclude:: ../../tests/dataportal/set_initialization_decl6.spy
+.. literalinclude:: ../../src/dataportal/set_initialization_decl6.spy
:language: python
@@ -66,19 +66,19 @@ Parameter Components
When a parameter is a single value, then a :class:`~pyomo.environ.Param` component can be simply initialized with a
value:
-.. literalinclude:: ../../tests/dataportal/param_initialization_decl1.spy
+.. literalinclude:: ../../src/dataportal/param_initialization_decl1.spy
:language: python
More generally, :class:`~pyomo.environ.Param`
components can be initialized with dictionary data where the dictionary
values are single values:
-.. literalinclude:: ../../tests/dataportal/param_initialization_decl2.spy
+.. literalinclude:: ../../src/dataportal/param_initialization_decl2.spy
:language: python
Parameters can also be indirectly initialized with functions that
return native Python data:
-.. literalinclude:: ../../tests/dataportal/param_initialization_decl3.spy
+.. literalinclude:: ../../src/dataportal/param_initialization_decl3.spy
:language: python
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/doc/OnlineDocs/working_abstractmodels/pyomo_command.rst b/doc/OnlineDocs/working_abstractmodels/pyomo_command.rst
index 1d22798d8ce..aabfc8667f7 100644
--- a/doc/OnlineDocs/working_abstractmodels/pyomo_command.rst
+++ b/doc/OnlineDocs/working_abstractmodels/pyomo_command.rst
@@ -90,7 +90,7 @@ When there seem to be troubles expressing the model, it is often useful
to embed print commands in the model in places that will yield helpful
information. Consider the following snippet:
-.. literalinclude:: ../tests/scripting/spy4PyomoCommand_Troubleshooting_printed_command.spy
+.. literalinclude:: ../src/scripting/spy4PyomoCommand_Troubleshooting_printed_command.spy
:language: python
The effect will be to output every member of the set ``model.I`` at the
diff --git a/doc/OnlineDocs/working_models.rst b/doc/OnlineDocs/working_models.rst
index 2b9b664c548..dbd7aa383e3 100644
--- a/doc/OnlineDocs/working_models.rst
+++ b/doc/OnlineDocs/working_models.rst
@@ -58,7 +58,7 @@ computer to solve the problem or even to iterate over solutions. This
example is provided just to illustrate some elementary aspects of
scripting.
-.. literalinclude:: tests/scripting/iterative1.spy
+.. literalinclude:: src/scripting/iterative1.spy
:language: python
Let us now analyze this script. The first line is a comment that happens
@@ -66,7 +66,7 @@ to give the name of the file. This is followed by two lines that import
symbols for Pyomo. The pyomo namespace is imported as
``pyo``. Therefore, ``pyo.`` must precede each use of a Pyomo name.
-.. literalinclude:: tests/scripting/iterative1_Import_symbols_for_pyomo.spy
+.. literalinclude:: src/scripting/iterative1_Import_symbols_for_pyomo.spy
:language: python
An object to perform optimization is created by calling
@@ -74,7 +74,7 @@ An object to perform optimization is created by calling
argument would be ``'gurobi'`` if, e.g., Gurobi was desired instead of
glpk:
-.. literalinclude:: tests/scripting/iterative1_Call_SolverFactory_with_argument.spy
+.. literalinclude:: src/scripting/iterative1_Call_SolverFactory_with_argument.spy
:language: python
The next lines after a comment create a model. For our discussion here,
@@ -86,13 +86,13 @@ to keep it simple. Constraints could be present in the base model.
Even though it is an abstract model, the base model is fully specified
by these commands because it requires no external data:
-.. literalinclude:: tests/scripting/iterative1_Create_base_model.spy
+.. literalinclude:: src/scripting/iterative1_Create_base_model.spy
:language: python
The next line is not part of the base model specification. It creates an
empty constraint list that the script will use to add constraints.
-.. literalinclude:: tests/scripting/iterative1_Create_empty_constraint_list.spy
+.. literalinclude:: src/scripting/iterative1_Create_empty_constraint_list.spy
:language: python
The next non-comment line creates the instantiated model and refers to
@@ -103,19 +103,19 @@ the ``create`` function is called without arguments because none are
needed; however, the name of a file with data commands is given as an
argument in many scripts.
-.. literalinclude:: tests/scripting/iterative1_Create_instantiated_model.spy
+.. literalinclude:: src/scripting/iterative1_Create_instantiated_model.spy
:language: python
The next line invokes the solver and refers to the object contain
results with the Python variable ``results``.
-.. literalinclude:: tests/scripting/iterative1_Solve_and_refer_to_results.spy
+.. literalinclude:: src/scripting/iterative1_Solve_and_refer_to_results.spy
:language: python
The solve function loads the results into the instance, so the next line
writes out the updated values.
-.. literalinclude:: tests/scripting/iterative1_Display_updated_value.spy
+.. literalinclude:: src/scripting/iterative1_Display_updated_value.spy
:language: python
The next non-comment line is a Python iteration command that will
@@ -123,7 +123,7 @@ successively assign the integers from 0 to 4 to the Python variable
``i``, although that variable is not used in script. This loop is what
causes the script to generate five more solutions:
-.. literalinclude:: tests/scripting/iterative1_Assign_integers.spy
+.. literalinclude:: src/scripting/iterative1_Assign_integers.spy
:language: python
An expression is built up in the Python variable named ``expr``. The
@@ -135,7 +135,7 @@ zero and the expression in ``expr`` is augmented accordingly. Although
Pyomo expression when it is assigned expressions involving Pyomo
variable objects:
-.. literalinclude:: tests/scripting/iterative1_Iteratively_assign_and_test.spy
+.. literalinclude:: src/scripting/iterative1_Iteratively_assign_and_test.spy
:language: python
During the first iteration (when ``i`` is 0), we know that all values of
@@ -159,7 +159,7 @@ function to get it.
The next line adds to the constraint list called ``c`` the requirement
that the expression be greater than or equal to one:
-.. literalinclude:: tests/scripting/iterative1_Add_expression_constraint.spy
+.. literalinclude:: src/scripting/iterative1_Add_expression_constraint.spy
:language: python
The proof that this precludes the last solution is left as an exerise
@@ -167,7 +167,7 @@ for the reader.
The final lines in the outer for loop find a solution and display it:
-.. literalinclude:: tests/scripting/iterative1_Find_and_display_solution.spy
+.. literalinclude:: src/scripting/iterative1_Find_and_display_solution.spy
:language: python
.. note::
@@ -268,14 +268,14 @@ Fixing Variables and Re-solving
Instead of changing model data, scripts are often used to fix variable
values. The following example illustrates this.
-.. literalinclude:: tests/scripting/iterative2.spy
+.. literalinclude:: src/scripting/iterative2.spy
:language: python
In this example, the variables are binary. The model is solved and then
the value of ``model.x[2]`` is flipped to the opposite value before
solving the model again. The main lines of interest are:
-.. literalinclude:: tests/scripting/iterative2_Flip_value_before_solve_again.spy
+.. literalinclude:: src/scripting/iterative2_Flip_value_before_solve_again.spy
:language: python
This could also have been accomplished by setting the upper and lower
@@ -430,7 +430,7 @@ Consider the following very simple example, which is similar to the
iterative example. This is a concrete model. In this example, the value
of ``x[2]`` is accessed.
-.. literalinclude:: tests/scripting/noiteration1.py
+.. literalinclude:: src/scripting/noiteration1.py
:language: python
.. note::
@@ -476,7 +476,7 @@ Another way to access all of the variables (particularly if there are
blocks) is as follows (this particular snippet assumes that instead of
`import pyomo.environ as pyo` `from pyo.environ import *` was used):
-.. literalinclude:: tests/scripting/block_iter_example_compprintloop.spy
+.. literalinclude:: src/scripting/block_iter_example_compprintloop.spy
:language: python
.. _ParamAccess:
@@ -521,21 +521,21 @@ To signal that duals are desired, declare a Suffix component with the
name "dual" on the model or instance with an IMPORT or IMPORT_EXPORT
direction.
-.. literalinclude:: tests/scripting/driveabs2_Create_dual_suffix_component.spy
+.. literalinclude:: src/scripting/driveabs2_Create_dual_suffix_component.spy
:language: python
See the section on Suffixes :ref:`Suffixes` for more information on
Pyomo's Suffix component. After the results are obtained and loaded into
an instance, duals can be accessed in the following fashion.
-.. literalinclude:: tests/scripting/driveabs2_Access_all_dual.spy
+.. literalinclude:: src/scripting/driveabs2_Access_all_dual.spy
:language: python
The following snippet will only work, of course, if there is a
constraint with the name ``AxbConstraint`` that has and index, which is
the string ``Film``.
-.. literalinclude:: tests/scripting/driveabs2_Access_one_dual.spy
+.. literalinclude:: src/scripting/driveabs2_Access_one_dual.spy
:language: python
Here is a complete example that relies on the file ``abstract2.py`` to
@@ -544,14 +544,14 @@ data. Note that the model in ``abstract2.py`` does contain a constraint
named ``AxbConstraint`` and ``abstract2.dat`` does specify an index for
it named ``Film``.
-.. literalinclude:: tests/scripting/driveabs2.spy
+.. literalinclude:: src/scripting/driveabs2.spy
:language: python
Concrete models are slightly different because the model is the
instance. Here is a complete example that relies on the file
``concrete1.py`` to provide the model and instantiate it.
-.. literalinclude:: tests/scripting/driveconc1.py
+.. literalinclude:: src/scripting/driveconc1.py
:language: python
Accessing Slacks
@@ -568,7 +568,7 @@ After a solve, the results object has a member ``Solution.Status`` that
contains the solver status. The following snippet shows an example of
access via a ``print`` statement:
-.. literalinclude:: tests/scripting/spy4scripts_Print_solver_status.spy
+.. literalinclude:: src/scripting/spy4scripts_Print_solver_status.spy
:language: python
The use of the Python ``str`` function to cast the value to a be string
@@ -576,12 +576,12 @@ makes it easy to test it. In particular, the value 'optimal' indicates
that the solver succeeded. It is also possible to access Pyomo data that
can be compared with the solver status as in the following code snippet:
-.. literalinclude:: tests/scripting/spy4scripts_Pyomo_data_comparedwith_solver_status_1.spy
+.. literalinclude:: src/scripting/spy4scripts_Pyomo_data_comparedwith_solver_status_1.spy
:language: python
Alternatively,
-.. literalinclude:: tests/scripting/spy4scripts_Pyomo_data_comparedwith_solver_status_2.spy
+.. literalinclude:: src/scripting/spy4scripts_Pyomo_data_comparedwith_solver_status_2.spy
:language: python
.. _TeeTrue:
@@ -592,7 +592,7 @@ Display of Solver Output
To see the output of the solver, use the option ``tee=True`` as in
-.. literalinclude:: tests/scripting/spy4scripts_See_solver_output.spy
+.. literalinclude:: src/scripting/spy4scripts_See_solver_output.spy
:language: python
This can be useful for troubleshooting solver difficulties.
@@ -607,7 +607,7 @@ solver. In scripts or callbacks, the options can be attached to the
solver object by adding to its options dictionary as illustrated by this
snippet:
-.. literalinclude:: tests/scripting/spy4scripts_Add_option_to_solver.spy
+.. literalinclude:: src/scripting/spy4scripts_Add_option_to_solver.spy
:language: python
If multiple options are needed, then multiple dictionary entries should
@@ -616,7 +616,7 @@ be added.
Sometimes it is desirable to pass options as part of the call to the
solve function as in this snippet:
-.. literalinclude:: tests/scripting/spy4scripts_Add_multiple_options_to_solver.spy
+.. literalinclude:: src/scripting/spy4scripts_Add_multiple_options_to_solver.spy
:language: python
The quoted string is passed directly to the solver. If multiple options
@@ -644,7 +644,7 @@ situations where they are not, the SolverFactory function accepts the
keyword ``executable``, which you can use to set an absolute or relative
path to a solver executable. E.g.,
-.. literalinclude:: tests/scripting/spy4scripts_Set_path_to_solver_executable.spy
+.. literalinclude:: src/scripting/spy4scripts_Set_path_to_solver_executable.spy
:language: python
Warm Starts
@@ -654,7 +654,7 @@ Some solvers support a warm start based on current values of
variables. To use this feature, set the values of variables in the
instance and pass ``warmstart=True`` to the ``solve()`` method. E.g.,
-.. literalinclude:: tests/scripting/spy4scripts_Pass_warmstart_to_solver.spy
+.. literalinclude:: src/scripting/spy4scripts_Pass_warmstart_to_solver.spy
:language: python
.. note::
@@ -686,7 +686,7 @@ parallel. The example can be run with the following command:
mpirun -np 2 python -m mpi4py parallel.py
-.. literalinclude:: tests/scripting/parallel.py
+.. literalinclude:: src/scripting/parallel.py
:language: python
@@ -700,5 +700,5 @@ The pyomo command-line ``--tempdir`` option propagates through to the
TempFileManager service. One can accomplish the same through the
following few lines of code in a script:
-.. literalinclude:: tests/scripting/spy4scripts_Specify_temporary_directory_name.spy
+.. literalinclude:: src/scripting/spy4scripts_Specify_temporary_directory_name.spy
:language: python
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..fa747cf8b21 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
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 3cd5c34f011..397b4a18100 100644
--- a/examples/dae/stochpdegas_automatic.py
+++ b/examples/dae/stochpdegas_automatic.py
@@ -1,7 +1,18 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
-# from __future__ import division
+#
from pyomo.environ import *
from pyomo.dae import *
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 10595db4c22..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
@@ -9,7 +20,6 @@
with each other.
"""
-from __future__ import division
from pyomo.environ import ConcreteModel, Objective, Param, RangeSet, Set, Var, value
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 7e183dfc397..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
@@ -22,7 +33,6 @@
http://dx.doi.org/10.1016/0098-1354(95)00219-7
"""
-from __future__ import division
from pyomo.core.expr.logical_expr import land, lor
from pyomo.core.plugins.transform.logical_to_linear import (
diff --git a/examples/gdp/eight_process/eight_proc_model.py b/examples/gdp/eight_process/eight_proc_model.py
index d4bd4dbd102..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
@@ -22,7 +33,6 @@
http://dx.doi.org/10.1016/0098-1354(95)00219-7
"""
-from __future__ import division
from pyomo.environ import (
ConcreteModel,
diff --git a/examples/gdp/eight_process/eight_proc_verbose_model.py b/examples/gdp/eight_process/eight_proc_verbose_model.py
index 78da347e564..1fd68909146 100644
--- a/examples/gdp/eight_process/eight_proc_verbose_model.py
+++ b/examples/gdp/eight_process/eight_proc_verbose_model.py
@@ -1,10 +1,20 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
eight_proc_model.py.
"""
-from __future__ import division
from pyomo.environ import (
ConcreteModel,
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 7f96f32c65c..2abffef1af6 100644
--- a/examples/gdp/nine_process/small_process.py
+++ b/examples/gdp/nine_process/small_process.py
@@ -1,6 +1,18 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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.
"""
+
from pyomo.core import ConcreteModel, RangeSet, Var, Constraint, Objective
from pyomo.core.expr.current import exp, log, sqrt
from pyomo.gdp import Disjunction
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 16d134500e7..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:
@@ -9,6 +20,7 @@
Pyomo model implementation by @RomeoV
"""
+
from pyomo.environ import *
from pyomo.gdp import *
from pyomo.gdp.basic_step import apply_basic_step
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 b281e009d1f..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.
@@ -14,7 +25,6 @@
Pyomo model implementation by @bernalde and @qtothec.
"""
-from __future__ import division
from pyomo.environ import *
from pyomo.gdp import *
diff --git a/examples/gdp/small_lit/nonconvex_HEN.py b/examples/gdp/small_lit/nonconvex_HEN.py
index 61c24c3187a..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
@@ -7,7 +18,6 @@
Pyomo model implementation by @RomeoV
"""
-
from pyomo.environ import (
ConcreteModel,
Constraint,
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 eba3c82dc05..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
@@ -11,8 +22,6 @@
"""
-from __future__ import division
-
from pyomo.environ import (
ConcreteModel,
NonNegativeReals,
diff --git a/examples/gdp/strip_packing/strip_packing_concrete.py b/examples/gdp/strip_packing/strip_packing_concrete.py
index 4fa6172a8d1..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
@@ -9,7 +20,6 @@
cutting fabric.
"""
-from __future__ import division
from pyomo.environ import ConcreteModel, NonNegativeReals, Objective, Param, Set, Var
diff --git a/examples/gdp/two_rxn_lee/two_rxn_model.py b/examples/gdp/two_rxn_lee/two_rxn_model.py
index 9057ef8c006..98e4cc2e878 100644
--- a/examples/gdp/two_rxn_lee/two_rxn_model.py
+++ b/examples/gdp/two_rxn_lee/two_rxn_model.py
@@ -1,5 +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.
+# ___________________________________________________________________________
+
"""Two reactor model from literature. See README.md."""
-from __future__ import division
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 7274b587dae..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
@@ -12,9 +23,7 @@ def solve_nonlinear():
m.c = pmo.constraint(body=m.x + m.y + 0.5 * m.z, rhs=2)
- m.o = pmo.objective(
- (m.x**0.2) * (m.y**0.8) + (m.z**0.4) - m.x, sense=pmo.maximize
- )
+ m.o = pmo.objective((m.x**0.2) * (m.y**0.8) + (m.z**0.4) - m.x, sense=pmo.maximize)
m.x.value, m.y.value, m.z.value = (1, 1, 1)
ipopt = pmo.SolverFactory("ipopt")
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 cd0153eee61..ce6132e6cf5 100644
--- a/examples/performance/dae/stochpdegas1_automatic.py
+++ b/examples/performance/dae/stochpdegas1_automatic.py
@@ -1,7 +1,18 @@
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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
-# from __future__ import division
+#
from pyomo.environ import *
from pyomo.dae import *
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.out b/examples/pyomo/tutorials/set.out
index b01b666c012..818977f6155 100644
--- a/examples/pyomo/tutorials/set.out
+++ b/examples/pyomo/tutorials/set.out
@@ -1,15 +1,12 @@
-28 Set Declarations
+23 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,11 @@
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}
-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
+23 Declarations: A B C D E F G H Hsub I J K K_2 L M N O P R S T U V
diff --git a/examples/pyomo/tutorials/set.py b/examples/pyomo/tutorials/set.py
index 78f2656d739..a14301484c9 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
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 814b4a5938e..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
@@ -33,9 +44,7 @@ def create_model(k1, k2, k3, caf):
model.cc_bal = pyo.Constraint(expr=(0 == -model.sv * model.cc + k2 * model.cb))
- model.cd_bal = pyo.Constraint(
- expr=(0 == -model.sv * model.cd + k3 * model.ca**2.0)
- )
+ model.cd_bal = pyo.Constraint(expr=(0 == -model.sv * model.cd + k3 * model.ca**2.0))
return model
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 fbbd11fa32a..b762acf55cf 100644
--- a/examples/pyomobook/performance-ch/wl.txt
+++ b/examples/pyomobook/performance-ch/wl.txt
@@ -3,96 +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.15 seconds to construct Var x; 40000 indices 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.26 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.82 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.08 seconds to construct Var x; 40000 indices 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.33 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.13 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.59 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
-[+ 1.74] Built model
-[+ 7.39] Wrote LP file and solved
-[+ 11.36] finished parameter sweep
- 14919301 function calls (14916699 primitive calls) in 15.948 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 590 to 15 due to restriction <15>
+ List reduced from 673 to 15 due to restriction <15>
ncalls tottime percall cumtime percall filename:lineno(function)
- 1 0.002 0.002 15.948 15.948 /export/home/dlwoodruff/Documents/BookIII/trunk/pyomo/examples/doc/pyomobook/performance-ch/wl.py:112(solve_parametric)
- 30 0.007 0.000 15.721 0.524 /export/home/dlwoodruff/software/pyomo/pyomo/opt/base/solvers.py:511(solve)
- 30 0.001 0.000 9.150 0.305 /export/home/dlwoodruff/software/pyomo/pyomo/solvers/plugins/solvers/GUROBI.py:191(_presolve)
- 30 0.001 0.000 9.149 0.305 /export/home/dlwoodruff/software/pyomo/pyomo/opt/solver/shellcmd.py:188(_presolve)
- 30 0.001 0.000 9.134 0.304 /export/home/dlwoodruff/software/pyomo/pyomo/opt/base/solvers.py:651(_presolve)
- 30 0.000 0.000 9.133 0.304 /export/home/dlwoodruff/software/pyomo/pyomo/opt/base/solvers.py:719(_convert_problem)
- 30 0.002 0.000 9.133 0.304 /export/home/dlwoodruff/software/pyomo/pyomo/opt/base/convert.py:31(convert_problem)
- 30 0.001 0.000 9.093 0.303 /export/home/dlwoodruff/software/pyomo/pyomo/solvers/plugins/converter/model.py:43(apply)
- 30 0.001 0.000 9.080 0.303 /export/home/dlwoodruff/software/pyomo/pyomo/core/base/block.py:1756(write)
- 30 0.008 0.000 9.077 0.303 /export/home/dlwoodruff/software/pyomo/pyomo/repn/plugins/cpxlp.py:81(__call__)
- 30 1.308 0.044 9.065 0.302 /export/home/dlwoodruff/software/pyomo/pyomo/repn/plugins/cpxlp.py:377(_print_model_LP)
- 30 0.002 0.000 5.016 0.167 /export/home/dlwoodruff/software/pyomo/pyomo/opt/solver/shellcmd.py:223(_apply_solver)
- 30 0.002 0.000 5.013 0.167 /export/home/dlwoodruff/software/pyomo/pyomo/opt/solver/shellcmd.py:289(_execute_command)
- 30 0.006 0.000 5.011 0.167 /export/home/dlwoodruff/software/pyutilib/pyutilib/subprocess/processmngr.py:433(run_command)
- 30 0.001 0.000 4.388 0.146 /export/home/dlwoodruff/software/pyutilib/pyutilib/subprocess/processmngr.py:829(wait)
+ 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)
- 14919301 function calls (14916699 primitive calls) in 15.948 seconds
+ 7294708 function calls (7291012 primitive calls) in 10.989 seconds
Ordered by: internal time
- List reduced from 590 to 15 due to restriction <15>
+ List reduced from 673 to 15 due to restriction <15>
ncalls tottime percall cumtime percall filename:lineno(function)
- 30 4.381 0.146 4.381 0.146 {built-in method posix.waitpid}
- 30 1.308 0.044 9.065 0.302 /export/home/dlwoodruff/software/pyomo/pyomo/repn/plugins/cpxlp.py:377(_print_model_LP)
- 76560 0.703 0.000 1.165 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/repn/plugins/cpxlp.py:178(_print_expr_canonical)
- 76560 0.682 0.000 0.858 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/repn/standard_repn.py:424(_collect_sum)
- 30 0.544 0.018 0.791 0.026 /export/home/dlwoodruff/software/pyomo/pyomo/solvers/plugins/solvers/GUROBI.py:365(process_soln_file)
- 76560 0.539 0.000 1.691 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/repn/standard_repn.py:973(_generate_standard_repn)
- 306000 0.507 0.000 0.893 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/core/base/set.py:581(bounds)
- 30 0.367 0.012 0.367 0.012 {built-in method posix.read}
- 76560 0.323 0.000 2.291 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/repn/standard_repn.py:245(generate_standard_repn)
- 76560 0.263 0.000 2.923 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/repn/plugins/cpxlp.py:569(constraint_generator)
- 225090 0.262 0.000 0.336 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/core/base/constraint.py:228(has_ub)
- 153060 0.249 0.000 0.422 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/core/expr/symbol_map.py:82(createSymbol)
- 77220 0.220 0.000 0.457 0.000 {built-in method builtins.sorted}
- 30 0.201 0.007 0.202 0.007 {built-in method _posixsubprocess.fork_exec}
- 153000 0.185 0.000 0.690 0.000 /export/home/dlwoodruff/software/pyomo/pyomo/core/base/var.py:407(ub)
+ 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)
-[ 36.46] Resetting the tic/toc delta timer
-Using license file /export/home/dlwoodruff/software/gurobi900/linux64/../lic/gurobi.lic
-Academic license - for non-commercial use only
-[+ 1.21] finished parameter sweep with persistent interface
+[ 0.00] Resetting the tic/toc delta timer
+[+ 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/suffix_declaration.txt b/examples/pyomobook/pyomo-components-ch/suffix_declaration.txt
index d5e38a44dcc..e0237e3ef46 100644
--- a/examples/pyomobook/pyomo-components-ch/suffix_declaration.txt
+++ b/examples/pyomobook/pyomo-components-ch/suffix_declaration.txt
@@ -1,9 +1,9 @@
*** suffixsimple ***
2 Suffix Declarations
- dual : Direction=Suffix.IMPORT_EXPORT, Datatype=Suffix.FLOAT
+ dual : Direction=IMPORT_EXPORT, Datatype=FLOAT
Key : Value
- priority : Direction=Suffix.EXPORT, Datatype=Suffix.INT
+ priority : Direction=EXPORT, Datatype=INT
Key : Value
2 Declarations: priority dual
@@ -16,7 +16,7 @@
Not constructed
1 Suffix Declarations
- foo : Direction=Suffix.LOCAL, Datatype=Suffix.FLOAT
+ foo : Direction=LOCAL, Datatype=FLOAT
Not constructed
3 Declarations: x c foo
diff --git a/examples/pyomobook/pyomo-components-ch/var_declaration.py b/examples/pyomobook/pyomo-components-ch/var_declaration.py
index 538cbea1842..2ee5d7fb749 100644
--- a/examples/pyomobook/pyomo-components-ch/var_declaration.py
+++ b/examples/pyomobook/pyomo-components-ch/var_declaration.py
@@ -1,4 +1,14 @@
-from __future__ import print_function
+# ___________________________________________________________________________
+#
+# Pyomo: Python Optimization Modeling Objects
+# Copyright (c) 2008-2024
+# National Technology and Engineering Solutions of Sandia, LLC
+# Under the terms of Contract DE-NA0003525 with National Technology and
+# Engineering 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 1aa2a3ed6b3..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
@@ -10,541 +10,146 @@
# ___________________________________________________________________________
import pyomo.common.unittest as unittest
-import filecmp
import glob
import os
-import os.path
-import re
-import subprocess
-import sys
-from itertools import zip_longest
-from pyomo.opt import check_available_solvers
-from pyomo.common.dependencies import attempt_import, check_min_version
-from pyomo.common.fileutils import this_file_dir, import_file
-from pyomo.common.log import LoggingIntercept, pyomo_formatter
-from pyomo.common.tee import capture_output
+from pyomo.common.dependencies import attempt_import, matplotlib_available
+from pyomo.common.fileutils import this_file_dir
import pyomo.environ as pyo
-def gurobi_fully_licensed():
- m = pyo.ConcreteModel()
- m.x = pyo.Var(list(range(2001)), within=pyo.NonNegativeReals)
- m.o = pyo.Objective(expr=sum(m.x.values()))
- try:
- results = pyo.SolverFactory('gurobi').solve(m, tee=True)
- pyo.assert_optimal_termination(results)
- return True
- except:
- return False
-
+currdir = this_file_dir()
parameterized, param_available = attempt_import('parameterized')
if not param_available:
raise unittest.SkipTest('Parameterized is not available.')
-# Needed for testing (switches the matplotlib backend):
-from pyomo.common.dependencies import matplotlib_available
-
+# Needed for testing (triggers matplotlib import and switches its backend):
bool(matplotlib_available)
-# Find all *.txt files, and use them to define baseline tests
-currdir = this_file_dir()
-datadir = currdir
-
-solver_dependencies = {
- # abstract_ch
- 'test_abstract_ch_wl_abstract_script': ['glpk'],
- 'test_abstract_ch_pyomo_wl_abstract': ['glpk'],
- 'test_abstract_ch_pyomo_solve1': ['glpk'],
- 'test_abstract_ch_pyomo_solve2': ['glpk'],
- 'test_abstract_ch_pyomo_solve3': ['glpk'],
- 'test_abstract_ch_pyomo_solve4': ['glpk'],
- 'test_abstract_ch_pyomo_solve5': ['glpk'],
- 'test_abstract_ch_pyomo_diet1': ['glpk'],
- 'test_abstract_ch_pyomo_buildactions_works': ['glpk'],
- 'test_abstract_ch_pyomo_abstract5_ns1': ['glpk'],
- 'test_abstract_ch_pyomo_abstract5_ns2': ['glpk'],
- 'test_abstract_ch_pyomo_abstract5_ns3': ['glpk'],
- 'test_abstract_ch_pyomo_abstract6': ['glpk'],
- 'test_abstract_ch_pyomo_abstract7': ['glpk'],
- 'test_abstract_ch_pyomo_AbstractH': ['ipopt'],
- 'test_abstract_ch_AbstHLinScript': ['glpk'],
- 'test_abstract_ch_pyomo_AbstractHLinear': ['glpk'],
- # blocks_ch
- 'test_blocks_ch_lotsizing': ['glpk'],
- 'test_blocks_ch_blocks_lotsizing': ['glpk'],
- # dae_ch
- 'test_dae_ch_run_path_constraint_tester': ['ipopt'],
- # gdp_ch
- 'test_gdp_ch_pyomo_gdp_uc': ['glpk'],
- 'test_gdp_ch_pyomo_scont': ['glpk'],
- 'test_gdp_ch_pyomo_scont2': ['glpk'],
- 'test_gdp_ch_scont_script': ['glpk'],
- # intro_ch'
- 'test_intro_ch_pyomo_concrete1_generic': ['glpk'],
- 'test_intro_ch_pyomo_concrete1': ['glpk'],
- 'test_intro_ch_pyomo_coloring_concrete': ['glpk'],
- 'test_intro_ch_pyomo_abstract5': ['glpk'],
- # mpec_ch
- 'test_mpec_ch_path1': ['path'],
- 'test_mpec_ch_nlp_ex1b': ['ipopt'],
- 'test_mpec_ch_nlp_ex1c': ['ipopt'],
- 'test_mpec_ch_nlp_ex1d': ['ipopt'],
- 'test_mpec_ch_nlp_ex1e': ['ipopt'],
- 'test_mpec_ch_nlp_ex2': ['ipopt'],
- 'test_mpec_ch_nlp1': ['ipopt'],
- 'test_mpec_ch_nlp2': ['ipopt'],
- 'test_mpec_ch_nlp3': ['ipopt'],
- 'test_mpec_ch_mip1': ['glpk'],
- # nonlinear_ch
- 'test_rosen_rosenbrock': ['ipopt'],
- 'test_react_design_ReactorDesign': ['ipopt'],
- 'test_react_design_ReactorDesignTable': ['ipopt'],
- 'test_multimodal_multimodal_init1': ['ipopt'],
- 'test_multimodal_multimodal_init2': ['ipopt'],
- 'test_disease_est_disease_estimation': ['ipopt'],
- 'test_deer_DeerProblem': ['ipopt'],
- # scripts_ch
- 'test_sudoku_sudoku_run': ['glpk'],
- 'test_scripts_ch_warehouse_script': ['glpk'],
- 'test_scripts_ch_warehouse_print': ['glpk'],
- 'test_scripts_ch_warehouse_cuts': ['glpk'],
- 'test_scripts_ch_prob_mod_ex': ['glpk'],
- 'test_scripts_ch_attributes': ['glpk'],
- # optimization_ch
- 'test_optimization_ch_ConcHLinScript': ['glpk'],
- # overview_ch
- 'test_overview_ch_wl_mutable_excel': ['glpk'],
- 'test_overview_ch_wl_excel': ['glpk'],
- 'test_overview_ch_wl_concrete_script': ['glpk'],
- 'test_overview_ch_wl_abstract_script': ['glpk'],
- 'test_overview_ch_pyomo_wl_abstract': ['glpk'],
- # performance_ch
- 'test_performance_ch_wl': ['gurobi', 'gurobi_persistent', 'gurobi_license'],
- 'test_performance_ch_persistent': ['gurobi_persistent'],
-}
-package_dependencies = {
- # abstract_ch'
- 'test_abstract_ch_pyomo_solve4': ['yaml'],
- 'test_abstract_ch_pyomo_solve5': ['yaml'],
- # gdp_ch
- 'test_gdp_ch_pyomo_scont': ['yaml'],
- 'test_gdp_ch_pyomo_scont2': ['yaml'],
- 'test_gdp_ch_pyomo_gdp_uc': ['sympy'],
- # overview_ch'
- 'test_overview_ch_wl_excel': ['pandas', 'xlrd'],
- 'test_overview_ch_wl_mutable_excel': ['pandas', 'xlrd'],
- # scripts_ch'
- 'test_scripts_ch_warehouse_cuts': ['matplotlib'],
- # performance_ch'
- 'test_performance_ch_wl': ['numpy', 'matplotlib'],
-}
-
-#
-# Initialize the availability data
-#
-solvers_used = set(sum(list(solver_dependencies.values()), []))
-available_solvers = check_available_solvers(*solvers_used)
-if gurobi_fully_licensed():
- available_solvers.append('gurobi_license')
-solver_available = {solver_: (solver_ in available_solvers) for solver_ in solvers_used}
-
-package_available = {}
-package_modules = {}
-packages_used = set(sum(list(package_dependencies.values()), []))
-for package_ in packages_used:
- pack, pack_avail = attempt_import(package_)
- package_available[package_] = pack_avail
- package_modules[package_] = pack
-
-
-def check_skip(name):
- """
- Return a boolean if the test should be skipped
- """
-
- if name in solver_dependencies:
- solvers_ = solver_dependencies[name]
- if not all([solver_available[i] for i in solvers_]):
- # Skip the test because a solver is not available
- _missing = []
- for i in solvers_:
- if not solver_available[i]:
- _missing.append(i)
- return "Solver%s %s %s not available" % (
- 's' if len(_missing) > 1 else '',
- ", ".join(_missing),
- 'are' if len(_missing) > 1 else 'is',
- )
-
- if name in package_dependencies:
- packages_ = package_dependencies[name]
- if not all([package_available[i] for i in packages_]):
- # Skip the test because a package is not available
- _missing = []
- for i in packages_:
- if not package_available[i]:
- _missing.append(i)
- return "Package%s %s %s not available" % (
- 's' if len(_missing) > 1 else '',
- ", ".join(_missing),
- 'are' if len(_missing) > 1 else 'is',
- )
-
- # This is a hack, xlrd dropped support for .xlsx files in 2.0.1 which
- # causes problems with older versions of Pandas<=1.1.5 so skipping
- # tests requiring both these packages when incompatible versions are found
- if (
- 'pandas' in package_dependencies[name]
- and 'xlrd' in package_dependencies[name]
- ):
- if check_min_version(
- package_modules['xlrd'], '2.0.1'
- ) and not check_min_version(package_modules['pandas'], '1.1.6'):
- return "Incompatible versions of xlrd and pandas"
- return False
-
-
-def filter(line):
- """
- Ignore certain text when comparing output with baseline
- """
- for field in (
- '[',
- 'password:',
- 'http:',
- 'Job ',
- 'Importing module',
- 'Function',
- 'File',
- 'Matplotlib',
- '-------',
- '=======',
- ' ^',
- ):
- if line.startswith(field):
- return True
- for field in (
- 'Total CPU',
- 'Ipopt',
- 'license',
- 'Status: optimal',
- 'Status: feasible',
- 'time:',
- 'Time:',
- 'with format cpxlp',
- 'usermodel = >> 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 0854715baeb..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
@@ -11,6 +11,4 @@
from pyomo.common.deprecation import relocated_module_attribute
-relocated_module_attribute(
- 'nullcontext', 'contextlib.nullcontext', version='6.7.0.dev0'
-)
+relocated_module_attribute('nullcontext', 'contextlib.nullcontext', version='6.7.0')
diff --git a/pyomo/common/cmake_builder.py b/pyomo/common/cmake_builder.py
index 71358c29fb2..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
@@ -32,11 +32,8 @@ def handleReadonly(function, path, excinfo):
def build_cmake_project(
targets, package_name=None, description=None, user_args=[], parallel=None
):
- # Note: setuptools must be imported before distutils to avoid
- # warnings / errors with recent setuptools distributions
- from setuptools import Extension
- import distutils.core
- from distutils.command.build_ext import build_ext
+ from setuptools import Extension, Distribution
+ from setuptools.command.build_ext import build_ext
class _CMakeBuild(build_ext, object):
def run(self):
@@ -122,7 +119,7 @@ def __init__(self, target_dir, user_args, parallel):
'ext_modules': ext_modules,
'cmdclass': {'build_ext': _CMakeBuild},
}
- dist = distutils.core.Distribution(package_config)
+ dist = Distribution(package_config)
basedir = os.path.abspath(os.path.curdir)
try:
tmpdir = os.path.abspath(tempfile.mkdtemp())
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 ceb4174ecca..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())
@@ -91,16 +121,32 @@ def __len__(self):
# Overload MutableMapping 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.
+ # We want a specialization of update() to avoid unnecessary calls to
+ # id() when copying / merging ComponentMaps
+ def update(self, *args, **kwargs):
+ if len(args) == 1 and not kwargs and isinstance(args[0], ComponentMap):
+ return self._dict.update(args[0]._dict)
+ return super().update(*args, **kwargs)
+
+ # We want to avoid generating Pyomo expressions due to comparing the
+ # keys, so look up each entry from other in this dict.
def __eq__(self, other):
- if not isinstance(other, collections_Mapping):
+ if self is other:
+ return True
+ if not isinstance(other, collections_Mapping) or len(self) != len(other):
return False
- return {(type(key), id(key)): val for key, val in self.items()} == {
- (type(key), id(key)): val for key, val in other.items()
- }
+ # Note we have already verified the dicts are the same size
+ for key, val in other.items():
+ other_id = _hasher[key.__class__](key)
+ if other_id not in self._dict:
+ return False
+ self_val = self._dict[other_id][1]
+ # Note: check "is" first to help avoid creation of Pyomo
+ # expressions (for the case that the values contain the same
+ # Pyomo component)
+ if self_val is not val and self_val != val:
+ return False
+ return True
def __ne__(self, other):
return not (self == other)
@@ -114,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.'
@@ -133,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 0b16acd00be..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,26 +95,25 @@ 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 set((type(val), id(val)) for val in self) == set(
- (type(val), id(val)) for val in other
+ return len(self) == len(other) and all(
+ _hasher[val.__class__](val) in self._data for val in other
)
def __ne__(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 61e4f682a2a..f9c3a725bb8 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
@@ -31,13 +31,14 @@
import textwrap
import types
+from operator import attrgetter
+
from pyomo.common.collections import Sequence, Mapping
from pyomo.common.deprecation import (
deprecated,
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
@@ -300,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
@@ -422,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
@@ -452,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
@@ -487,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
----------
@@ -511,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)]
@@ -707,6 +785,7 @@ def from_enum_or_string(cls, arg):
NonNegativeFloat
In
InEnum
+ IsInstance
ListOf
Module
Path
@@ -1026,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
@@ -1052,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):
@@ -1088,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:
@@ -1396,9 +1484,11 @@ def _item_body(self, indent, obj):
None,
[
'dict' if isinstance(obj, ConfigDict) else obj.domain_name(),
- 'optional'
- if obj._default is None
- else f'default={repr(obj._default)}',
+ (
+ 'optional'
+ if obj._default is None
+ else f'default={repr(obj._default)}'
+ ),
],
)
)
@@ -1686,11 +1776,9 @@ def __call__(
ans.reset()
else:
# Copy over any Dict definitions
- for k in self._decl_order:
+ for k, v in self._data.items():
if preserve_implicit or k in self._declared:
- v = self._data[k]
ans._data[k] = _tmp = v(preserve_implicit=preserve_implicit)
- ans._decl_order.append(k)
if k in self._declared:
ans._declared.add(k)
_tmp._parent = ans
@@ -2381,12 +2469,7 @@ class ConfigDict(ConfigBase, Mapping):
content_filters = {None, 'all', 'userdata'}
- __slots__ = (
- '_decl_order',
- '_declared',
- '_implicit_declaration',
- '_implicit_domain',
- )
+ __slots__ = ('_declared', '_implicit_declaration', '_implicit_domain')
_all_slots = set(__slots__ + ConfigBase.__slots__)
def __init__(
@@ -2397,7 +2480,6 @@ def __init__(
implicit_domain=None,
visibility=0,
):
- self._decl_order = []
self._declared = set()
self._implicit_declaration = implicit
if (
@@ -2476,7 +2558,6 @@ def __delitem__(self, key):
_key = str(key).replace(' ', '_')
del self._data[_key]
# Clean up the other data structures
- self._decl_order.remove(_key)
self._declared.discard(_key)
def __contains__(self, key):
@@ -2484,10 +2565,10 @@ def __contains__(self, key):
return _key in self._data
def __len__(self):
- return self._decl_order.__len__()
+ return len(self._data)
def __iter__(self):
- return (self._data[key]._name for key in self._decl_order)
+ return map(attrgetter('_name'), self._data.values())
def __getattr__(self, name):
# Note: __getattr__ is only called after all "usual" attribute
@@ -2524,13 +2605,12 @@ def keys(self):
def values(self):
self._userAccessed = True
- for key in self._decl_order:
- yield self[key]
+ return map(self.__getitem__, self._data)
def items(self):
self._userAccessed = True
- for key in self._decl_order:
- yield (self._data[key]._name, self[key])
+ for key, val in self._data.items():
+ yield (val._name, self[key])
@deprecated('The iterkeys method is deprecated. Use dict.keys().', version='6.0')
def iterkeys(self):
@@ -2559,7 +2639,6 @@ def _add(self, name, config):
% (name, self.name(True))
)
self._data[_name] = config
- self._decl_order.append(_name)
config._parent = self
config._name = name
return config
@@ -2611,10 +2690,7 @@ def add(self, name, config):
def value(self, accessValue=True):
if accessValue:
self._userAccessed = True
- return {
- cfg._name: cfg.value(accessValue)
- for cfg in map(self._data.__getitem__, self._decl_order)
- }
+ return {cfg._name: cfg.value(accessValue) for cfg in self._data.values()}
def set_value(self, value, skip_implicit=False):
if value is None:
@@ -2634,7 +2710,7 @@ def set_value(self, value, skip_implicit=False):
_key = str(key).replace(' ', '_')
if _key in self._data:
# str(key) may not be key... store the mapping so that
- # when we later iterate over the _decl_order, we can map
+ # when we later iterate over the _data, we can map
# the local keys back to the incoming value keys.
_decl_map[_key] = key
else:
@@ -2657,7 +2733,7 @@ def set_value(self, value, skip_implicit=False):
# We want to set the values in declaration order (so that
# things are deterministic and in case a validation depends
# on the order)
- for key in self._decl_order:
+ for key in self._data:
if key in _decl_map:
self[key] = value[_decl_map[key]]
# implicit data is declared at the end (in sorted order)
@@ -2673,16 +2749,11 @@ def set_value(self, value, skip_implicit=False):
def reset(self):
# Reset the values in the order they were declared. This
# allows reset functions to have a deterministic ordering.
- def _keep(self, key):
- keep = key in self._declared
- if keep:
- self._data[key].reset()
+ for key, val in list(self._data.items()):
+ if key in self._declared:
+ val.reset()
else:
del self._data[key]
- return keep
-
- # this is an in-place slice of a list...
- self._decl_order[:] = [x for x in self._decl_order if _keep(self, x)]
self._userAccessed = False
self._userSet = False
@@ -2693,8 +2764,7 @@ def _data_collector(self, level, prefix, visibility=None, docMode=False):
yield (level, prefix, None, self)
if level is not None:
level += 1
- for key in self._decl_order:
- cfg = self._data[key]
+ for cfg in self._data.values():
yield from cfg._data_collector(level, cfg._name + ': ', visibility, docMode)
diff --git a/pyomo/common/dependencies.py b/pyomo/common/dependencies.py
index 4ddbe1c9ee8..4c9e43002ef 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,16 +9,18 @@
# 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
-from . import numeric_types
SUPPRESS_DEPENDENCY_WARNINGS = False
@@ -128,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.
@@ -313,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()
@@ -434,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,
@@ -442,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,
):
@@ -496,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.
@@ -507,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
@@ -523,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
@@ -577,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(
@@ -622,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,
@@ -673,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
@@ -699,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:
@@ -713,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
+ )
#
@@ -743,6 +927,12 @@ def _finalize_yaml(module, available):
yaml_load_args['Loader'] = module.SafeLoader
+def _finalize_ctypes(module, available):
+ # ctypes.util must be explicitly imported (and fileutils assumes
+ # this has already happened)
+ import ctypes.util
+
+
def _finalize_scipy(module, available):
if available:
# Import key subpackages that we will want to assume are present
@@ -773,11 +963,22 @@ 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
+ # from accidentally registering ndarray as a native_numeric_type.
numeric_types.native_types.add(np.ndarray)
numeric_types.RegisterLogicalType(np.bool_)
for t in (
@@ -798,41 +999,77 @@ 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)
- for t in (np.float_, np.float16, np.float32, np.float64):
+ _floats = [np.float_, 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, 'float96'):
+ _floats.append(np.float96)
+ if hasattr(np, 'float128'):
+ _floats.append(np.float128)
+ for t in _floats:
numeric_types.RegisterNumericType(t)
# We have deprecated RegisterBooleanType, so we will mock up the
# registration here (to bypass the deprecation warning) until we
# finally remove all support for it
numeric_types._native_boolean_types.add(t)
-
-
-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')
-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),
-)
+ _complex = [np.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, 'complex192'):
+ _complex.append(np.complex192)
+ if hasattr(np, 'complex256'):
+ _complex.append(np.complex256)
+ for t in _complex:
+ numeric_types.RegisterComplexType(t)
+
+
+def _pyutilib_importer():
+ # On newer Pythons, PyUtilib import will fail, but only if a
+ # second-level module is imported. We will arbitrarily choose to
+ # check pyutilib.component (as that is the path exercised by the
+ # pyomo.common.tempfiles deprecation path)
+ importlib.import_module('pyutilib.component')
+ return importlib.import_module('pyutilib')
+
+
+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 a90efcc2787..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
@@ -9,9 +9,10 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
-import ctypes
import os
+from .dependencies import ctypes
+
def _as_bytes(val):
"""Helper function to coerce a string to a bytes() object"""
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 16933df64af..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
@@ -32,16 +32,17 @@
PathData
"""
-import ctypes.util
import glob
import inspect
import logging
import os
import platform
import importlib.util
+import subprocess
import sys
from . import envvar
+from .dependencies import ctypes
from .deprecation import deprecated, relocated_module_attribute
relocated_module_attribute('StreamIndenter', 'pyomo.common.formatting', version='6.2')
@@ -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 f76d16880df..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
@@ -257,7 +257,8 @@ def writelines(self, sequence):
r'|(?:\[\s*[A-Za-z0-9\.]+\s*\] +)' # [PASS]|[FAIL]|[ OK ]
)
_verbatim_line_start = re.compile(
- r'(\| )' r'|(\+((-{3,})|(={3,}))\+)' # line blocks # grid table
+ r'(\| )' # line blocks
+ r'|(\+((-{3,})|(={3,}))\+)' # grid table
)
_verbatim_line = re.compile(
r'(={3,}[ =]+)' # simple tables, ======== sections
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..1c14b64bd70 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
diff --git a/pyomo/common/log.py b/pyomo/common/log.py
index bf2ae1e4c96..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
@@ -139,7 +139,8 @@ def format(self, record):
#
# A standard approach is to use inspect.cleandoc, which
# allows for the first line to have 0 indent.
- msg = inspect.cleandoc(msg)
+ if getattr(record, 'cleandoc', True):
+ msg = inspect.cleandoc(msg)
# Split the formatted log message (that currently has _flag in
# lieu of the actual message content) into lines, then
diff --git a/pyomo/common/modeling.py b/pyomo/common/modeling.py
index b3a6d59fcf0..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
@@ -9,8 +9,8 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
-from random import random
import sys
+from .dependencies import random
def randint(a, b):
@@ -21,7 +21,7 @@ def randint(a, b):
can support deterministic testing (i.e., setting the random.seed and
expecting the same sequence), we will implement a simple, but stable
version of randint()."""
- return int((b - a + 1) * random())
+ return int((b - a + 1) * random.random())
def unique_component_name(instance, name):
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 dbad3ef0853..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
@@ -41,10 +41,14 @@
#: Python set used to identify numeric constants. This set includes
#: native Python types as well as numeric types from Python packages
#: like numpy, which may be registered by users.
-native_numeric_types = {int, float, complex}
+#:
+#: Note that :data:`native_numeric_types` does NOT include
+#: :py:`complex`, as that is not a valid constant in Pyomo numeric
+#: expressions.
+native_numeric_types = {int, float}
native_integer_types = {int}
native_logical_types = {bool}
-pyomo_constant_types = set() # includes NumericConstant
+native_complex_types = {complex}
_native_boolean_types = {int, bool, str, bytes}
relocated_module_attribute(
@@ -56,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
@@ -64,34 +78,53 @@
#: like numpy.
#:
#: :data:`native_types` = :data:`native_numeric_types ` + { str }
-native_types = set([bool, str, type(None), slice, bytes])
+native_types = {bool, str, type(None), slice, bytes}
native_types.update(native_numeric_types)
native_types.update(native_integer_types)
-native_types.update(_native_boolean_types)
+native_types.update(native_complex_types)
native_types.update(native_logical_types)
+native_types.update(_native_boolean_types)
nonpyomo_leaf_types.update(native_types)
-def RegisterNumericType(new_type):
- """
- A utility function for updating the set of types that are
- recognized to handle numeric values.
+def RegisterNumericType(new_type: type):
+ """Register the specified type as a "numeric type".
+
+ A utility function for registering new types as "native numeric
+ types" that can be leaf nodes in Pyomo numeric expressions. The
+ type should be compatible with :py:class:`float` (that is, store a
+ scalar and be castable to a Python float).
+
+ Parameters
+ ----------
+ new_type: type
+ The new numeric type (e.g, numpy.float64)
- The argument should be a class (e.g, numpy.float64).
"""
native_numeric_types.add(new_type)
native_types.add(new_type)
nonpyomo_leaf_types.add(new_type)
-def RegisterIntegerType(new_type):
- """
- A utility function for updating the set of types that are
- recognized to handle integer values. This also registers the type
- as numeric but does not register it as boolean.
+def RegisterIntegerType(new_type: type):
+ """Register the specified type as an "integer type".
+
+ A utility function for registering new types as "native integer
+ types". Integer types can be leaf nodes in Pyomo numeric
+ expressions. The type should be compatible with :py:class:`float`
+ (that is, store a scalar and be castable to a Python float).
+
+ Registering a type as an integer type implies
+ :py:func:`RegisterNumericType`.
+
+ Note that integer types are NOT registered as logical / Boolean types.
+
+ Parameters
+ ----------
+ new_type: type
+ The new integer type (e.g, numpy.int64)
- The argument should be a class (e.g., numpy.int64).
"""
native_numeric_types.add(new_type)
native_integer_types.add(new_type)
@@ -104,26 +137,64 @@ def RegisterIntegerType(new_type):
"is deprecated. Users likely should use RegisterLogicalType.",
version='6.6.0',
)
-def RegisterBooleanType(new_type):
- """
- A utility function for updating the set of types that are
- recognized as handling boolean values. This function does not
- register the type of integer or numeric.
+def RegisterBooleanType(new_type: type):
+ """Register the specified type as a "logical type".
+
+ A utility function for registering new types as "native logical
+ types". Logical types can be leaf nodes in Pyomo logical
+ expressions. The type should be compatible with :py:class:`bool`
+ (that is, store a scalar and be castable to a Python bool).
+
+ Note that logical types are NOT registered as numeric types.
+
+ Parameters
+ ----------
+ new_type: type
+ The new logical type (e.g, numpy.bool_)
- The argument should be a class (e.g., numpy.bool_).
"""
_native_boolean_types.add(new_type)
native_types.add(new_type)
nonpyomo_leaf_types.add(new_type)
-def RegisterLogicalType(new_type):
+def RegisterComplexType(new_type: type):
+ """Register the specified type as an "complex type".
+
+ A utility function for registering new types as "native complex
+ types". Complex types can NOT be leaf nodes in Pyomo numeric
+ expressions. The type should be compatible with :py:class:`complex`
+ (that is, store a scalar complex value and be castable to a Python
+ complex).
+
+ Note that complex types are NOT registered as logical or numeric types.
+
+ Parameters
+ ----------
+ new_type: type
+ The new complex type (e.g, numpy.complex128)
+
"""
- A utility function for updating the set of types that are
- recognized as handling boolean values. This function does not
- register the type of integer or numeric.
+ native_types.add(new_type)
+ native_complex_types.add(new_type)
+ nonpyomo_leaf_types.add(new_type)
+
+
+def RegisterLogicalType(new_type: type):
+ """Register the specified type as a "logical type".
+
+ A utility function for registering new types as "native logical
+ types". Logical types can be leaf nodes in Pyomo logical
+ expressions. The type should be compatible with :py:class:`bool`
+ (that is, store a scalar and be castable to a Python bool).
+
+ Note that logical types are NOT registered as numeric types.
+
+ Parameters
+ ----------
+ new_type: type
+ The new logical type (e.g, numpy.bool_)
- The argument should be a class (e.g., numpy.bool_).
"""
_native_boolean_types.add(new_type)
native_logical_types.add(new_type)
@@ -131,12 +202,74 @@ def RegisterLogicalType(new_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.
We check for "numeric types" by checking if we can add zero to it
- without changing the object's type. If that works, then we register
- the type in native_numeric_types.
+ without changing the object's type, and that the object compares to
+ 0 in a meaningful way. If that works, then we register the type in
+ :py:attr:`native_numeric_types`.
"""
obj_class = obj.__class__
@@ -147,78 +280,82 @@ def check_if_numeric_type(obj):
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):
"""
- A utility function that returns the value of a Pyomo object or
- expression.
-
- Args:
- obj: The argument to evaluate. If it is None, a
- string, or any other primitive numeric type,
- then this function simply returns the argument.
- Otherwise, if the argument is a NumericValue
- then the __call__ method is executed.
- exception (bool): If :const:`True`, then an exception should
- be raised when instances of NumericValue fail to
- s evaluate due to one or more objects not being
- initialized to a numeric value (e.g, one or more
- variables in an algebraic expression having the
- value None). If :const:`False`, then the function
- returns :const:`None` when an exception occurs.
- Default is True.
-
- Returns: A numeric value or None.
+ A utility function that returns the value of a Pyomo object or
+ expression.
+
+ Args:
+ obj: The argument to evaluate. If it is None, a
+ string, or any other primitive numeric type,
+ then this function simply returns the argument.
+ Otherwise, if the argument is a NumericValue
+ then the __call__ method is executed.
+ exception (bool): If :const:`True`, then an exception should
+ be raised when instances of NumericValue fail to
+ evaluate due to one or more objects not being
+ initialized to a numeric value (e.g, one or more
+ variables in an algebraic expression having the
+ value None). If :const:`False`, then the function
+ returns :const:`None` when an exception occurs.
+ Default is True.
+
+ Returns: A numeric value or None.
"""
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
@@ -233,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 e981d26d84e..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
@@ -22,18 +22,15 @@
import logging
import shutil
import weakref
+
+from pyomo.common.dependencies import attempt_import, pyutilib_available
from pyomo.common.deprecation import deprecated, deprecation_warning
from pyomo.common.errors import TempfileContextError
from pyomo.common.multithread import MultiThreadWrapperWithMain
-try:
- from pyutilib.component.config.tempfiles import TempfileManager as pyutilib_mngr
-except ImportError:
- pyutilib_mngr = None
-
deletion_errors_are_fatal = True
-
logger = logging.getLogger(__name__)
+pyutilib_tempfiles, _ = attempt_import('pyutilib.component.config.tempfiles')
class TempfileManagerClass(object):
@@ -432,16 +429,17 @@ def _resolve_tempdir(self, dir=None):
return self.manager().tempdir
elif TempfileManager.main_thread.tempdir is not None:
return TempfileManager.main_thread.tempdir
- elif pyutilib_mngr is not None and pyutilib_mngr.tempdir is not None:
- deprecation_warning(
- "The use of the PyUtilib TempfileManager.tempdir "
- "to specify the default location for Pyomo "
- "temporary files has been deprecated. "
- "Please set TempfileManager.tempdir in "
- "pyomo.common.tempfiles",
- version='5.7.2',
- )
- return pyutilib_mngr.tempdir
+ elif pyutilib_available:
+ if pyutilib_tempfiles.TempfileManager.tempdir is not None:
+ deprecation_warning(
+ "The use of the PyUtilib TempfileManager.tempdir "
+ "to specify the default location for Pyomo "
+ "temporary files has been deprecated. "
+ "Please set TempfileManager.tempdir in "
+ "pyomo.common.tempfiles",
+ version='5.7.2',
+ )
+ return pyutilib_tempfiles.TempfileManager.tempdir
return None
def _remove_filesystem_object(self, name):
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 9bafd852eb9..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()
@@ -3027,6 +3218,82 @@ def fcn(self):
self.assertEqual(add_docstring_list("", ExampleClass.CONFIG), ref)
self.assertIn('add_docstring_list is deprecated', LOG.getvalue())
+ def test_declaration_in_init(self):
+ class CustomConfig(ConfigDict):
+ def __init__(
+ self,
+ description=None,
+ doc=None,
+ implicit=False,
+ implicit_domain=None,
+ visibility=0,
+ ):
+ super().__init__(
+ description=description,
+ doc=doc,
+ implicit=implicit,
+ implicit_domain=implicit_domain,
+ visibility=visibility,
+ )
+
+ self.declare('time_limit', ConfigValue(domain=NonNegativeFloat))
+ self.declare('stream_solver', ConfigValue(domain=bool))
+
+ cfg = CustomConfig()
+ OUT = StringIO()
+ cfg.display(ostream=OUT)
+ # Note: pypy outputs "None" as "null"
+ self.assertEqual(
+ "time_limit: None\nstream_solver: None\n",
+ OUT.getvalue().replace('null', 'None'),
+ )
+
+ # Test that creating a copy of a ConfigDict with declared fields
+ # in the __init__ does not result in duplicate outputs in the
+ # display (reported in PR #3113)
+ cfg2 = cfg({'time_limit': 10, 'stream_solver': 0})
+ OUT = StringIO()
+ cfg2.display(ostream=OUT)
+ self.assertEqual(
+ "time_limit: 10.0\nstream_solver: false\n",
+ 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..31f9520b613 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
@@ -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 b82082ac1af..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
@@ -30,6 +30,7 @@
import pyomo.common.tempfiles as tempfiles
+from pyomo.common.dependencies import pyutilib_available
from pyomo.common.log import LoggingIntercept
from pyomo.common.tempfiles import (
TempfileManager,
@@ -37,11 +38,6 @@
TempfileContextError,
)
-try:
- from pyutilib.component.config.tempfiles import TempfileManager as pyutilib_mngr
-except ImportError:
- pyutilib_mngr = None
-
old_tempdir = TempfileManager.tempdir
tempdir = None
@@ -528,13 +524,13 @@ def test_open_tempfile_windows(self):
f.close()
os.remove(fname)
- @unittest.skipIf(pyutilib_mngr is None, "deprecation test requires pyutilib")
+ @unittest.skipUnless(pyutilib_available, "deprecation test requires pyutilib")
def test_deprecated_tempdir(self):
self.TM.push()
try:
tmpdir = self.TM.create_tempdir()
- _orig = pyutilib_mngr.tempdir
- pyutilib_mngr.tempdir = tmpdir
+ _orig = tempfiles.pyutilib_tempfiles.TempfileManager.tempdir
+ tempfiles.pyutilib_tempfiles.TempfileManager.tempdir = tmpdir
self.TM.tempdir = None
with LoggingIntercept() as LOG:
@@ -556,7 +552,7 @@ def test_deprecated_tempdir(self):
)
finally:
self.TM.pop()
- pyutilib_mngr.tempdir = _orig
+ tempfiles.pyutilib_tempfiles.TempfileManager.tempdir = _orig
def test_context(self):
with self.assertRaisesRegex(
diff --git a/pyomo/common/tests/test_timing.py b/pyomo/common/tests/test_timing.py
index d2ce6175801..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
@@ -14,6 +14,7 @@
import gc
from io import StringIO
+from itertools import zip_longest
import logging
import sys
import time
@@ -26,8 +27,15 @@
TicTocTimer,
HierarchicalTimer,
)
-from pyomo.environ import ConcreteModel, RangeSet, Var, Any, TransformationFactory
-from pyomo.core.base.var import _VarData
+from pyomo.environ import (
+ AbstractModel,
+ ConcreteModel,
+ RangeSet,
+ Var,
+ Any,
+ TransformationFactory,
+)
+from pyomo.core.base.var import VarData
class _pseudo_component(Var):
@@ -54,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\]; "
@@ -99,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:
@@ -114,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:
@@ -127,11 +133,51 @@ 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(), "")
+ def test_report_timing_context_manager(self):
+ ref = r"""
+ (0(\.\d+)?) seconds to construct Var x; 2 indices total
+ (0(\.\d+)?) seconds to construct Var y; 0 indices total
+ (0(\.\d+)?) seconds to construct Suffix Suffix
+ (0(\.\d+)?) seconds to apply Transformation RelaxIntegerVars \(in-place\)
+ """.strip()
+
+ xfrm = TransformationFactory('core.relax_integer_vars')
+
+ model = AbstractModel()
+ model.r = RangeSet(2)
+ model.x = Var(model.r)
+ model.y = Var(Any, dense=False)
+
+ OS = StringIO()
+
+ with report_timing(False):
+ with report_timing(OS):
+ with report_timing(False):
+ # Active reporting is False: nothing should be emitted
+ with capture_output() as OUT:
+ m = model.create_instance()
+ xfrm.apply_to(m)
+ self.assertEqual(OUT.getvalue(), "")
+ self.assertEqual(OS.getvalue(), "")
+ # Active reporting: we should log the timing
+ with capture_output() as OUT:
+ m = model.create_instance()
+ xfrm.apply_to(m)
+ self.assertEqual(OUT.getvalue(), "")
+ result = OS.getvalue().strip()
+ 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
+ with capture_output() as OUT:
+ m = model.create_instance()
+ xfrm.apply_to(m)
+ self.assertEqual(OUT.getvalue(), "")
+ self.assertEqual(result, OS.getvalue().strip())
+
def test_TicTocTimer_tictoc(self):
SLEEP = 0.1
RES = 0.02 # resolution (seconds): 1/5 the sleep
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 a87fc57da9e..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
@@ -11,11 +11,14 @@
import datetime
import multiprocessing
-from io import StringIO
+import os
import time
+from io import StringIO
import pyomo.common.unittest as unittest
from pyomo.common.log import LoggingIntercept
+from pyomo.common.tee import capture_output
+from pyomo.common.tempfiles import TempfileManager
from pyomo.environ import ConcreteModel, Var, Param
@@ -236,5 +239,319 @@ def test_bound_function_require_fork(self):
self.bound_function_require_fork()
+baseline = """
+[ 0.00] Setting up Pyomo environment
+[ 0.00] Applying Pyomo preprocessing actions
+[ 0.00] Creating model
+[ 0.00] Applying solver
+[ 0.05] Processing results
+ Number of solutions: 1
+ Solution Information
+ Gap: None
+ Status: optimal
+ Function Value: -9.99943939749e-05
+ Solver results file: results.yml
+[ 0.05] Applying Pyomo postprocessing actions
+[ 0.05] Pyomo Finished
+# ==========================================================
+# = Solver Results =
+# ==========================================================
+# ----------------------------------------------------------
+# Problem Information
+# ----------------------------------------------------------
+Problem:
+- Lower bound: -inf
+ Upper bound: inf
+ Number of objectives: 1
+ Number of constraints: 3
+ Number of variables: 3
+ Sense: unknown
+# ----------------------------------------------------------
+# Solver Information
+# ----------------------------------------------------------
+Solver:
+- Status: ok
+ Message: Ipopt 3.12.3\x3a Optimal Solution Found
+ Termination condition: optimal
+ Id: 0
+ Error rc: 0
+ Time: 0.0408430099487
+# ----------------------------------------------------------
+# Solution Information
+# ----------------------------------------------------------
+Solution:
+- number of solutions: 1
+ number of solutions displayed: 1
+- Gap: None
+ Status: optimal
+ Message: Ipopt 3.12.3\x3a Optimal Solution Found
+ Objective:
+ f1:
+ Value: -9.99943939749e-05
+ Variable:
+ compl.v:
+ Value: 9.99943939749e-05
+ y:
+ Value: 9.99943939749e-05
+ Constraint: No values
+"""
+
+pass_ref = """
+[ 0.00] Setting up Pyomo environment
+[ 0.00] Applying Pyomo preprocessing actions
+WARNING: DEPRECATED: The Model.preprocess() method is deprecated and no longer
+ performs any actions (deprecated in 6.0) (called from :1)
+[ 0.00] Creating model
+[ 0.01] Applying solver
+[ 0.06] Processing results
+ Number of solutions: 1
+ Solution Information
+ Gap: None
+ Status: optimal
+ Function Value: -0.00010001318188373491
+ Solver results file: results.yml
+[ 0.06] Applying Pyomo postprocessing actions
+[ 0.06] Pyomo Finished
+# ==========================================================
+# = Solver Results =
+# ==========================================================
+# ----------------------------------------------------------
+# Problem Information
+# ----------------------------------------------------------
+Problem:
+- Lower bound: -inf
+ Upper bound: inf
+ Number of objectives: 1
+ Number of constraints: 3
+ Number of variables: 3
+ Sense: unknown
+# ----------------------------------------------------------
+# Solver Information
+# ----------------------------------------------------------
+Solver:
+- Status: ok
+ Message: Ipopt 3.14.13\x3a Optimal Solution Found
+ Termination condition: optimal
+ Id: 0
+ Error rc: 0
+ Time: 0.04224729537963867
+# ----------------------------------------------------------
+# Solution Information
+# ----------------------------------------------------------
+Solution:
+- number of solutions: 1
+ number of solutions displayed: 1
+- Gap: None
+ Status: optimal
+ Message: Ipopt 3.14.13\x3a Optimal Solution Found
+ Objective:
+ f1:
+ Value: -0.00010001318188373491
+ Variable:
+ compl.v:
+ Value: 9.99943939749205e-05
+ x:
+ Value: -9.39395440720558e-09
+ y:
+ Value: 9.99943939749205e-05
+ Constraint: No values
+
+"""
+
+fail_ref = """
+[ 0.00] Setting up Pyomo environment
+[ 0.00] Applying Pyomo preprocessing actions
+[ 0.00] Creating model
+[ 0.01] Applying solver
+[ 0.06] Processing results
+ Number of solutions: 1
+ Solution Information
+ Gap: None
+ Status: optimal
+ Function Value: -0.00010001318188373491
+ Solver results file: results.yml
+[ 0.06] Applying Pyomo postprocessing actions
+[ 0.06] Pyomo Finished
+# ==========================================================
+# = Solver Results =
+# ==========================================================
+# ----------------------------------------------------------
+# Problem Information
+# ----------------------------------------------------------
+Problem:
+- Lower bound: -inf
+ Upper bound: inf
+ Number of objectives: 1
+ Number of constraints: 3
+ Number of variables: 3
+ Sense: unknown
+# ----------------------------------------------------------
+# Solver Information
+# ----------------------------------------------------------
+Solver:
+- Status: ok
+ Message: Ipopt 3.14.13\x3a Optimal Solution Found
+ Termination condition: optimal
+ Id: 0
+ Error rc: 0
+ Time: 0.04224729537963867
+# ----------------------------------------------------------
+# Solution Information
+# ----------------------------------------------------------
+Solution:
+- number of solutions: 1
+ number of solutions displayed: 1
+- Gap: None
+ Status: optimal
+ Message: Ipopt 3.14.13\x3a Optimal Solution Found
+ Objective:
+ f1:
+ Value: -0.00010001318188373491
+ Variable:
+ compl.v:
+ Value: 9.79943939749205e-05
+ x:
+ Value: -9.39395440720558e-09
+ y:
+ Value: 9.99943939749205e-05
+ Constraint: No values
+
+"""
+
+
+class TestBaselineTestDriver(unittest.BaselineTestDriver, unittest.TestCase):
+ solver_dependencies = {}
+ package_dependencies = {}
+
+ def test_baseline_pass(self):
+ self.compare_baseline(pass_ref, baseline, abstol=1e-6)
+
+ with self.assertRaises(self.failureException):
+ with capture_output() as OUT:
+ self.compare_baseline(pass_ref, baseline, None)
+ self.assertEqual(
+ OUT.getvalue(),
+ f"""---------------------------------
+BASELINE FILE
+---------------------------------
+{baseline}
+=================================
+---------------------------------
+TEST OUTPUT FILE
+---------------------------------
+{pass_ref}
+""",
+ )
+
+ def test_baseline_fail(self):
+ with self.assertRaises(self.failureException):
+ with capture_output() as OUT:
+ self.compare_baseline(fail_ref, baseline)
+ self.assertEqual(
+ OUT.getvalue(),
+ f"""---------------------------------
+BASELINE FILE
+---------------------------------
+{baseline}
+=================================
+---------------------------------
+TEST OUTPUT FILE
+---------------------------------
+{fail_ref}
+""",
+ )
+
+ def test_testcase_collection(self):
+ with TempfileManager.new_context() as TMP:
+ tmpdir = TMP.create_tempdir()
+ for fname in (
+ 'a.py',
+ 'b.py',
+ 'b.txt',
+ 'c.py',
+ 'c.sh',
+ 'c.yml',
+ 'd.sh',
+ 'd.txt',
+ 'e.sh',
+ ):
+ with open(os.path.join(tmpdir, fname), 'w'):
+ pass
+
+ py_tests, sh_tests = unittest.BaselineTestDriver.gather_tests([tmpdir])
+ self.assertEqual(
+ py_tests,
+ [
+ (
+ os.path.basename(tmpdir) + '_b',
+ os.path.join(tmpdir, 'b.py'),
+ os.path.join(tmpdir, 'b.txt'),
+ )
+ ],
+ )
+ self.assertEqual(
+ sh_tests,
+ [
+ (
+ os.path.basename(tmpdir) + '_c',
+ os.path.join(tmpdir, 'c.sh'),
+ os.path.join(tmpdir, 'c.yml'),
+ ),
+ (
+ os.path.basename(tmpdir) + '_d',
+ os.path.join(tmpdir, 'd.sh'),
+ os.path.join(tmpdir, 'd.txt'),
+ ),
+ ],
+ )
+
+ self.python_test_driver(*py_tests[0])
+
+ _update_baselines = os.environ.pop('PYOMO_TEST_UPDATE_BASELINES', None)
+ try:
+ with open(os.path.join(tmpdir, 'b.py'), 'w') as FILE:
+ FILE.write('print("Hello, World")\n')
+
+ with self.assertRaises(self.failureException):
+ self.python_test_driver(*py_tests[0])
+ with open(os.path.join(tmpdir, 'b.txt'), 'r') as FILE:
+ self.assertEqual(FILE.read(), "")
+
+ os.environ['PYOMO_TEST_UPDATE_BASELINES'] = '1'
+
+ with self.assertRaises(self.failureException):
+ self.python_test_driver(*py_tests[0])
+ with open(os.path.join(tmpdir, 'b.txt'), 'r') as FILE:
+ self.assertEqual(FILE.read(), "Hello, World\n")
+
+ finally:
+ os.environ.pop('PYOMO_TEST_UPDATE_BASELINES', None)
+ if _update_baselines is not None:
+ os.environ['PYOMO_TEST_UPDATE_BASELINES'] = _update_baselines
+
+ self.shell_test_driver(*sh_tests[1])
+ _update_baselines = os.environ.pop('PYOMO_TEST_UPDATE_BASELINES', None)
+ try:
+ with open(os.path.join(tmpdir, 'd.sh'), 'w') as FILE:
+ FILE.write('echo "Hello, World"\n')
+
+ with self.assertRaises(self.failureException):
+ self.shell_test_driver(*sh_tests[1])
+ with open(os.path.join(tmpdir, 'd.txt'), 'r') as FILE:
+ self.assertEqual(FILE.read(), "")
+
+ os.environ['PYOMO_TEST_UPDATE_BASELINES'] = '1'
+
+ with self.assertRaises(self.failureException):
+ self.shell_test_driver(*sh_tests[1])
+ with open(os.path.join(tmpdir, 'd.txt'), 'r') as FILE:
+ self.assertEqual(FILE.read(), "Hello, World\n")
+
+ finally:
+ os.environ.pop('PYOMO_TEST_UPDATE_BASELINES', None)
+ if _update_baselines is not None:
+ os.environ['PYOMO_TEST_UPDATE_BASELINES'] = _update_baselines
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/pyomo/common/timing.py b/pyomo/common/timing.py
index 96360c61a1b..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
@@ -44,30 +44,59 @@
_transform_logger = logging.getLogger('pyomo.common.timing.transformation')
-def report_timing(stream=True, level=logging.INFO):
- """Set reporting of Pyomo timing information.
+class report_timing(object):
+ def __init__(self, stream=True, level=logging.INFO):
+ """Set reporting of Pyomo timing information.
- Parameters
- ----------
- stream: bool, TextIOBase
- The destination stream to emit timing information. If ``True``,
- defaults to ``sys.stdout``. If ``False`` or ``None``, disables
- reporting of timing information.
- level: int
- The logging level for the timing logger
- """
- if stream:
- _logger.setLevel(level)
- if stream is True:
- stream = sys.stdout
- handler = logging.StreamHandler(stream)
- handler.setFormatter(logging.Formatter(" %(message)s"))
- _logger.addHandler(handler)
- return handler
- else:
- _logger.setLevel(logging.WARNING)
- for h in _logger.handlers:
- _logger.removeHandler(h)
+ For historical reasons, this class may be used as a function
+ (the reporting logger is configured as part of the instance
+ initializer). However, the preferred usage is as a context
+ manager (thereby ensuring that the timing logger is restored
+ upon exit).
+
+ Parameters
+ ----------
+ stream: bool, TextIOBase
+
+ The destination stream to emit timing information. If
+ ``True``, defaults to ``sys.stdout``. If ``False`` or
+ ``None``, disables reporting of timing information.
+
+ level: int
+
+ The logging level for the timing logger
+
+ """
+ self._old_level = _logger.level
+ # For historical reasons (because report_timing() used to be a
+ # function), we will do what you think should be done in
+ # __enter__ here in __init__.
+ if stream:
+ _logger.setLevel(level)
+ if stream is True:
+ stream = sys.stdout
+ self._handler = logging.StreamHandler(stream)
+ self._handler.setFormatter(logging.Formatter(" %(message)s"))
+ _logger.addHandler(self._handler)
+ else:
+ self._handler = list(_logger.handlers)
+ _logger.setLevel(logging.WARNING)
+ for h in list(_logger.handlers):
+ _logger.removeHandler(h)
+
+ def reset(self):
+ _logger.setLevel(self._old_level)
+ if type(self._handler) is list:
+ for h in self._handler:
+ _logger.addHandler(h)
+ else:
+ _logger.removeHandler(self._handler)
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, et, ev, tb):
+ self.reset()
class GeneralTimer(object):
@@ -194,19 +223,14 @@ def __str__(self):
#
# Setup the timer
#
-# TODO: Remove this bit for Pyomo 6.0 - we won't care about older versions
-if sys.version_info >= (3, 3):
- # perf_counter is guaranteed to be monotonic and the most accurate timer
- default_timer = time.perf_counter
-elif sys.platform.startswith('win'):
- # On old Pythons, clock() is more accurate than time() on Windows
- # (.35us vs 15ms), but time() is more accurate than clock() on Linux
- # (1ns vs 1us). It is unfortunate that time() is not monotonic, but
- # since the TicTocTimer is used for (potentially very accurate)
- # timers, we will sacrifice monotonicity on Linux for resolution.
- default_timer = time.clock
-else:
- default_timer = time.time
+# perf_counter is guaranteed to be monotonic and the most accurate
+# timer. It became available in Python 3.3. Prior to that, clock() was
+# more accurate than time() on Windows (.35us vs 15ms), but time() was
+# more accurate than clock() on Linux (1ns vs 1us). It is unfortunate
+# that time() is not monotonic, but since the TicTocTimer is used for
+# (potentially very accurate) timers, we will sacrifice monotonicity on
+# Linux for resolution.
+default_timer = time.perf_counter
class TicTocTimer(object):
diff --git a/pyomo/common/unittest.py b/pyomo/common/unittest.py
index c53b7f50398..84d962eb784 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
@@ -17,9 +17,13 @@
# ___________________________________________________________________________
import enum
+import glob
import logging
import math
+import os
+import operator
import re
+import subprocess
import sys
from io import StringIO
@@ -31,7 +35,10 @@
import pytest as pytest
from pyomo.common.collections import Mapping, Sequence
+from pyomo.common.dependencies import attempt_import, check_min_version
from pyomo.common.errors import InvalidValueError
+from pyomo.common.fileutils import import_file
+from pyomo.common.log import LoggingIntercept, pyomo_formatter
from pyomo.common.tee import capture_output
from unittest import mock
@@ -491,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,
@@ -547,3 +558,385 @@ def assertRaisesRegex(self, expected_exception, expected_regex, *args, **kwargs)
contextClass = _unittest.case._AssertRaisesContext
context = contextClass(expected_exception, self, expected_regex)
return context.handle('assertRaisesRegex', args, kwargs)
+
+ def assertExpressionsEqual(self, a, b, include_named_exprs=True, places=None):
+ from pyomo.core.expr.compare import assertExpressionsEqual
+
+ return assertExpressionsEqual(self, a, b, include_named_exprs, places)
+
+ def assertExpressionsStructurallyEqual(
+ self, a, b, include_named_exprs=True, places=None
+ ):
+ from pyomo.core.expr.compare import assertExpressionsStructurallyEqual
+
+ return assertExpressionsStructurallyEqual(
+ self, a, b, include_named_exprs, places
+ )
+
+
+class BaselineTestDriver(object):
+ """Generic driver for performing baseline tests in bulk
+
+ This test driver was originally crafted for testing the examples in
+ the Pyomo Book, and has since been generalized to reuse in testing
+ ".. literalinclude:" examples from the Online Docs.
+
+ We expect that consumers of this class will derive from both this
+ class and `pyomo.common.unittest.TestCase`, and then use
+ `parameterized` to declare tests that call either the
+ :py:meth:`python_test_driver` or :py:meth:`shell_test_driver`
+ methods.
+
+ Note that derived classes must declare two class attributes:
+
+ Class Attributes
+ ----------------
+ solver_dependencies: Dict[str, List[str]]
+
+ maps the test name to a list of required solvers. If any solver
+ is not available, then the test will be skipped.
+
+ package_dependencies: Dict[str, List[str]]
+
+ maps the test name to a list of required modules. If any module
+ is not available, then the test will be skipped.
+
+ """
+
+ @staticmethod
+ def custom_name_func(test_func, test_num, test_params):
+ func_name = test_func.__name__
+ return "test_%s_%s" % (test_params.args[0], func_name[-2:])
+
+ def __init__(self, test):
+ # Finalize the class, if necessary...
+ if getattr(self.__class__, 'solver_available', None) is None:
+ self.initialize_dependencies()
+ super().__init__(test)
+
+ def initialize_dependencies(self):
+ # Note: as a rule, pyomo.common is not allowed to import from
+ # the rest of Pyomo. we permit it here because a) this is not
+ # at module scope, and b) there is really no better / more
+ # logical place in pyomo to put this code.
+ from pyomo.opt import check_available_solvers
+
+ cls = self.__class__
+ #
+ # Initialize the availability data
+ #
+ solvers_used = set(sum(list(cls.solver_dependencies.values()), []))
+ available_solvers = check_available_solvers(*solvers_used)
+ cls.solver_available = {
+ solver_: (solver_ in available_solvers) for solver_ in solvers_used
+ }
+
+ cls.package_available = {}
+ cls.package_modules = {}
+ packages_used = set(sum(list(cls.package_dependencies.values()), []))
+ for package_ in packages_used:
+ pack, pack_avail = attempt_import(package_, defer_import=False)
+ cls.package_available[package_] = pack_avail
+ cls.package_modules[package_] = pack
+
+ @classmethod
+ def _find_tests(cls, test_dirs, pattern):
+ test_tuples = []
+ for testdir in test_dirs:
+ # Find all pattern files in the test directory and any immediate
+ # sub-directories
+ for fname in list(glob.glob(os.path.join(testdir, pattern))) + list(
+ glob.glob(os.path.join(testdir, '*', pattern))
+ ):
+ test_file = os.path.abspath(fname)
+ bname = os.path.basename(test_file)
+ dir_ = os.path.dirname(test_file)
+ name = os.path.splitext(bname)[0]
+ tname = os.path.basename(dir_) + '_' + name
+
+ suffix = None
+ # Look for txt and yml file names matching py file names. Add
+ # a test for any found
+ for suffix_ in ['.txt', '.yml']:
+ if os.path.exists(os.path.join(dir_, name + suffix_)):
+ suffix = suffix_
+ break
+ if suffix is not None:
+ tname = tname.replace('-', '_')
+ tname = tname.replace('.', '_')
+
+ # Create list of tuples with (test_name, test_file, baseline_file)
+ test_tuples.append(
+ (tname, test_file, os.path.join(dir_, name + suffix))
+ )
+
+ # Ensure a deterministic test ordering
+ test_tuples.sort()
+ return test_tuples
+
+ @classmethod
+ def gather_tests(cls, test_dirs):
+ # Find all .sh files in the test directories
+ sh_test_tuples = cls._find_tests(test_dirs, '*.sh')
+
+ # Find all .py files in the test directories
+ py_test_tuples = cls._find_tests(test_dirs, '*.py')
+
+ # If there is both a .py and a .sh, defer to the sh
+ sh_files = set(map(operator.itemgetter(1), sh_test_tuples))
+ py_test_tuples = list(
+ filter(lambda t: t[1][:-3] + '.sh' not in sh_files, py_test_tuples)
+ )
+
+ return py_test_tuples, sh_test_tuples
+
+ def check_skip(self, name):
+ """
+ Return a boolean if the test should be skipped
+ """
+
+ if name in self.solver_dependencies:
+ solvers_ = self.solver_dependencies[name]
+ if not all([self.solver_available[i] for i in solvers_]):
+ # Skip the test because a solver is not available
+ _missing = []
+ for i in solvers_:
+ if not self.solver_available[i]:
+ _missing.append(i)
+ return "Solver%s %s %s not available" % (
+ 's' if len(_missing) > 1 else '',
+ ", ".join(_missing),
+ 'are' if len(_missing) > 1 else 'is',
+ )
+
+ if name in self.package_dependencies:
+ packages_ = self.package_dependencies[name]
+ if not all([self.package_available[i] for i in packages_]):
+ # Skip the test because a package is not available
+ _missing = []
+ for i in packages_:
+ if not self.package_available[i]:
+ _missing.append(i)
+ return "Package%s %s %s not available" % (
+ 's' if len(_missing) > 1 else '',
+ ", ".join(_missing),
+ 'are' if len(_missing) > 1 else 'is',
+ )
+
+ # This is a hack, xlrd dropped support for .xlsx files in 2.0.1 which
+ # causes problems with older versions of Pandas<=1.1.5 so skipping
+ # tests requiring both these packages when incompatible versions are found
+ if (
+ 'pandas' in self.package_dependencies[name]
+ and 'xlrd' in self.package_dependencies[name]
+ ):
+ if check_min_version(
+ self.package_modules['xlrd'], '2.0.1'
+ ) and not check_min_version(self.package_modules['pandas'], '1.1.6'):
+ return "Incompatible versions of xlrd and pandas"
+
+ return False
+
+ def filter_fcn(self, line):
+ """
+ Ignore certain text when comparing output with baseline
+ """
+ for field in (
+ '[',
+ 'password:',
+ 'http:',
+ 'Job ',
+ 'Importing module',
+ 'Function',
+ 'File',
+ 'Matplotlib',
+ 'Memory:',
+ '-------',
+ '=======',
+ ' ^',
+ ):
+ if line.startswith(field):
+ return True
+ for field in (
+ 'Total CPU',
+ 'Ipopt',
+ 'license',
+ #'Status: optimal',
+ #'Status: feasible',
+ 'time:',
+ 'Time:',
+ 'with format cpxlp',
+ 'usermodel = 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)
@@ -933,7 +940,7 @@ def update_config(self, val: UpdateConfig):
def set_instance(self, model):
saved_update_config = self.update_config
- self.__init__()
+ self.__init__(only_child_vars=self._only_child_vars)
self.update_config = saved_update_config
self._model = model
if self.use_extensions and cmodel_available:
@@ -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 2a4e7bb785e..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
@@ -63,10 +54,10 @@ def get_appsi_extension(in_setup=False, appsi_root=None):
def build_appsi(args=[]):
print('\n\n**** Building APPSI ****')
- import setuptools
- from distutils.dist import Distribution
+ 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