I can’t reproduce what you’ve done because you haven’t provided B.
You haven’t shown us the optimal d returned by CVX. Given that cvx_optval = -4.44932e-9, there must be some at least slightly negative elements in the optimal d. My guess is that they are within solver tolerance of being non-negative. For instance, on a random B I generated, the minimum element of the optimal d = -5.88e-8, which is within solver tolerance of being non-negative.
You could specify a small positive number small_positive_number as the minimum value, such as 1e-6, and then use the constraint d >= small_positive_number
instead of declaring d(N) to be nonnegative.
Then the optimal d should not be negative. Alternatively, you could adjust any slightly negative elements of d to be nonnegative, but then you might make the semidefinite constraint be not quite satisfied.
think you for your help！
“but it is too small to eliminate the elements of diag(B).” means d are unknown positive diagonal elements that l want to use them to cancel the diagonal elements of B,in order to make the diag(B) more small but not nonnegative. Because the diagonal elements of B contains the noise I don’t want.
I may not be clear about the meaning of matrix B.If I solve the problem I will reply to you, thank you again for your help:slight_smile:！
B is a rank one matrix by construction, so all eigenvalues are zero except for one positive eigenvalue… Essentially, your whole optimization is nothing but playing with roundoff error or tolerance. You can not reduce the diagonal of B (while leaving the off-diagonal elements unchanged) without causing it to not be Hermitian semidefinite.
You may need to rethink your model formulation. Burt that is really a modeling question, not a CVX question.