Sums of squares v (x) = (1, x, x 2 ,y,y 2 , xy ) p is a sum of squares () 9 Q ⌫ 0 with p(x)= hQ, v (x)v (x) T i Q v (x)v (x) T 0 B B B B B B B B @ - 1 x x 2 y y 2 xy 1 q 11 q 12 q 13 q 14 q 15 q 16 x q 21 q 22 q 23 q 24 q 25 q 26 x 2 q 31 q 32 q 33 q 34 q 35 q 36 y q 41 q 42 q 43 q 44 q 45 q 46 y 2 q 51 q 52 q 53 q 54 q 55 q 56 xy q 61 q 62 q 63 q 64 q 65 q 66 1 C C C C C C C C A 0 B B B B B B B B @ - 1 x x 2 y y 2 xy 1 1 x x 2 y y 2 xy x x x 2 x 3 xy xy 2 x 2 y x 2 x 2 x 3 x 4 x 2 y x 2 y 2 x 3 y y y xy x 2 y y 2 y 3 xy 2 y 2 y 2 xy 2 x 2 y 2 y 3 y 4 xy 3 xy xy x 2 y x 3 y xy 2 xy 3 x 2 y 2 1 C C C C C C C C A p(x, y )= x 4 +2x 3 y + x 2 y 2 - 6x 2 y - 6xy 2 + 10x 2 + 10xy +9y 2 - 30y + 25 q 11 = 25 q 23 + q 32 =0 q 25 + q 52 + q 46 + q 64 = -6 Q = X u i u T i = ) p = X (u T i v (x)) 2
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Sums of squares
v(x) = (1, x, x2, y, y
2, xy)
p is a sum of squares () 9 Q ⌫ 0 with p(x) = hQ, v(x)v(x)
Ti
Qv(x)v(x)T
0
BBBBBBBB@
� 1 x x
2y y
2xy
1 q11 q12 q13 q14 q15 q16
x q21 q22 q23 q24 q25 q26
x
2q31 q32 q33 q34 q35 q36
y q41 q42 q43 q44 q45 q46
y
2q51 q52 q53 q54 q55 q56
xy q61 q62 q63 q64 q65 q66
1
CCCCCCCCA
0
BBBBBBBB@
� 1 x x
2y y
2xy
1 1 x x
2y y
2xy
x x x
2x
3xy xy
2x
2y
x
2x
2x
3x
4x
2y x
2y
2x
3y
y y xy x
2y y
2y
3xy
2
y
2y
2xy
2x
2y
2y
3y
4xy
3
xy xy x
2y x
3y xy
2xy
3x
2y
2
1
CCCCCCCCA
p(x, y) = x
4 + 2x3y + x
2y
2 � 6x2y � 6xy2 + 10x2 + 10xy + 9y2 � 30y + 25
q11 = 25
q23 + q32 = 0
q25 + q52 + q46 + q64 = �6
Q =X
uiuTi =) p =
X(uT
i v(x))2
Sparse SDPA format: Setupmaximize hF0, Y i
hFi, Y i = ci for i = 1, . . . , mY ⌫ 0.
minimize c1x1 + · · ·+ cmxm
x1F1 + x2F2 + · · ·+ xmFm � F0 ⇥ 0.
1
2
3 Block 4, a diagonal block
Matrices have a block structure
Sparse SDPA format
maximize hF0, Y ihFi, Y i = ci for i = 1, . . . , mY ⌫ 0.
Text file ‘problem.sdpa’:
Matrix entries: hmatrix number i h block number i h i i h j i h entry i
Remarks: • Indices always start at 1 • Write the size of a block as a negative number to indicate a diagonal block • Only upper-diagonal entries need to be given!
A feasibility problem
p(x) = x
4 + 6x3 + 15x2 � 10x+ 17
F2 =
0
@0 1 01 0 00 0 0
1
AF1 =
0
@1 0 00 0 00 0 0
1
A
F3 =
0
@0 0 10 1 01 0 0
1
A F4 =
0
@0 0 00 0 10 1 0
1
A F5 =
0
@0 0 00 0 00 0 1
1
A
F0 =
0
@0 0 00 0 00 0 0
1
A
maximize hF0, Y ihFi, Y i = ci for i = 1, . . . , 5
Y ⌫ 0.
Is the polynomial
a sum of squares?
c1 = 17, c2 = �10, c3 = 15, c4 = 6, c5 = 1
v(x) = (1, x, x2)
The SDPA file
F2 =
0
@0 1 01 0 00 0 0
1
AF1 =
0
@1 0 00 0 00 0 0
1
A
F3 =
0
@0 0 10 1 01 0 0
1
A F4 =
0
@0 0 00 0 10 1 0
1
A F5 =
0
@0 0 00 0 00 0 1
1
A
F0 =
0
@0 0 00 0 00 0 0
1
A
c1 = 17, c2 = �10, c3 = 15, c4 = 6, c5 = 1
File ‘sos1.sdpa’: 5 ▷ Number of constraint matrices!1 ▷ We have only one block!3 ▷ Which is 3x3!17 -10 15 6 1 ▷ The right-hand side 1 1 1 1 1.0 ▷ Matrix entries!2 1 1 2 1.0 !3 1 1 3 1.0 !3 1 2 2 1.0!4 1 2 3 1.0 !5 1 3 3 1.0
Using CSDP from SAGE• Simple SAGE module to solve problems with CSDP • Allows you to read the solution given by CSDP as SAGE matrices • NO WARRANTY!
Module csdp: Example of use >> import csdp!>> ret = run_csdp(‘problem.sdpa’)!>> ret = run_csdp(‘problem.sdpa’, ‘solution.sol’)!>> ret.primal_value!13.4!>> ret.msg!‘SDP solved’!>> sol = read_csdp_solution(‘solution.sol’, [ 4, 5, -2 ])!>> sol[0]!(Matrix corresponding to block 1)!>> sol[1]!(Matrix corresponding to block 2)!>> sol[2]!(Vector giving diagonal of diagonal block 3)
The MAXCUT SDP in SAGE
max hC,XihEi, Xi = 1 for all i 2 VX ⌫ 0.
Ei is one exactly at (i, i)
Cij =
(w(�(i)) if i = j
�w(ij) if i 6= j
Then: MAXCUT relaxation =
14SDP value
Laplacian matrix
Program
File maxcut.sage: def maxcut_sdp(G, w):! n = G.num_verts()! idx = dict(zip(G.vertices(), range(n)))!! # Cost matrix! C = matrix(RDF, n)! for u, v in G.edge_iterator(labels = False):! i, j = idx[u], idx[v]! C[i, j] = C[j, i] = -w[u, v]!! for u in G:! i = idx[u]! for e in G.edge_iterator(u, labels = False):! C[i, i] += w[e]!! outfile = open('maxcut.sdpa', 'w')!
Program (cont.)File maxcut.sage: def maxcut_sdp(G, w):! (…)! outfile.write('%d\n' % n)! outfile.write('1\n')! outfile.write('%d\n' % n)! outfile.write(n * '1 ' + '\n')!! for i in xrange(n):! outfile.write('%d 1 %d %d 1.0\n' % (i+1, i+1, i+1))!! for i in xrange(C.nrows()):! for j in xrange(i, C.ncols()):! outfile.write('0 1 %d %d %f\n' % (i+1, j+1, C[i,j]))!! outfile.close()!! ret = csdp.run_csdp('maxcut.sdpa')! return ret.primal_value / 4!