Thank you very much. Yes, you are right. I forgot to put the abs() function. Actually, the code works without the abs() function in the fourth constraint. If we put absolute function as follows:
Z(5,6) <= abs(trace(Z(1:2,3:4))-theta(1:2)’*Xtdot(:,1)-theta(3:4)’*Xt(:,1)+Xtdot(:,1)’*Xt(:,1));
then the error will appear.
I tried to compact my code in this post. However, the complete code is as follows that can be run entirely. Please just consider the optimization section, i.e., “CVX Solver” and “YILMAP solver”, of the code and ignore the first part. As you can see, I also tried to solve with YALMIP, but it does not work!
I also trest your suggestion:
- When I removed precision of the CVX, it can not solve!
- When I define the U as an expression instead of variable, it become infeasible!
Thank you for your help.
%% Test code
clear
close all
format long
warning off
%% CVX Solver
G = [A’*A , -A’*b ; -b’A , b’b];
cvx_clear
% cvx_solver sedumi
% cvx_solver mosek
% cvx_solver sdpt3
cvx_begin SDP quiet
cvx_precision best
variables theta(8,1) U(9,9)
variable Z(8,8) symmetric
minimize (trace(GU));
subject to
diag(Z) >= 0; Z(5,6) >= 0;
Z(5,5) == trace(Z(1:2,1:2))-2theta(1:2)‘Xt(:,1)+norm(Xt(:,1))^2;
Z(6,6) == trace(Z(1:2,1:2))-2theta(1:2)‘Xr(:,1)+norm(Xr(:,1))^2;
Z(7,7) <= abs(trace(Z(3:4,3:4))-2theta(3:4)‘Xtdot(:,1)+norm(Xtdot(:,1))^2);
Z(8,8) <= abs(trace(Z(3:4,3:4))-2theta(3:4)’*Xrdot(:,1)+norm(Xrdot(:,1))^2);
Z(5,7) <= abs(trace(Z(1:2,3:4))-theta(1:2)’*Xtdot(:,1)-theta(3:4)’*Xt(:,1)+Xtdot(:,1)’*Xt(:,1));
Z(6,8) <= abs(trace(Z(1:2,3:4))-theta(1:2)’*Xrdot(:,1)-theta(3:4)’*Xr(:,1)+Xrdot(:,1)‘Xr(:,1));
Z(5,6) >= abs(trace(Z(1:2,1:2))-theta(1:2)’(Xt(:,1)+Xr(:,1))+Xt(:,1)’*Xr(:,1));
Z(5,8) <= abs(trace(Z(1:2,3:4))-theta(1:2)’*Xrdot(:,1)-theta(3:4)’*Xt(:,1)+Xt(:,1)’*Xrdot(:,1));
Z(6,7) <= abs(trace(Z(1:2,3:4))-theta(1:2)’*Xtdot(:,1)-theta(3:4)’*Xr(:,1)+Xr(:,1)‘Xtdot(:,1));
Z(7,8) <= abs(trace(Z(3:4,3:4))-theta(3:4)’(Xtdot(:,1)+Xrdot(:,1))+Xtdot(:,1)’*Xrdot(:,1));
U == [Z , theta ; theta' , 1];
U == semidefinite(9);
cvx_end
cvx_status
% cvx_solver
Xhat_SDP = theta(1:2);
Xhatdot_SDP = theta(3:4);
%% YALMIP Solver
yalmip(‘clear’)
% Define Variables
theta1 = sdpvar(8,1);
U1 = sdpvar(9,9,‘symmetric’);
Z1 = sdpvar(8,8,‘symmetric’);
% Define Constraints
% my_tolerance_for_strict = 1e-5;
Constraints = [U1>=0 , U1 == [Z1 , theta1 ; theta1’ , 1] , …
diag(Z1) >= 0 , Z1(5,6) >= 0 , …
Z1(5,5) == trace(Z1(1:2,1:2))-2*theta1(1:2)‘Xt(:,1)+norm(Xt(:,1))^2, …
Z1(6,6) == trace(Z1(1:2,1:2))-2theta1(1:2)‘Xr(:,1)+norm(Xr(:,1))^2, …
Z1(7,7) <= trace(Z1(3:4,3:4))-2theta1(3:4)‘Xtdot(:,1)+norm(Xtdot(:,1))^2, …
Z1(8,8) <= trace(Z1(3:4,3:4))-2theta1(3:4)’*Xrdot(:,1)+norm(Xrdot(:,1))^2, …
Z1(5,7) <= trace(Z1(1:2,3:4))-theta1(1:2)’*Xtdot(:,1)-theta1(3:4)’*Xt(:,1)+Xtdot(:,1)’*Xt(:,1), …
Z1(6,8) <= trace(Z1(1:2,3:4))-theta1(1:2)’*Xrdot(:,1)-theta1(3:4)’*Xr(:,1)+Xrdot(:,1)‘Xr(:,1), …
Z1(5,6) >= trace(Z1(1:2,1:2))-theta1(1:2)’(Xt(:,1)+Xr(:,1))+Xt(:,1)’*Xr(:,1), …
Z1(5,8) <= trace(Z1(1:2,3:4))-theta1(1:2)’*Xrdot(:,1)-theta1(3:4)’*Xt(:,1)+Xt(:,1)’*Xrdot(:,1), …
Z1(6,7) <= trace(Z1(1:2,3:4))-theta1(1:2)’*Xtdot(:,1)-theta1(3:4)’*Xr(:,1)+Xr(:,1)‘Xtdot(:,1), …
Z1(7,8) <= trace(Z1(3:4,3:4))-theta1(3:4)’(Xtdot(:,1)+Xrdot(:,1))+Xtdot(:,1)’*Xrdot(:,1)]
Objective = trace(G*U1);
sol = optimize(Constraints,Objective);