I’m going to take a stab at answering your question. It’s not entirely clear what you want to solve, but it seems like \lambda is your variable, and you want to solve something like
I can’t actually parse the rest of your problem (if you update it, or ask a follow-on, I might be able to give you some more help).
Anyway, it turns out that you can write your CVX code like the math (assuming your P matrices are stored in a cell array):
cvx_begin
variable lambda(n)
maximize gamma + lambda'*r
subject to
constr = P{0} % this *has* to be a single equals (an assignment)
for i = 1:n
constr = constr + P{i}*lambda(i)
end
constr == semidefinite(n) % this *has* to be a double equals (a set constraint)
cvx_end
Hope that gives you some idea about how to do this! Feel free to ask for clarification.
Update: Now that I see your problem, I can write the CVX code for you.
cvx_begin
variables lambda(m) gamma
maximize ( gamma + lambda'*r + r0 )
% this will form the upper left part of the matrix
% (it's important that these are single equals)
X11 = P0;
for i = 1:m,
X11 = X11 + lambda(i)*P(:,:,i);
end
% this will form the upper right
X12 = q0;
for i = 1:m,
X12 = X12 + lambda(i)*q(:,i);
end
X12 = (1/2)*X12;
% lower left is the same as upper right
% finally, the constraints
[X11 X12; X12 -gamma] == semidefinite( % you have to figure out the dimensions )
lambda >= 0
cvx_end
To get a better understanding of why we use the assignment “=” instead of the equality “==”, you might want to read up on expressions in CVX (section 3.8 of the user guide).