Linear matrix Inequality

So I’m trying to convert the following semidefinite problem into cvx code. This is actually the semidefinite relaxation of the boolean least squares problem.

$$min ,,\phi_{sdp} = trace(A^T A X) - 2b^TAx + b^Tb $$

$$s.t.$$

$$\begin{bmatrix}
X & x \
x^T & 1
\end{bmatrix}
\succeq0 \ $$

$$X_{ii} = 1, i=1, 2, …, n$$
Note that the first constraint is equivalent to $$ X \succeq xx^T $$

Here’s the code I have

A=randn(10)
b=randn(10,1)+1
cvx_begin
    variable X_sdp(10,10) symmetric
    variables x(10,1)
    minimize (trace(A'*A*X_sdp) - 2*b'*A*x + b'*b)
    subject to
        for i=1:10,
            X_sdp(i, i) == 1
        end
        X_sdp - x*x'  == semidefinite(10)
cvx_end

The error I’m running into is

"Only scalar quadratic forms can be specified in CVX".

which I think refers to the line of the last constraint.

Change

X_sdp - x*x'  == semidefinite(10)

to

[X_sdp x;x' 1] == semidefinite(11)

Then it will run.

That’s right. I’m curious why the author even felt the need to do the conversion, the model was right in its original form.

Mark’s right below. But I should add, instead of that for loop, just do diag(X_sdp)==1.