Hi, I am trying to use cvx instead of Yalmip for solving my LMI problem. I have my opt problem formulated in yalmip as follows:
X = sdpvar(n,n);
L = sdpvar(1,n,'full' );
mat = [X [A*X - B*L;L;X]';[A*X - B*L;L;X] blkdiag(X,inv(R),inv(Qx))]
optimize(mat >= 0, -trace(X))
K_f = value(L)*inv(value(X))
However, when I code it in cvx the K_cvx obtained is not the same as K_f.
cvx_begin
variable X(n,n)
variable L(1,n)
minimize (-trace(X))
subject to
[X [A*X-B*L ; L; X]';[A*X-B*L ; L; X] blkdiag(X,inv(R),inv(Qx))] >= 0
cvx_end
K_cvx = L*inv(X)
The code is quite simple, so I guess they are equivalent, but there is something wrong. Do you have any hints?
Presuming inv(R) and inv(Qx) are symmetric, the constraint in YALMIP is an LMI (SDP).
However, you have specified an elementwise nonnegativity constraint in CVX.
-
Square matrix variables in YALMIP are symmetric by default. They are not in CVX.
FIx: variable X(n,n) symmetric
-
YALMIP is essentially always in what is called sdp mode in CVX. But CVX by default is not.:
FIx: cvx_begin sdp
or instead of sdp mode, use
LHS == semidefinite(matrix dimension being constrained)
Please read http://cvxr.com/cvx/doc/sdp.html .
Thank you Mark, I haven’t paid attention about these details.
one more thing: Assume I want to find a sequence of X and L (so to solve finite horizon problems and find K(k) over k in 0,…N-1, where N is my time horizon). Are iterations supported in cvx?
I’m not sure exactly what your model is, but you can declare 3D arrays in which the first two dimensions are symmetric.
variable X(n,n,N) symmetric
declares that X(:,:,k) is symmetric for each value of k.
Then use constraints or expression assignments to capture (constrain) the evolution over time.