I am trying to do element-wise multiplication in CVXPY in the objective function. Is this allowed as part of a convex problem?
X
is a n x 1 variable.
V
is a n x n constant.
I want to do the equivalent of np.multiply(X, V*X)
, which returns an n x 1 vector.
In cvxopt you have to write your problem in a more standard way for the type of solver you want to use, whereas cvxpy is supposed to adapt your problem based on the structure you use for your problem (they are supposed to select the type of cvxopt solver depending on your problem and pass the variables in an standard ...
Disciplined convex programming (DCP) is a system for constructing mathematical expressions with known curvature from a given library of base functions. CVXPY uses DCP to ensure that the specified optimization problems are convex. This section of the tutorial explains the rules of DCP and how they are applied by CVXPY.
CVXPY comes with ECOS_BB – an open source mixed-integer nonlinear solver – by default.
The preferred way of creating a NonPos constraint is through operator overloading. To constrain an expression x to be non-positive, simply write x <= 0 ; to constrain x to be non-negative, write x >= 0 . The former creates a NonPos constraint with x as its argument, while the latter creates one with -x as its argument.
I think the function you're 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 function used to be called mul_elemwise
(<1.0), which may have been the source of your confusion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With