I study the noise source identification.
recently， l meet the problem that l defined d as a nonnegative vector ，but the solution was always nonpositive.just like this:

the B is an hermitian_semidefinite matrix.My goal is to make sum(d） positive and maximum,with constrain B is maintaining the positive semidefinite.
Think you in advance!

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.

but it is too small to eliminate the elements of diag(B).

I read in Pal, formed B, then executed

N=49;
cvx_begin
variable d(N)
d >=1e-8
B - diag(d,0) == hermitian_semidefinite(N)
maximize(sum(d))
cvx_solver sdpt3
cvx_end

Result is
cvx_optval = +3.28872e-07, min(d) = 6.711493410820829e-09.

Using SeDuMi, cvx_optval =: +3.91062e-09, min(d) = 7.861089211967724e-11.

So this is as I predicted in my first post.
Note that you need to pay attention to Status returned by CVX. When I used d >= 1e-6, Status was Inaccurate/Solved for both SDPT3 and SeDuMi.

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.