Skip to content

Commit f1dbf5e

Browse files
committed
Misc edits to resolve bugs in pycoek usage
1 parent f641b4e commit f1dbf5e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Diff for: lib/pyomo_coek/pyomo_coek/components_only/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .linear_expression import LinearExpression
88
from pyomo.core.base.block import Block
99
from pyomo.core.base.PyomoModel import ConcreteModel
10-
from pyomo.core.base.set import RangeSet, \
10+
from pyomo.core.base.set import Set, RangeSet, \
1111
Reals, \
1212
PositiveReals, \
1313
NonPositiveReals, \

Diff for: lib/pyomo_coek/pyomo_coek/components_only/solvers.py

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def __init__(self, solver_name):
7070
self.solution_loader = MySolutionLoader(None, None, None, None)
7171

7272
def available(self):
73+
if self._opt is None:
74+
return self.Availability.NotFound
7375
if self._opt.available:
7476
return self.Availability.FullLicense
7577
else:

Diff for: lib/pyomo_coek/pyomo_coek/test/level1/test_solver.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

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

1112

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

2930
opt = pyomo_module.SolverFactory("coek_gurobi")
30-
if opt.available(False):
31+
if opt.available():
3132
res = opt.solve(m)
3233
pyo.check_optimal_termination(m)
3334

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

4142
opt = pyomo_module.SolverFactory("coek_ipopt")
42-
if opt.available(False):
43+
if opt.available():
4344
res = opt.solve(m)
4445
pyo.check_optimal_termination(m)

0 commit comments

Comments
 (0)