Skip to content

Commit

Permalink
Misc edits to resolve bugs in pycoek usage
Browse files Browse the repository at this point in the history
  • Loading branch information
whart222 committed Jul 11, 2024
1 parent f641b4e commit f1dbf5e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/pyomo_coek/pyomo_coek/components_only/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .linear_expression import LinearExpression
from pyomo.core.base.block import Block
from pyomo.core.base.PyomoModel import ConcreteModel
from pyomo.core.base.set import RangeSet, \
from pyomo.core.base.set import Set, RangeSet, \
Reals, \
PositiveReals, \
NonPositiveReals, \
Expand Down
2 changes: 2 additions & 0 deletions lib/pyomo_coek/pyomo_coek/components_only/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def __init__(self, solver_name):
self.solution_loader = MySolutionLoader(None, None, None, None)

def available(self):
if self._opt is None:
return self.Availability.NotFound
if self._opt.available:
return self.Availability.FullLicense
else:
Expand Down
5 changes: 3 additions & 2 deletions lib/pyomo_coek/pyomo_coek/test/level1/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

def test_available1(pyomo_module):
opt = pyomo_module.SolverFactory("bad_pyomo_solvername")
# TODO - resolve this inconsistency in the API
assert not opt.available(False)


Expand All @@ -27,7 +28,7 @@ def test_gurobi(pyomo_module):
m.o = pyomo_module.Objective(expr=m.x0 + m.x1)

opt = pyomo_module.SolverFactory("coek_gurobi")
if opt.available(False):
if opt.available():
res = opt.solve(m)
pyo.check_optimal_termination(m)

Expand All @@ -39,6 +40,6 @@ def test_ipopt(pyomo_module):
m.o = pyomo_module.Objective(expr=m.x0 + m.x1)

opt = pyomo_module.SolverFactory("coek_ipopt")
if opt.available(False):
if opt.available():
res = opt.solve(m)
pyo.check_optimal_termination(m)

0 comments on commit f1dbf5e

Please sign in to comment.