Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an inequality constraint on the inner product of two columns in CVXPY?

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.

like image 769
Creator Avatar asked Mar 16 '17 02:03

Creator


People also ask

How to write constraints in 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.

How to change solver in CVXPY?

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.

What is the difference between Cvxpy and Cvxopt?

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 ...

What solver does Cvxpy use?

CVXPY relies on the open source solvers OSQP, SCS, and ECOS. Additional solvers are supported, but must be installed separately.


1 Answers

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.

like image 61
Sergey Dovgal Avatar answered Sep 17 '22 04:09

Sergey Dovgal