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)
运行之后出现的错误:
修改数据的输入形式:
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)
问题解决。
标签:cvxopt,matrix,语法错误,show,python,sol,column,solvers,progress 来源: https://blog.csdn.net/qq_45669448/article/details/104702653