python语法错误 'q' must be a 'd' matrix with one column

代码:

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)

运行之后出现的错误:
python语法错误 'q' must be a 'd' matrix with one column
修改数据的输入形式:

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)

问题解决。

上一篇:java.lang.IllegalStateException: Shutdown in progress


下一篇:php exec如何查看进度