Skip to content

Commit

Permalink
Merge branch 'main' into add-accidental-formulation
Browse files Browse the repository at this point in the history
  • Loading branch information
emma58 committed Oct 9, 2024
2 parents af9e4c3 + ef61460 commit d357a15
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 209 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,19 @@ jobs:
other: [""]
category: [""]

# win/3.8 conda builds no longer work due to environment not being able
# to resolve. We are skipping it now.
exclude:
- os: windows-latest
python: 3.8

include:
- os: ubuntu-latest
python: '3.12'
TARGET: linux
PYENV: pip

- os: macos-13
- os: macos-latest
python: '3.10'
TARGET: osx
PYENV: pip
Expand Down Expand Up @@ -215,6 +221,7 @@ jobs:
if: matrix.TARGET == 'win'
run: |
echo "SETUPTOOLS_USE_DISTUTILS=local" >> $GITHUB_ENV
choco install pkgconfiglite
- name: Set up Python ${{ matrix.python }}
if: matrix.PYENV == 'pip'
Expand Down Expand Up @@ -352,6 +359,10 @@ jobs:
done
echo ""
echo "*** Install Pyomo dependencies ***"
# For windows, cannot use newer setuptools because of APPSI compilation issues
if test "${{matrix.TARGET}}" == 'win'; then
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES setuptools<74.0.0"
fi
# Note: this will fail the build if any installation fails (or
# possibly if it outputs messages to stderr)
conda install --update-deps -q -y $CONDA_DEPENDENCIES
Expand Down
26 changes: 16 additions & 10 deletions .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
python: [ 3.8, 3.9, '3.10', '3.11', '3.12' ]
other: [""]
category: [""]
Expand All @@ -77,12 +77,13 @@ jobs:
exclude:
- os: windows-latest
python: 3.8

include:
- os: ubuntu-latest
TARGET: linux
PYENV: pip

- os: macos-13
- os: macos-latest
TARGET: osx
PYENV: pip

Expand All @@ -108,14 +109,6 @@ jobs:
PYENV: conda
PACKAGES: openmpi mpi4py

- os: ubuntu-latest
python: '3.11'
other: /singletest
category: "-m 'neos or importtest'"
skip_doctest: 1
TARGET: linux
PYENV: pip

- os: ubuntu-latest
python: '3.10'
other: /cython
Expand All @@ -132,6 +125,14 @@ jobs:
TARGET: win
PYENV: pip

- os: ubuntu-latest
python: '3.11'
other: /singletest
category: "-m 'neos or importtest'"
skip_doctest: 1
TARGET: linux
PYENV: pip

