Writing down a feasibility semidefinite program in DSDP or CSDP

50 Views Asked by At

I am trying to solve a simple semidefinite programming problem (following this post):

$$\begin{array}{ll} \text{minimize} & 0\\ \text{subject to} & \mathrm X \mathbb 1 = \mathrm b\\ & \mathrm X \succeq \mathrm O\end{array}$$

I am using R, either package Rdsdp or Rcsdp using corresponding libraries DSDP and CSDP, and have trouble formulating the problem. In particular, both commands expect X to be in block-diagonal form, and has a K parameter, that specifies

  • s: A vector of integers listing the dimension of positive semidefinite cone blocks.
  • l: A scaler integer indicating the dimension of the linear nonnegative cone block.

I am not sure how to relate my problem to the block-diagonal form of X (and hence C and A), and how to specify this K. So far, for a $3\times3$ matrix, I wrote:

  • C: matrix of 0, 1 row and 6 cols, 6 representing unique elements in the $3\times3$ original matrix.
  • A: matrix of ones or zeros, 3 rows and 6 cols. First row selects the first three elements of x: $[1,1,1,0,0,0]$.

My code is:

library(Rdsdp)

b <- c(7.0, 6.5, 5.5) # the contraint, only vector I am sure about
C=matrix(0,1,15)
A=matrix(c(c(1,1,1,0,0,0),
           c(0,1,0,1,1,0),
           c(0, 0, 1, 0,1, 1)),
         nrow=3, ncol=6,byrow=TRUE)
K <-  list(s=c(1,2), l=3) # me random guessing

result_mat = dsdp(A,b,C,K)

round(result_mat$X,3)
#> [1]        3.036        2.147        1.816        2.181        2.171
#> [6]        0.756        0.756 49945388.956

Created on 2019-10-31 by the reprex package (v0.3.0)