diff --git a/pyomo/solvers/plugins/solvers/mosek_direct.py b/pyomo/solvers/plugins/solvers/mosek_direct.py index dc1fa0f43a9..972a82a16fa 100644 --- a/pyomo/solvers/plugins/solvers/mosek_direct.py +++ b/pyomo/solvers/plugins/solvers/mosek_direct.py @@ -39,6 +39,7 @@ mosek, mosek_available = attempt_import('mosek') + class DegreeError(ValueError): pass @@ -566,6 +567,16 @@ def _add_block(self, block): "support multiple objectives.") self._set_objective(obj) + def _set_whichsol(self): + itr_soltypes = [mosek.problemtype.qo, mosek.problemtype.qcqo, + mosek.problemtype.conic] + if (self._solver_model.getnumintvar() >= 1): + self._whichsol = mosek.soltype.itg + elif (self._solver_model.getprobtype() in itr_soltypes): + self._whichsol = mosek.soltype.itr + elif (self._solver_model.getprobtype() == mosek.problemtype.lo): + self._whichsol = mosek.soltype.bas + def _postsolve(self): extract_duals = False @@ -589,19 +600,15 @@ def _postsolve(self): msk_task = self._solver_model - itr_soltypes = [mosek.problemtype.qo, mosek.problemtype.qcqo, - mosek.problemtype.conic] + self._set_whichsol() - if (msk_task.getnumintvar() >= 1): - self._whichsol = mosek.soltype.itg + if (self._whichsol == mosek.soltype.itg): if extract_reduced_costs: logger.warning("Cannot get reduced costs for MIP.") if extract_duals: logger.warning("Cannot get duals for MIP.") extract_reduced_costs = False extract_duals = False - elif (msk_task.getprobtype() in itr_soltypes): - self._whichsol = mosek.soltype.itr whichsol = self._whichsol sol_status = msk_task.getsolsta(whichsol) @@ -975,11 +982,15 @@ def warm_start_capable(self): return True def _warm_start(self): + self._set_whichsol() for pyomo_var, mosek_var in self._pyomo_var_to_solver_var_map.items(): if pyomo_var.value is not None: - for solType in mosek.soltype.values: - self._solver_model.putxxslice( - solType, mosek_var, mosek_var + 1, [(pyomo_var.value)]) + self._solver_model.putxxslice( + self._whichsol, mosek_var, mosek_var + 1, [(pyomo_var.value)]) + + if (self._version[0] > 9) & (self._whichsol == mosek.soltype.itg): + self._solver_model.putintparam( + mosek.iparam.mio_construct_sol, mosek.onoffkey.on) def _load_vars(self, vars_to_load=None): var_map = self._pyomo_var_to_solver_var_map