Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Mosek tests, fixed variable bounds #1844

Merged
merged 2 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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