Skip to content
Snippets Groups Projects
Commit 6a42d20a authored by Tim Rheinfels's avatar Tim Rheinfels
Browse files

util: implement function to check for the presence of MOSEK

parent fee7bef5
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,9 @@
### @author Tim Rheinfels <tim.rheinfels@fau.de>
###
import cvxpy as cp
from enum import Enum
import logging
import json
import numpy as np
......@@ -98,3 +100,20 @@ class Serializable(object): #pragma: no cover
def __str__(self):
assert(hasattr(self, 'to_dict'))
return json.dumps(self.to_dict(), indent=2, cls=StrJSONEncoder)
###
### @brief Checks if MOSEK is correctly configured for use with cvxpy
###
### @returns True if MOSEK is present and usable
### @returns False if MOSEK cannot be used
###
def check_mosek(): #pragma: no cover
# Create a dummy problem and try solving it using MOSEK
x = cp.Variable(nonneg=True)
problem = cp.Problem(cp.Minimize(x))
try:
problem.solve(solver=cp.MOSEK)
except:
logging.critical('MOSEK does not work. Did you install the license file?', exc_info=True)
return False
return True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment