I am trying to solve a linear objective with an LMI. However, the objective function involved the summation of variables (I use a loop for this). Following is my objective function (Also included as a picture)
\begin{align}
& \min _{\substack{\theta \in \Theta \\ \lambda_i \geq 0 \\ \gamma_i}} \sum_{i} C_{\theta}( \hat{x_i},\hat{u_i}) + \frac{1}{2} \gamma_i + \langle L, \lambda_i \rangle \\
& \textbf{s.t. } \begin{bmatrix} \theta_{uu} & v_i \\ v_i^T & \gamma_i \end{bmatrix} \succ 0
\end{align}
When I run my optimization code, Yalmip does not return the optimal value of theta_xu and theta_uu. I say this because I put another value of these variables (satisfying all the constraints) in the loss function (objective function), and obtain an even lower loss. What could be going wrong? Is there an issue if I use a loop to construct an objective function? I am using mosek as the solver. Following is the code for reference:
theta_uu = sdpvar(2,2,'symmetric');
theta_xu = sdpvar(6,2);
lambda = sdpvar(n,size(M,1));
gamma = sdpvar(n,1);
ops = sdpsettings('verbose',0);
obj = 0;
cnst = [];
for i=1:n
obj= obj + 2*x0(i,:) * theta_xu * uOpt(i,:)' + uOpt(i,:) * theta_uu * Opt(i,:)';
obj = obj + 0.5*gamma(i) + lambda(i,:)*L;
cnst = [cnst, [theta_uu M'*lambda(i,:)'+theta_xu'*x0(i,:)'; (M'*lambda(i,:)'+theta_xu'*x0(i,:)')' gamma(i)] >= 0];
end
cnst = [cnst, theta_uu >= eye(2),lambda(:,:) >= 0];
cnst = [cnst, theta_xu(:,:) <= 100, theta_xu(:,:) >= -100, theta_uu(:,:) >= -100,theta_uu(:,:) <= 100; ];
optimize(cnst,obj,ops);