I am trying to optimize using cvxpy.
w=cvxpy.Variable((10,1))
cvxpy.kron(w,w)
this is not working saying that first argument should be constant,
and then I tried to use numpy
numpy.kron(w,w)
and then, it says that incompatible dimensions (10,1) (10,1)
shouldn't it work?? How should I do the kronecker product on it
You shouldn't be using numpy operations on cvxpy Variables. Instead you should be using cvxpy atoms whenever they are available. With numpy you can do the following:
numpy.kron(numpy.ones((10, 1)), numpy.ones((10, 1)))
As for the error, cvxpy is telling you that you cannot use a Variable as the first argument to cvxpy.kron
. For example you can use a numpy array or a cvxpy.Parameter
.
cvxpy.kron(numpy.ones((2, 2)), w)
Results in:
Expression(AFFINE, UNKNOWN, (20, 2))