# The optimal solution from CVX can not satisfy the constraints

I have such a convex optimization problem:
\begin{aligned} \mathcal{P}_{3}: \min _{\mathbf{X}} &-\log _{2} \operatorname{det}\left(\mathbf{I}_{N_{r}}+\frac{S N R}{N_{r}} \mathbf{A}^{\mathrm{H}}\left(\mathbf{X} \otimes \mathbf{I}_{N_{t}}\right) \mathbf{A}\right) \\ \text { s.t. } & \operatorname{Tr}\left(\mathbf{A}^{\mathrm{H}}\left(\mathbf{X} \otimes \mathbf{I}_{N_{t}}\right) \mathbf{A}\right)-N_{r} N_{t} \leq 0 \\ &-\mathbf{X}_{i, j} \leq 0 \\ & \mathbf{X}=\mathbf{X}^{\mathrm{T}} \end{aligned}
where \mathbf{X} is a positive semipositive matrix. The convexity of the problem is proved which is actually a SDP. When I use CVX, the optimal solution has negative elements so it does not satisfy the second constraint. The cvx_status is ‘Solved’ and the solver I used is Mosek. My cvx code is followed as:
cvx_begin sdp quiet
variable pattern_cov(L,L) symmetric;
minimize -det_rootn(eye(Nr)+snr/min(Nt,Nr)*A(:,:,reali)’*kron(pattern_cov,eye(Nt))*A(:,:,reali));
subject to
pattern_cov>=0;
abs(trace(A(:,:,reali)’*kron(pattern_cov,eye(Nt))A(:,:,reali)))<=NtNr;
abs(trace(A(:,:,reali)’*kron(pattern_cov.’,eye(Nt))A(:,:,reali)))<=NtNr;
pattern_cov==semidefinite(L);
cvx_end
How can I solve this problem?

Negative as in -10^8 or as in -10^{-8}? When you say a constraint is violated you should explain by how much. It may be just numerical noise. You could also post the log output.

Thank you for your advice, Michal. I should have noticed this point. The negative elements is huge from -1 to -10^{3} which can not be ignored.

Remove quiet and paste the full log output.

Also, when you are in sdp mode then pattern_cov>=0; might just mean that it is PSD, and not nonnegative. http://web.cvxr.com/cvx/doc/sdp.html

You are right. The pattern_cov>=0 is the constraint about PSD. The problem can be solved after constrainting the element one by one. Thank you for your help!