# Could anyone tell me how to handle this constraints?

Here is my problem to be solve:
\underset{\gamma, z, X}{\text{inf}}\,\, \gamma c +z\\ \,\,\,\,\,\text{s.t.} \,\, \gamma\geq 0\\ \,\,\,\,\,\begin{bmatrix} \gamma I-X & \gamma v \\ (\gamma v)^T & z \\ \end{bmatrix} \succeq 0\\ \,\,\,\,\,X_{ij} = 1 ,\,\, \text{for}\,\, i ==j\\ \,\,\,\,\,X_{ij} <0 ,\,\, \text{for}\,\, i \neq j

c,v are constant value and vector. \gamma, z, X are decision variables and decision matrix. X is a symetric matrix. When I try to use cvx to solve this question, I encounter the following problem. The objective function and first two constraints are simple to handle in cvx. However, how can I handle the last two constraints in cvx？That is , in cvx, how should I handle the matrix diagnal and off-diagnal constraints (X_{ij} = 1 ,\,\, \text{for}\,\, i ==j,X_{ij} <0 ,\,\, \text{for}\,\, i \neq j)?

diag(X) == 1
X - diag(diag(X)) <= 0


Change the 0 to s small positive number, such as 1e-6 if you need the inequality to be strict.

This is elegant, efficient, vectorized code. But you could accomplish the same thing by “brute force” use of double (nested) for loops