I'm trying to incorporate a norm in cvxpy of an array that includes a constant and a cvxpy variable. Looking at something like:
import cvxpy as cp t = cp.Variable(pos=True) arr = [1,t] obj = cp.norm(arr)
throws the following error:
Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cvxpy/atoms/norm.py", line 47, in norm x = Expression.cast_to_const(x) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cvxpy/expressions/expression.py", line 446, in cast_to_const return expr if isinstance(expr, Expression) else cvxtypes.constant()(expr) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cvxpy/expressions/constants/constant.py", line 44, in init self._value = intf.DEFAULT_INTF.const_to_matrix(value) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cvxpy/interface/numpy_interface/ndarray_interface.py", line 50, in const_to_matrix return result.astype(numpy.float64) ValueError: setting an array element with a sequence.
I realize I'm probably missing something obvious here, like cp.norm requires a cp.Variable object as input. However, cvxpy doesn't recognize a function of the form obj = cp.sqrt(1+cp.square(t)) as convex, even though it is a norm of <1,t>. Any ideas of how to get this through without being rejected?