clear all
close all
clc
Length = 20;
Width = 20;
Sensor_Number = 5;
sigma = 0.4;
rho_gang = 2;
rho = ones(1,Sensor_Number).*7;
node_location = [10,10];
node_x = zeros(Sensor_Number,1);
node_y = zeros(Sensor_Number,1);
d = zeros(Sensor_Number,1);
d_realy = zeros(Sensor_Number,1);
for i = 1:Sensor_Number
node_x(i) = randLength;
node_y(i) = randWidth;
end
for i = 1:Sensor_Number
d_realy(i) = sqrt((node_location(1)-node_x(i))^2+(node_location(2)-node_y(i))^2);
if i == 2 && i == 4
d(i) = sqrt((node_location(1)-node_x(i))^2+(node_location(2)-node_y(i))^2)+sqrt(sigma)*randn;
else
d(i) = sqrt((node_location(1)-node_x(i))^2+(node_location(2)-node_y(i))^2)+sqrt(sigma)randn+7rand;
end
end
Q = diag(repmat(sigma^2,Sensor_Number,1));
B = [eye(Sensor_Number),ones(Sensor_Number,1)];
cvx_begin
variables tau x(2) e_gang lambda r
variable G(6,6) symmetric
minimize tau
subject to
for i = 1:Sensor_Number
g(i) = norm(x-[node_x(i);node_y(i)]);
end
g(Sensor_Number+1) = e_gang;
%% (10d)
0 <= g(Sensor_Number+1) <= rho_gang;
%% G 13 10a
for i = 1 : Sensor_Number
G(i,i) == r - 2*[node_x(i);node_y(i)]‘x + (norm(([node_x(i);node_y(i)])))^2; % (10a)
for j = 1 : Sensor_Number
if i > j
G(i,j) >= abs(r-([node_x(i);node_y(i)]+[node_x(j);node_y(j)])‘x +[node_x(i);node_y(i)]’[node_x(j);node_y(j)]);
end
end
end
%% (10e)
0 <= G(Sensor_Number+1,Sensor_Number+1) <= rho_gang^2;
%% (12a)
G == semidefinite(6);
[[G,g’];[g,1]] == semidefinite(7);
%% (8)
q = trace(B’inv(Q)BG)-2d’inv(Q)Bg’+d’inv(Q)d;
lambda[[eye(Sensor_Number),rho_gangones(Sensor_Number,1)-rho’/2];[(rho_gangones(Sensor_Number,1)-rho’/2)’,Sensor_Numberrho_gang^2-2rho_gang(sum(rho’/2))]]-…
[[inv(Q),inv(Q)(Bg’-d)];[(Bg’-d)'inv(Q),q-tau]] == semidefinite(6)
% (12b)
[[eye(2),x];[x’,r]] == semidefinite(3);
% 14
H = [-2([node_x,node_y]),ones(Sensor_Number,1)];
for i = 1 : Sensor_Number
f (i) = d(i)^2 - (norm([node_x(i),node_y(i)]))^2;
end
H[x’,r]’ <= f’;
cvx_end