I am trying to solve the following semi-definite program using Picos package. In fact, this is a SDP relaxation for solving the maxcut problem for the case of 3 subgraphs.
import picos as pic
maxcut = pic.Problem()
Y=maxcut.add_variable('Y',(47,47),'symmetric')
WW = 2/3*nx.adjacency_matrix(G).todense()
for i in range(47):
for j in range(i+1,47):
WW[i,j]=0
W=pic.new_param('W',WW)
maxcut.add_constraint(Y>>0)
maxcut.add_constraint(pic.tools.diag_vect(Y)==1)
maxcut.add_list_of_constraints([Y[i]> -0.5 for i in range(47*47)])
maxcut.set_objective('max',W|(1-Y))
print (maxcut)
maxcut.solve(verbose = 0)
print ('bound from the SDP relaxation: {0}'.format(maxcut.obj_value()))
I get the following output:
---------------------
optimization problem (SDP):
1128 variables, 2256 affine constraints, 1128 vars in 1 SD cones
Y : (47, 47), symmetric
maximize 〈 W | -Y + |1| 〉
such that
Y ≽ |0|
diag(Y) = |1|
[2209 constraints (first: Y[0] > -0.5)]
---------------------
bound from the SDP relaxation: 41.67318021477081
The issue is that although I require that Y is positive semidefinite maxcut.add_constraint(Y>>0)
, when I check its eigenvalues, not all of them turn out to be nonnegative.
When I remove the constraint of ones on the diagonal (maxcut.add_constraint(pic.tools.diag_vect(Y)==1)
, this issue is solved. However, I do need this constraint.
If you could suggest what is wrong with my code, it would be great... Thank you in advance!