Suppose my constraint is the product of the first column and third column of the matrix variable is greater than one. How can I implement in CVXPY? Example:
w = Variable(4,3)
In Matlab, my constraint would be:
w(:,1)'*w(:,3)>1
How can I implement it in CVXPY? Or can we perform dot product under CVXPY? numpy.dot
is not supported by CVXPY.
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.
You can change the solver called by CVXPY using the solver keyword argument. If the solver you choose cannot solve the problem, CVXPY will raise an exception. Here's example code solving the same problem with different solvers.
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 ...
CVXPY relies on the open source solvers OSQP, SCS, and ECOS. Additional solvers are supported, but must be installed separately.
If both variables are positive then the set {x * y > 1}
is actually convex, while the function x*y
is neither convex nor concave. This can be checked by looking at eigenvalues of matrix of second derivatives
(x*y)'' =
[[0, 1],
[1, 0]]
which are {-1, 1}
. The matrix is not positive-definite and is not negative-definite.
Sometimes you can transform a problem so that it becomes convex. In this case this is possible by taking a logarithm of both sides:
log(x) + log(y) >= 0
this is a valid restriction because both log(x) and log(y) are concave functions and the inequality is greater-than-or-equal. This constraint will pass the "disciplined convex programming" rules. Good luck.
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