代码:
from cvxopt import solvers, matrix
P=matrix([[2,1],[1,2]])
q=matrix([2,1])
G=matrix([[-1,0],[0,-1]])
h=matrix([1,1])
A=matrix([1,1],(1,2))
b=matrix(1)
solvers.options['show_progress'] = False
sol = solvers.qp(P,q,G,h,A,b)
运行之后出现的错误:
修改数据的输入形式:
from cvxopt import solvers, matrix
P=matrix([[2.,1.],[1.,2.]])
q=matrix([2.,1.])
G=matrix([[-1.,0.],[0.,-1.]])
h=matrix([1.,1.])
A=matrix([1.,1.],(1,2))
b=matrix(1.)
solvers.options['show_progress'] = False
sol = solvers.qp(P,q,G,h,A,b)
问题解决。