- os: ubuntu-latest
python: 3.8
other: /slim
Expand Down Expand Up @@ -243,6 +244,7 @@ jobs:
if: matrix.TARGET == 'win'
run: |
echo "SETUPTOOLS_USE_DISTUTILS=local" >> $GITHUB_ENV
choco install pkgconfiglite
- name: Set up Python ${{ matrix.python }}
if: matrix.PYENV == 'pip'
Expand Down Expand Up @@ -380,6 +382,10 @@ jobs:
done
echo ""
echo "*** Install Pyomo dependencies ***"
# For windows, cannot use newer setuptools because of APPSI compilation issues
if test "${{matrix.TARGET}}" == 'win'; then
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES setuptools<74.0.0"
fi
# Note: this will fail the build if any installation fails (or
# possibly if it outputs messages to stderr)
conda install --update-deps -q -y $CONDA_DEPENDENCIES
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![Jenkins Status](https://github.com/Pyomo/jenkins-status/blob/main/pyomo_main.svg)](https://pyomo-jenkins.sandia.gov/)
[![codecov](https://codecov.io/gh/Pyomo/pyomo/branch/main/graph/badge.svg)](https://codecov.io/gh/Pyomo/pyomo)
[![Documentation Status](https://readthedocs.org/projects/pyomo/badge/?version=latest)](http://pyomo.readthedocs.org/en/latest/)
[![URL Validation](https://img.shields.io/github/actions/workflow/status/Pyomo/pyomo/url_check.yml?branch=main&label=doc%20urls)](https://github.com/Pyomo/pyomo/actions/workflows/url_check.yml)
[![Build services](https://github.com/Pyomo/jenkins-status/blob/main/pyomo_services.svg)](https://pyomo-jenkins.sandia.gov/)
[![GitHub contributors](https://img.shields.io/github/contributors/pyomo/pyomo.svg)](https://github.com/pyomo/pyomo/graphs/contributors)
[![Merged PRs](https://img.shields.io/github/issues-pr-closed-raw/pyomo/pyomo.svg?label=merged+PRs)](https://github.com/pyomo/pyomo/pulls?q=is:pr+is:merged)
Expand Down
6 changes: 6 additions & 0 deletions examples/pyomobook/gdp-ch/gdp_uc.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ def obj(m):
@model.Constraint(model.GENERATORS)
def nontrivial(m, g):
return sum(m.Power[g, t] for t in m.TIME) >= len(m.TIME) / 2 * m.MinPower[g]


@model.ConstraintList()
def nondegenerate(m):
for i, g in enumerate(m.GENERATORS):
yield m.Power[g, i + 1] == 0
30 changes: 15 additions & 15 deletions examples/pyomobook/gdp-ch/pyomo.gdp_uc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Problem:
Lower bound: 45.0
Upper bound: 45.0
Number of objectives: 1
Number of constraints: 58
Number of constraints: 60
Number of variables: 24
Number of nonzeros: 124
Number of nonzeros: 126
Sense: minimize
# ----------------------------------------------------------
# Solver Information
Expand All @@ -34,8 +34,8 @@ Solver:
Termination condition: optimal
Statistics:
Branch and bound:
Number of bounded subproblems: 15
Number of created subproblems: 15
Number of bounded subproblems: 9
Number of created subproblems: 9
Error rc: 0
Time: 0.007754325866699219
# ----------------------------------------------------------
Expand All @@ -51,24 +51,24 @@ Solution:
obj:
Value: 45
Variable:
GenOff[g1,2].binary_indicator_var:
GenOff[g1,1].binary_indicator_var:
Value: 1
GenOff[g2,1].binary_indicator_var:
GenOff[g2,2].binary_indicator_var:
Value: 1
GenOn[g1,1].binary_indicator_var:
GenOn[g1,3].binary_indicator_var:
Value: 1
GenOn[g2,3].binary_indicator_var:
GenOn[g2,1].binary_indicator_var:
Value: 1
GenStartup[g1,3].binary_indicator_var:
GenStartup[g1,2].binary_indicator_var:
Value: 1
GenStartup[g2,2].binary_indicator_var:
GenStartup[g2,3].binary_indicator_var:
Value: 1
Power[g1,1]:
Value: 10
Power[g1,3]:
Power[g1,2]:
Value: 5
Power[g2,2]:
Power[g1,3]:
Value: 10
Power[g2,3]:
Power[g2,1]:
Value: 20
Power[g2,3]:
Value: 10
Constraint: No values
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def test_post_processing(self):
fme = TransformationFactory('contrib.fourier_motzkin_elimination')
fme.apply_to(m, vars_to_eliminate=disaggregatedVars, do_integer_arithmetic=True)
# post-process
fme.post_process_fme_constraints(m, SolverFactory('glpk'))
fme.post_process_fme_constraints(m, SolverFactory('glpk'), tolerance=-1e-6)

constraints = m._pyomo_contrib_fme_transformation.projected_constraints
self.assertEqual(len(constraints), 11)
Expand Down
85 changes: 1 addition & 84 deletions pyomo/contrib/pynumero/sparse/block_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def assert_block_structure(vec):
raise NotFullyDefinedBlockVectorError(msg)


class BlockVector(np.ndarray, BaseBlockVector):
class BlockVector(BaseBlockVector, np.ndarray):
"""
Structured vector interface. This interface can be used to
perform operations on vectors composed by vectors. For example,
Expand Down Expand Up @@ -1592,86 +1592,3 @@ def toMPIBlockVector(self, rank_ownership, mpi_comm, assert_correct_owners=False
mpi_bv.set_block(bid, self.get_block(bid))

return mpi_bv

# the following methods are not supported by blockvector

def argpartition(self, kth, axis=-1, kind='introselect', order=None):
BaseBlockVector.argpartition(self, kth, axis=axis, kind=kind, order=order)

def argsort(self, axis=-1, kind='quicksort', order=None):
BaseBlockVector.argsort(self, axis=axis, kind=kind, order=order)

def byteswap(self, inplace=False):
BaseBlockVector.byteswap(self, inplace=inplace)

def choose(self, choices, out=None, mode='raise'):
BaseBlockVector.choose(self, choices, out=out, mode=mode)

def diagonal(self, offset=0, axis1=0, axis2=1):
BaseBlockVector.diagonal(self, offset=offset, axis1=axis1, axis2=axis2)

def dump(self, file):
BaseBlockVector.dump(self, file)

def dumps(self):
BaseBlockVector.dumps(self)

def getfield(self, dtype, offset=0):
BaseBlockVector.getfield(self, dtype, offset=offset)

def item(self, *args):
BaseBlockVector.item(self, *args)

def itemset(self, *args):
BaseBlockVector.itemset(self, *args)

def newbyteorder(self, new_order='S'):
BaseBlockVector.newbyteorder(self, new_order=new_order)

def put(self, indices, values, mode='raise'):
BaseBlockVector.put(self, indices, values, mode=mode)

def partition(self, kth, axis=-1, kind='introselect', order=None):
BaseBlockVector.partition(self, kth, axis=axis, kind=kind, order=order)

def repeat(self, repeats, axis=None):
BaseBlockVector.repeat(self, repeats, axis=axis)

def reshape(self, shape, order='C'):
BaseBlockVector.reshape(self, shape, order=order)

def resize(self, new_shape, refcheck=True):
BaseBlockVector.resize(self, new_shape, refcheck=refcheck)

def searchsorted(self, v, side='left', sorter=None):
BaseBlockVector.searchsorted(self, v, side=side, sorter=sorter)

def setfield(self, val, dtype, offset=0):
BaseBlockVector.setfield(self, val, dtype, offset=offset)

def setflags(self, write=None, align=None, uic=None):
BaseBlockVector.setflags(self, write=write, align=align, uic=uic)

def sort(self, axis=-1, kind='quicksort', order=None):
BaseBlockVector.sort(self, axis=axis, kind=kind, order=order)

def squeeze(self, axis=None):
BaseBlockVector.squeeze(self, axis=axis)

def swapaxes(self, axis1, axis2):
BaseBlockVector.swapaxes(self, axis1, axis2)

def tobytes(self, order='C'):
BaseBlockVector.tobytes(self, order=order)

def take(self, indices, axis=None, out=None, mode='raise'):
BaseBlockVector.take(self, indices, axis=axis, out=out, mode=mode)

def trace(self, offset=0, axis1=0, axis2=1, dtype=None, out=None):
raise NotImplementedError('trace not implemented for BlockVector')

def transpose(*axes):
BaseBlockVector.transpose(*axes)

def tostring(order='C'):
BaseBlockVector.tostring(order=order)
80 changes: 1 addition & 79 deletions pyomo/contrib/pynumero/sparse/mpi_block_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def assert_block_structure(vec):
raise NotFullyDefinedBlockVectorError(msg)


class MPIBlockVector(np.ndarray, BaseBlockVector):
class MPIBlockVector(BaseBlockVector, np.ndarray):
"""
Parallel structured vector interface. This interface can be used to
perform parallel operations on vectors composed by vectors. The main
Expand Down Expand Up @@ -1447,81 +1447,3 @@ def flatten(self, order='C'):

def ravel(self, order='C'):
raise RuntimeError('Operation not supported by MPIBlockVector')

def argpartition(self, kth, axis=-1, kind='introselect', order=None):
BaseBlockVector.argpartition(self, kth, axis=axis, kind=kind, order=order)

def argsort(self, axis=-1, kind='quicksort', order=None):
BaseBlockVector.argsort(self, axis=axis, kind=kind, order=order)

def byteswap(self, inplace=False):
BaseBlockVector.byteswap(self, inplace=inplace)

def choose(self, choices, out=None, mode='raise'):
BaseBlockVector.choose(self, choices, out=out, mode=mode)

def diagonal(self, offset=0, axis1=0, axis2=1):
BaseBlockVector.diagonal(self, offset=offset, axis1=axis1, axis2=axis2)

def dump(self, file):
BaseBlockVector.dump(self, file)

def dumps(self):
BaseBlockVector.dumps(self)

def getfield(self, dtype, offset=0):
BaseBlockVector.getfield(self, dtype, offset=offset)

def item(self, *args):
BaseBlockVector.item(self, *args)

def itemset(self, *args):
BaseBlockVector.itemset(self, *args)

def newbyteorder(self, new_order='S'):
BaseBlockVector.newbyteorder(self, new_order=new_order)

def put(self, indices, values, mode='raise'):
BaseBlockVector.put(self, indices, values, mode=mode)

def partition(self, kth, axis=-1, kind='introselect', order=None):
BaseBlockVector.partition(self, kth, axis=axis, kind=kind, order=order)

def repeat(self, repeats, axis=None):
BaseBlockVector.repeat(self, repeats, axis=axis)

def reshape(self, shape, order='C'):
BaseBlockVector.reshape(self, shape, order=order)

def resize(self, new_shape, refcheck=True):
BaseBlockVector.resize(self, new_shape, refcheck=refcheck)

def searchsorted(self, v, side='left', sorter=None):
BaseBlockVector.searchsorted(self, v, side=side, sorter=sorter)

def setfield(self, val, dtype, offset=0):
BaseBlockVector.setfield(self, val, dtype, offset=offset)

def setflags(self, write=None, align=None, uic=None):
BaseBlockVector.setflags(self, write=write, align=align, uic=uic)

def sort(self, axis=-1, kind='quicksort', order=None):
BaseBlockVector.sort(self, axis=axis, kind=kind, order=order)

def squeeze(self, axis=None):
BaseBlockVector.squeeze(self, axis=axis)

def swapaxes(self, axis1, axis2):
BaseBlockVector.swapaxes(self, axis1, axis2)

def tobytes(self, order='C'):
BaseBlockVector.tobytes(self, order=order)

def argmax(self, axis=None, out=None):
BaseBlockVector.argmax(self, axis=axis, out=out)

def argmin(self, axis=None, out=None):
BaseBlockVector.argmax(self, axis=axis, out=out)

def take(self, indices, axis=None, out=None, mode='raise'):
BaseBlockVector.take(self, indices, axis=axis, out=out, mode=mode)
2 changes: 1 addition & 1 deletion pyomo/core/kernel/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def getname(
Args:
fully_qualified (bool): Generate a full name by
iterating through all anscestor containers.
iterating through all ancestor containers.
Default is :const:`False`.
convert (function): A function that converts a
storage key into a string
Expand Down
Loading

0 comments on commit d357a15

Please sign in to comment.