I try to solve a SDP, the result shows that the solution is feasible and optimal, but when I substitute the obtained solution back into the constraints, I find it violates many constraints.
using JuMP, MosekTools, LinearAlgebra, Random
Random.seed!(20);
n = 3
Q = rand(-50:50,n,n)
c = rand(-50:50,n)
l = zeros(n)
u = ones(n)
SemiDP = Model(with_optimizer(Mosek.Optimizer))
@variable(SemiDP, X[1:n,1:n])
@variable(SemiDP, x[1:n])
@objective(SemiDP, Min, dot(Q,X)+c'*x)
@constraint(SemiDP, x*u'-X .>= 0)
@constraint(SemiDP, X.>=0)
@SDconstraint(SemiDP, [1 x'; x X]>=0)
optimize!(SemiDP)
println(primal_status(SemiDP))
println("termination_status:", termination_status(SemiDP))
It shows the solution is optimal and primal feasible, but when I substitute the solution into the constraints:
value.(x)*u'-value.(X) .>= 0
eigvals([1 value.(x)'; value.(x) value.(X)]) #to see if the matrix is Semidefinite
I find it violates many constraints, e.g. some bool values are 0, and some eigenvalues are negative. Could anybody give some ideas on how the problem comes?