when i use the SDPT3, my problem can be correctly solved. but when i use SeDuMI as the solver, it can’t solve the problem (final result is ‘NaN’)and give an error message:
Status: Error
Optimal value (cvx_optval): NaN
Reference to non-existent field 'r0'.
Error in cvx_sedumi>solve (line 258)
tol = info.r0;
Error in cvxprob/solve (line 422)
[ x, status, tprec, iters, y ] = shim.solve( At, b, c, cones,
quiet, prec, solv.settings, eargs{:} );
Error in cvx_end (line 87)
solve( prob );
Error in nlos_miti_toa_sdp_m_receivers (line 174)
cvx_end;
The source code:
% clear;close all;
tic timestart=tic
%Parameters definition %observation times (OR observation times in one estimation) N=1; %repeat times for MSE calculation L=1; % noise VARIANCE = sqrt( var(x) ) VARIANCE=.01; %Fixed target position x_target=[-0.6 -0.3 0 0.3 0.6]; y_target=[-0.6 -0.3 0 0.3 0.6]; %anchor position anchor_posi=[1 1.414 1 0 -1 -1.414 -1 0 %x1 x2 x3 x4 1 0 -1 -1.414 -1 0 1 1.414]; %y1 y2 y3 y4 % anchor_posi=[1 2 1 2 -1 -2 -1 -2 %x1 x2 x3 x4 % 1 2 -1 -2 -1 2 1 2]; %y1 y2 y3 y4 % number of anchors M=length(anchor_posi(1,:)); %maximal nlos error. NLOS_MAX_RANGE = VARIANCE*20;
figure plot(-1,1, 'k');hold on;plot( -1,-1,'k');plot( 1,1,'k');plot(1,-1,'k') plot(1.414,0, 'k');plot( 0,-1.414,'k');plot(-1.414,0,'k');plot(0,1.414,'k') legend 'target position' grid on; for i=1:5 for j=1:5 plot(x_target(i), x_target(j),'r');hold on; index=(i-1)5+j; s=num2str(index); text(x_target(i)+0.05, x_target(j),s) end end
v=zeros(8,1); u=zeros(8,1); d1_observe = zeros(1,N); d2_observe = zeros(1,N); d3_observe = zeros(1,N); d4_observe = zeros(1,N); d5_observe = zeros(1,N); d6_observe = zeros(1,N); d7_observe = zeros(1,N); d8_observe = zeros(1,N);
mse_final_L=[]; %repeat for L times to calculate the MSE for l=1:L mse_final = [ ];
% input generation
%all kinds of conbination of NLOS for 8 receivers
mm=random('unif',0,1,[20,8]);% 'unif' UNIFORM distribution; 'exp' or 'Exponential'; 'norm' or 'Normal';
gain_tmp=[0 0 0 0 0 0 0 0 %1 0 1-25
1 0 0 0 0 0 0 0 %2 1 26-50
1 1 0 0 0 0 0 0 %3 2 51-175
1 0 1 0 0 0 0 0 %4
1 0 0 1 0 0 0 0 %5
1 0 0 0 1 0 0 0 %6
1 0 0 0 0 1 0 0 %7
1 1 1 0 0 0 0 0 %8 3 176-275
1 1 0 1 0 0 0 0 %9
1 1 0 0 1 0 0 0 %10
1 1 0 0 0 1 0 0 %11
1 1 1 1 0 0 0 0 %12 4 276-350
1 1 1 0 1 0 0 0 %13
1 1 1 0 0 1 0 0 %14
1 1 1 1 1 0 0 0 %15 5 351-400
1 1 1 1 0 1 0 0 %16
1 1 1 1 1 1 0 0 %17 6 401-450
1 1 1 1 1 0 1 0 %18
1 1 1 1 1 1 1 0 %19 7 451-475
1 1 1 1 1 1 1 1 %20 8 476-500
];
gain = gain_tmp.*mm;
[m,n]=size(gain);
comb_c=[];
index_c=[];
comb_c_final=[];
index_c_final=[];
%for different combinations of NLOS
for comb=1:m
% repeat for 5x5=25 different target positions estimation
for t_x=1:5
for t_y=1:5
% N times of observations, should be iid, white nosie
d1_observe = ((anchor_posi(1,1)-x_target(t_x))^2 + (anchor_posi(2,1)-y_target(t_y))^2)^0.5 + VARIANCE.*randn(N,1)+NLOS_MAX_RANGE*gain(comb,1);
d2_observe = ((anchor_posi(1,2)-x_target(t_x))^2 + (anchor_posi(2,2)-y_target(t_y))^2)^0.5 + VARIANCE.*randn(N,1)+NLOS_MAX_RANGE*gain(comb,2);
d3_observe = ((anchor_posi(1,3)-x_target(t_x))^2 + (anchor_posi(2,3)-y_target(t_y))^2)^0.5 + VARIANCE.*randn(N,1)+NLOS_MAX_RANGE*gain(comb,3);
d4_observe = ((anchor_posi(1,4)-x_target(t_x))^2 + (anchor_posi(2,4)-y_target(t_y))^2)^0.5 + VARIANCE.*randn(N,1)+NLOS_MAX_RANGE*gain(comb,4);
d5_observe = ((anchor_posi(1,5)-x_target(t_x))^2 + (anchor_posi(2,5)-y_target(t_y))^2)^0.5 + VARIANCE.*randn(N,1)+NLOS_MAX_RANGE*gain(comb,5);
d6_observe = ((anchor_posi(1,6)-x_target(t_x))^2 + (anchor_posi(2,6)-y_target(t_y))^2)^0.5 + VARIANCE.*randn(N,1)+NLOS_MAX_RANGE*gain(comb,6);
d7_observe = ((anchor_posi(1,7)-x_target(t_x))^2 + (anchor_posi(2,7)-y_target(t_y))^2)^0.5 + VARIANCE.*randn(N,1)+NLOS_MAX_RANGE*gain(comb,7);
d8_observe = ((anchor_posi(1,8)-x_target(t_x))^2 + (anchor_posi(2,8)-y_target(t_y))^2)^0.5 + VARIANCE.*randn(N,1)+NLOS_MAX_RANGE*gain(comb,8);
%%%%%%%%%%%%%%%%%%%%%%%%%% cvx %%%%%%%%%%%%%%%%%%%%%%%%%%%
v=[1 1 1 1 1 1 1 1];
alf=.1;
u=[0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2];
cvx_begin sdp %quiet
cvx_solver sedumi
variable x(2,1)
variable c(8,1)
variable z
variable h(8,1)
minimize v(1)*(d1_observe^2-h(1)-c(1))^2+alf*c(1)^2...
+v(2)*(d2_observe^2-h(2)-c(2))^2+alf*c(2)^2...
+v(3)*(d3_observe^2-h(3)-c(3))^2+alf*c(3)^2...
+v(4)*(d4_observe^2-h(4)-c(4))^2+alf*c(4)^2...
+v(5)*(d5_observe^2-h(5)-c(5))^2+alf*c(5)^2...
+v(6)*(d6_observe^2-h(6)-c(6))^2+alf*c(6)^2...
+v(7)*(d7_observe^2-h(7)-c(7))^2+alf*c(7)^2...
+v(8)*(d8_observe^2-h(8)-c(8))^2+alf*c(8)^2;
subject to
h(1)==[anchor_posi(1,1) anchor_posi(2,1) -1]*[ 1 0 x(1);0 1 x(2);x(1) x(2) z]*[anchor_posi(1,1); anchor_posi(2,1);-1];
h(2)==[anchor_posi(1,2) anchor_posi(2,2) -1]*[ 1 0 x(1);0 1 x(2);x(1) x(2) z]*[anchor_posi(1,2); anchor_posi(2,2);-1];
h(3)==[anchor_posi(1,3) anchor_posi(2,3) -1]*[ 1 0 x(1);0 1 x(2);x(1) x(2) z]*[anchor_posi(1,3); anchor_posi(2,3);-1];
h(4)==[anchor_posi(1,4) anchor_posi(2,4) -1]*[ 1 0 x(1);0 1 x(2);x(1) x(2) z]*[anchor_posi(1,4); anchor_posi(2,4);-1];
h(5)==[anchor_posi(1,5) anchor_posi(2,5) -1]*[ 1 0 x(1);0 1 x(2);x(1) x(2) z]*[anchor_posi(1,5); anchor_posi(2,5);-1];
h(6)==[anchor_posi(1,6) anchor_posi(2,6) -1]*[ 1 0 x(1);0 1 x(2);x(1) x(2) z]*[anchor_posi(1,6); anchor_posi(2,6);-1];
h(7)==[anchor_posi(1,7) anchor_posi(2,7) -1]*[ 1 0 x(1);0 1 x(2);x(1) x(2) z]*[anchor_posi(1,7); anchor_posi(2,7);-1];
h(8)==[anchor_posi(1,8) anchor_posi(2,8) -1]*[ 1 0 x(1);0 1 x(2);x(1) x(2) z]*[anchor_posi(1,8); anchor_posi(2,8);-1];
[1 0 anchor_posi(1,1)-x(1);0 1 anchor_posi(2,1)-x(2);anchor_posi(1,1)-x(1) anchor_posi(2,1)-x(2) d1_observe^2+u(1)]>=0;
[1 0 anchor_posi(1,2)-x(1);0 1 anchor_posi(2,2)-x(2);anchor_posi(1,2)-x(1) anchor_posi(2,2)-x(2) d2_observe^2+u(2)]>=0;
[1 0 anchor_posi(1,3)-x(1);0 1 anchor_posi(2,3)-x(2);anchor_posi(1,3)-x(1) anchor_posi(2,3)-x(2) d3_observe^2+u(3)]>=0;
[1 0 anchor_posi(1,4)-x(1);0 1 anchor_posi(2,4)-x(2);anchor_posi(1,4)-x(1) anchor_posi(2,4)-x(2) d4_observe^2+u(4)]>=0;
[1 0 anchor_posi(1,5)-x(1);0 1 anchor_posi(2,5)-x(2);anchor_posi(1,5)-x(1) anchor_posi(2,5)-x(2) d5_observe^2+u(5)]>=0;
[1 0 anchor_posi(1,6)-x(1);0 1 anchor_posi(2,6)-x(2);anchor_posi(1,6)-x(1) anchor_posi(2,6)-x(2) d6_observe^2+u(6)]>=0;
[1 0 anchor_posi(1,7)-x(1);0 1 anchor_posi(2,7)-x(2);anchor_posi(1,7)-x(1) anchor_posi(2,7)-x(2) d7_observe^2+u(7)]>=0;
[1 0 anchor_posi(1,8)-x(1);0 1 anchor_posi(2,8)-x(2);anchor_posi(1,8)-x(1) anchor_posi(2,8)-x(2) d8_observe^2+u(8)]>=0;
[1 0 x(1);0 1 x(2);x(1) x(2) z]>=0;
c(1)>=0;
c(2)>=0;
c(3)>=0;
c(4)>=0;
c(5)>=0;
c(6)>=0;
c(7)>=0;
c(8)>=0;
cvx_end;
%%%%%%%%%%%%%%%%%%%%%%%%%% end cvx %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x_estimated=x(1);y_estimated=x(2);
%final MSE calculation mse(real position, estimated position)
mse_tmp = ((x_estimated - x_target(t_x))^2 + (y_estimated - y_target(t_y))^2)^0.5;
mse_final = [mse_final mse_tmp];
end
end
end
mse_final_L=[mse_final_L;mse_final];
end timestop = toc
mse_final_L_f=sum(mse_final_L)/L;
figure plot(mse_final_L_f,'-.bo'); legend ('mse final'); xlabel 'target index'; ylabel 'MSE'; title 'MSE'