Skip to content

Commit

Permalink
Merge branch 'main' into dsda_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmundt authored Nov 26, 2024
2 parents 69e68e4 + d3f0bf5 commit e0cc3ff
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion doc/OnlineDocs/explanation/solvers/persistent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ notify the solver of incremental changes to a Pyomo model. The
persistent solver interfaces create and store model instances from the
Python API for the corresponding solver. For example, the
:class:`GurobiPersistent<pyomo.solvers.plugins.solvers.gurobi_persistent.GurobiPersistent>`
class maintaints a pointer to a gurobipy Model object. Thus, we can
class maintains a pointer to a gurobipy Model object. Thus, we can
make small changes to the model and notify the solver rather than
recreating the entire model using the solver Python API (or rewriting
an entire model file - e.g., an lp file) every time the model is
Expand Down
2 changes: 1 addition & 1 deletion pyomo/common/fileutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ class PathManager(object):
The ``Executable`` singleton uses :py:class:`ExecutableData`, an
extended form of the :py:class:`PathData` class, which provides the
``executable`` property as an alais for :py:meth:`path()` and
``executable`` property as an alias for :py:meth:`path()` and
:py:meth:`set_path()`:
.. doctest::
Expand Down
4 changes: 2 additions & 2 deletions pyomo/contrib/pynumero/sparse/mpi_block_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ def nnz(self):
@property
def owned_blocks(self):
"""
Returns list with inidices of blocks owned by this processor.
Returns list with indices of blocks owned by this processor.
"""
return list(zip(*np.nonzero(self._owned_mask)))

@property
def shared_blocks(self):
"""
Returns list of 2-tuples with inidices of blocks shared by all processors
Returns list of 2-tuples with indices of blocks shared by all processors
"""
return list(zip(*np.nonzero(self._rank_owner < 0)))

Expand Down
13 changes: 7 additions & 6 deletions pyomo/neos/kestrel.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ def getJobAndPassword(self):
password = m.groups()[0]
return (jobNumber, password)

def getAvailableSolvers(self):
"""Return a list of all NEOS solvers that this interface supports"""
allKestrelSolvers = self.neos.listSolversInCategory("kestrel")
_ampl = ':AMPL'
return sorted(s[: -len(_ampl)] for s in allKestrelSolvers if s.endswith(_ampl))

def getSolverName(self):
"""
Read in the kestrel_options to pick out the solver name.
Expand All @@ -218,12 +224,7 @@ def getSolverName(self):
"""
# Get a list of available kestrel solvers from NEOS
allKestrelSolvers = self.neos.listSolversInCategory("kestrel")
kestrelAmplSolvers = []
for s in allKestrelSolvers:
i = s.find(':AMPL')
if i > 0:
kestrelAmplSolvers.append(s[0:i])
kestrelAmplSolvers = self.getAvailableSolvers()
self.options = None
# Read kestrel_options to get solver name
if "kestrel_options" in os.environ:
Expand Down
16 changes: 12 additions & 4 deletions pyomo/neos/tests/test_neos.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ def test_connection_failed(self):
finally:
pyomo.neos.kestrel.NEOS.host = orig_host

def test_check_all_ampl_solvers(self):
kestrel = kestrelAMPL()
solvers = kestrel.getAvailableSolvers()
for solver in solvers:
name = solver.lower().replace('-', '')
if not hasattr(RunAllNEOSSolvers, 'test_' + name):
self.fail(f"RunAllNEOSSolvers missing test for '{solver}'")


class RunAllNEOSSolvers(object):
def test_bonmin(self):
Expand Down Expand Up @@ -165,10 +173,10 @@ def test_ooqp(self):
else:
self._run('ooqp')

# The simple tests aren't complementarity
# problems
# def test_path(self):
# self._run('path')
def test_path(self):
# The simple tests aren't complementarity
# problems
self.skipTest("The simple NEOS test is not a complementarity problem")

def test_snopt(self):
self._run('snopt')
Expand Down
2 changes: 1 addition & 1 deletion pyomo/opt/plugins/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def setup_test_parser(parser):
def test_exec(options):
import pyomo.solvers.tests.testcases

pyomo.solvers.tests.testcases.run_test_scenarios(options)
pyomo.solvers.tests.testcases.run_scenarios(options)


#
Expand Down
6 changes: 3 additions & 3 deletions pyomo/solvers/tests/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def run_scenarios(options):

for key, test_case in generate_scenarios():
model, solver, io = key
if len(solvers) > 0 and not solver in solvers:
if len(solvers) > 0 and solver not in solvers:
continue
if test_case.status == 'skip':
continue
Expand All @@ -381,7 +381,7 @@ def run_scenarios(options):
# Validate solution status
try:
model_class.post_solve_test_validation(None, results)
except:
except Exception:
if test_case.status == 'expected failure':
stat[key] = (True, "Expected failure")
else:
Expand Down Expand Up @@ -431,7 +431,7 @@ def run_scenarios(options):
total = Bunch(NumEPass=0, NumEFail=0, NumUPass=0, NumUFail=0)
for key in stat:
model, solver, io = key
if not solver in summary:
if solver not in summary:
summary[solver] = Bunch(NumEPass=0, NumEFail=0, NumUPass=0, NumUFail=0)
_pass, _str = stat[key]
if _pass:
Expand Down

0 comments on commit e0cc3ff

Please sign in to comment.