Skip to content

Commit

Permalink
Merge pull request #1844 from jsiirola/mosek-test-updates
Browse files Browse the repository at this point in the history
Update Mosek tests, fixed variable bounds
  • Loading branch information
jsiirola authored Feb 26, 2021
2 parents 9c48afa + 2f9af81 commit 7412149
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
14 changes: 10 additions & 4 deletions pyomo/solvers/plugins/solvers/mosek_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,16 @@ def _add_vars(self, var_seq):
vnames = tuple(self._symbol_map.getSymbol(
v, self._labeler) for v in var_seq)
vtypes = tuple(map(self._mosek_vartype_from_var, var_seq))
lbs = tuple(-inf if value(v.lb) is None else value(v.lb)
for v in var_seq)
ubs = tuple(inf if value(v.ub) is None else value(v.ub)
for v in var_seq)
lbs = tuple( value(v) if v.fixed
else -inf if value(v.lb) is None
else value(v.lb)
for v in var_seq
)
ubs = tuple( value(v) if v.fixed
else inf if value(v.ub) is None
else value(v.ub)
for v in var_seq
)
fxs = tuple(v.is_fixed() for v in var_seq)
bound_types = tuple(map(self._mosek_bounds, lbs, ubs, fxs))
self._solver_model.appendvars(len(var_seq))
Expand Down
14 changes: 10 additions & 4 deletions pyomo/solvers/plugins/solvers/mosek_persistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,16 @@ def update_vars(self, *solver_vars):
for v in solver_vars:
var_ids.append(self._pyomo_var_to_solver_var_map[v])
vtypes = tuple(map(self._mosek_vartype_from_var, solver_vars))
lbs = tuple(-float('inf') if value(v.lb) is None else value(v.lb)
for v in solver_vars)
ubs = tuple(float('inf') if value(v.ub) is None else value(v.ub)
for v in solver_vars)
lbs = tuple( value(v) if v.fixed
else -float('inf') if value(v.lb) is None
else value(v.lb)
for v in solver_vars
)
ubs = tuple( value(v) if v.fixed
else float('inf') if value(v.ub) is None
else value(v.ub)
for v in solver_vars
)
fxs = tuple(v.is_fixed() for v in solver_vars)
bound_types = tuple(map(self._mosek_bounds, lbs, ubs, fxs))
self._solver_model.putvartypelist(var_ids, vtypes)
Expand Down
17 changes: 11 additions & 6 deletions pyomo/solvers/tests/checks/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ def pickle_test(self):
load_solutions = (not model_class.solve_should_fail) and \
(test_case.status != 'expected failure')

opt, status = model_class.solve(solver,
io,
test_case.testcase.io_options,
test_case.testcase.options,
symbolic_labels,
load_solutions)
try:
opt, status = model_class.solve(solver,
io,
test_case.testcase.io_options,
test_case.testcase.options,
symbolic_labels,
load_solutions)
except:
if test_case.status == 'expected failure':
return
raise
m = pickle.loads(pickle.dumps(model_class.model))

#
Expand Down
8 changes: 4 additions & 4 deletions pyomo/solvers/tests/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ def test_solver_cases(*args):
'conic_constraints'])

_test_solver_cases['mosek', 'python'] = initialize(
name='mosek_direct',
name='mosek',
io='python',
capabilities=_mosek_capabilities,
import_suffixes=['dual', 'rc', 'slack'])

#
# MOSEK Persistent
#
_test_solver_cases['mosek_persistent','python'] = initialize(
name = 'mosek_persistent',
io = 'python',
_test_solver_cases['mosek','persistent'] = initialize(
name = 'mosek',
io = 'persistent',
capabilities=_mosek_capabilities,
import_suffixes=['dual','rc','slack'])

Expand Down
15 changes: 5 additions & 10 deletions pyomo/solvers/tests/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,12 @@
# MOSEK
#

ExpectedFailures['mosek_direct', 'python', 'QCP_simple'] = \
(lambda v: True,
"Conic constraints not yet handled by this interface")
for _io in ('python', 'persistent'):
for _test in ('QCP_simple', 'QCP_simple_nosuffixes', 'MIQCP_simple'):
ExpectedFailures['mosek', _io, _test] = (
lambda v: True,
"Mosek does not handle nonconvex quadratic constraints")

ExpectedFailures['mosek_direct', 'python', 'QCP_simple_nosuffixes'] = \
(lambda v: True,
"Conic constraints not yet handled by this interface")

ExpectedFailures['mosek_direct', 'python', 'MIQCP_simple'] = \
(lambda v: True,
"Conic constraints not yet handled by this interface")
#
# CPLEX
#
Expand Down

0 comments on commit 7412149

Please sign in to comment.