CVXPY - 传递变量和常量
CVXPY - passing both variables and constants
我正在尝试执行以下操作(CVX matlab 代码):
variable x(2)
minimize(norm([x;1]) + 2*max([x;0])
但是当我在 python CVXPY 中尝试这样做时,出现错误:
x = Variable(2)
norm([x, 1])
TypeError: float() argument must be a string or a number, not
'Variable'
from cvxpy import *
x = Variable(2)
prob=Problem(Minimize(norm(hstack([x, 1]))))
prob.solve()
我正在尝试执行以下操作(CVX matlab 代码):
variable x(2)
minimize(norm([x;1]) + 2*max([x;0])
但是当我在 python CVXPY 中尝试这样做时,出现错误:
x = Variable(2)
norm([x, 1])
TypeError: float() argument must be a string or a number, not 'Variable'
from cvxpy import *
x = Variable(2)
prob=Problem(Minimize(norm(hstack([x, 1]))))
prob.solve()