Elementary multiplication in CVXPY

I am trying to do elemental multiplication in CVXPY in an objective function. Is this resolved as part of the convex problem?

X - variable nx 1. V - constant nx n.

I want to do the equivalent of np.multiply (X, V * X) that returns a vector nx 1.

+3


source to share


1 answer


I think the function you are looking for is cvx.multiply

For example:



In [1]: import cvxpy as cvx

In [2]: n = 10

In [3]: X = cvx.Variable((n, 1))

In [4]: V = cvx.Variable((n, n))

In [5]: cvx.multiply(X, V*X)
Out[5]: Expression(UNKNOWN, UNKNOWN, (10, 1))

      

In the 1.0 update notes they mention that this feature was called mul_elemwise

(<1.0), which may have been the source of your confusion.

0


source







All Articles