/
cvxopt.py
37 lines (26 loc) · 941 Bytes
/
cvxopt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
""" CVXOPT module
:Author: Jonathan Karr <jonrkarr@gmail.com>
:Date: 2017-11-22
:Copyright: 2017, Karr Lab
:License: MIT
"""
from .cvxpy import CvxpyModel
from ..core import VariableType, ConvOptError
import cvxpy
class CvxoptModel(CvxpyModel):
""" CVXOPT solver """
SOLVER = cvxpy.CVXOPT
def load(self, conv_opt_model):
""" Load a model to CVXPY's data structure
Args:
conv_opt_model (:obj:`cvxpy.Problem`): model
Returns:
:obj:`dict`: the model in CVXPY's data structure
Raises:
:obj:`ConvOptError`: if a variable has an unsupported type
"""
solver_model = super(CvxoptModel, self).load(conv_opt_model)
for variable in conv_opt_model.variables:
if variable.type != VariableType.continuous:
raise ConvOptError('Unsupported variable of type "{}"'.format(variable.type))
return solver_model