-1

I'm trying to do the following (CVX matlab code):

variable x(2)
minimize(norm([x;1]) + 2*max([x;0])

But when I try to this in python CVXPY, I get an error:

x = Variable(2)
norm([x, 1])

TypeError: float() argument must be a string or a number, not 'Variable'

Maverick Meerkat
  • 5,737
  • 3
  • 47
  • 66

1 Answers1

1
from cvxpy import *
x = Variable(2)
prob=Problem(Minimize(norm(hstack([x, 1]))))
prob.solve()
Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39