|
@@ -1,34 +1,88 @@
|
|
|
-function [X, X_theo, W, F_theo, Omega_G, Omega_F, Phi_G, Phi_F, Ginit, Finit] = data_gen(s_width, s_length, run, N_Ref, N_Cpt, Mu_beta, Mu_alpha, Bound_beta, Bound_alpha, MV, RV, var_n)
|
|
|
+function [X, X_theo, W, F_theo, Omega_G, Omega_F, Phi_G, Phi_F, Ginit, Finit] = data_gen(config, run)
|
|
|
|
|
|
rng(run+1306) % Random seed
|
|
|
|
|
|
+s_width = config.sceneWidth;
|
|
|
+s_length = config.sceneLength;
|
|
|
+N_Ref = config.numRef;
|
|
|
+N_Cpt = config.numSensor;
|
|
|
+N_sousCpt = config.numSubSensor;
|
|
|
+Bound_phen = config.Bound_phen;
|
|
|
+Mu_beta = config.Mu_beta;
|
|
|
+Mu_alpha = config.Mu_alpha;
|
|
|
+Bound_beta = config.Bound_beta;
|
|
|
+Bound_alpha = config.Bound_alpha;
|
|
|
+gamma = config.gamma;
|
|
|
+MV = config.mvR;
|
|
|
+RV = config.rdvR;
|
|
|
+var_n = config.var_n;
|
|
|
+
|
|
|
%% Scene simulation
|
|
|
|
|
|
-phenLowerBound = 0.05;
|
|
|
-phenUpperBound = 0.15;
|
|
|
n_pic = 15;
|
|
|
s_n = s_width*s_length; % Total number of areas in the scene
|
|
|
[xx,yy] = meshgrid((-1:2/(s_width-1):1),(-1:2/(s_length-1):1));
|
|
|
xxyy = cat(2,xx(:),yy(:));
|
|
|
-
|
|
|
-g = zeros(1,s_n);
|
|
|
-for pic = 1:n_pic
|
|
|
- mu = 2*(rand(1,2)-0.5);
|
|
|
- sig = diag([ phenLowerBound + (phenUpperBound - phenLowerBound)*abs(randn()+0.5) , phenLowerBound + (phenUpperBound - phenLowerBound)*abs(randn()+0.5) ]);
|
|
|
- g = g + mvnpdf(xxyy,mu,sig);
|
|
|
+G_theo = ones(s_n,1);
|
|
|
+for sensor = 1:N_sousCpt
|
|
|
+ g = zeros(s_n,1);
|
|
|
+ for pic = 1:n_pic
|
|
|
+ mu = 2*(rand(1,2)-0.5);
|
|
|
+ sig = diag([ Bound_phen((sensor-1)*2+1) + (Bound_phen((sensor-1)*2+2) - Bound_phen((sensor-1)*2+1))*abs(randn()+0.5) , ...
|
|
|
+ Bound_phen((sensor-1)*2+1) + (Bound_phen((sensor-1)*2+2) - Bound_phen((sensor-1)*2+1))*abs(randn()+0.5) ]);
|
|
|
+ g = g + mvnpdf(xxyy,mu,sig);
|
|
|
+ end
|
|
|
+ g = (Bound_phen((sensor-1)*2+2) - Bound_phen((sensor-1)*2+1))/(max(g)-min(g))*(g-min(g)) + Bound_phen((sensor-1)*2+1);
|
|
|
+ % .5*(g/max(g))+1e-5
|
|
|
+ G_theo = cat(2, G_theo, g);
|
|
|
end
|
|
|
|
|
|
-g = g-min(g);
|
|
|
-g = .5*(g/max(g))+1e-5;
|
|
|
-G_theo = [ones(s_n,1),g]; % Theoretical matrix G (see eq.(3) of [1])
|
|
|
-
|
|
|
|
|
|
%% Sensors simulation
|
|
|
|
|
|
-F_theo = [max(Bound_beta(1),min(Bound_beta(2),Mu_beta+.5*randn(1,N_Cpt)));...
|
|
|
- max(Bound_alpha(1),min(Bound_alpha(2),Mu_alpha+.5*randn(1,N_Cpt)))];
|
|
|
-F_theo = [F_theo,[0;1]]; % Theoretical matrix F (see eq.(3) of [1])
|
|
|
+F_theo = zeros(N_sousCpt+1, N_sousCpt*(N_Cpt+1));
|
|
|
+
|
|
|
+for sensor = 1:N_sousCpt
|
|
|
+ F_theo(1,(sensor-1)*(N_Cpt+1)+1:sensor*(N_Cpt+1)) = ...
|
|
|
+ cat(2, max(Bound_beta((sensor-1)*2+1), min(Bound_beta((sensor-1)*2+2), ...
|
|
|
+ Mu_beta(sensor)+(Bound_beta((sensor-1)*2+2)-Bound_beta((sensor-1)*2+1))*0.55*randn(1,N_Cpt))), 0);
|
|
|
+end
|
|
|
+
|
|
|
+for sen = 1:N_sousCpt
|
|
|
+ f_theo = cat(2, max(Bound_alpha((sen-1)*2+1),...
|
|
|
+ min( Bound_alpha((sen-1)*2+2), ...
|
|
|
+ Mu_alpha(sen)+(Bound_alpha((sen-1)*2+2)-Bound_alpha((sen-1)*2+1))*0.25*randn(1,N_Cpt))), 1);
|
|
|
+ F_theo(sen+1, (sen-1)*(N_Cpt+1)+1:sen*(N_Cpt+1)) = f_theo;
|
|
|
+
|
|
|
+ C = (1-gamma)/gamma*(F_theo(1,(sen-1)*(N_Cpt+1)+1:sen*(N_Cpt+1)-1)+Bound_phen((sen-1)*2+1)*f_theo(1:end-1));
|
|
|
+ list_nosen = 1:N_sousCpt;
|
|
|
+ list_nosen(sen) = [];
|
|
|
+ maxPhen_nosen = norm(Bound_phen(2*list_nosen));
|
|
|
+ for sor = list_nosen
|
|
|
+ f_theo_nosen = rand(1,N_Cpt).*C/(sqrt(N_sousCpt)*maxPhen_nosen);
|
|
|
+ other_f_theo = cat(2, f_theo_nosen, 0);
|
|
|
+ F_theo(sor+1, (sen-1)*(N_Cpt+1)+1:sen*(N_Cpt+1)) = other_f_theo;
|
|
|
+ end
|
|
|
+end
|
|
|
|
|
|
+% F_theo = [];
|
|
|
+%
|
|
|
+% for sensor = 1:N_sousCpt
|
|
|
+% F_theo = cat(2, F_theo, cat(2, max(Bound_beta(1), min(Bound_beta(2), Mu_beta+.5*randn(1,N_Cpt))), 0));
|
|
|
+% end
|
|
|
+%
|
|
|
+%
|
|
|
+% for sen = 1:N_sousCpt
|
|
|
+% f_theo = [];
|
|
|
+% for sor = 1:N_sousCpt
|
|
|
+% if sen==sor
|
|
|
+% f_theo = cat(2, f_theo, cat(2, max(Bound_alpha(1), min(Bound_alpha(2), Mu_alpha+.5*randn(1,N_Cpt))), sen==sor));
|
|
|
+% else
|
|
|
+% f_theo = cat(2, f_theo, cat(2, 0*max(Bound_alpha(1), min(Bound_alpha(2), Mu_alpha+.5*randn(1,N_Cpt))), sen==sor));
|
|
|
+% end
|
|
|
+% end
|
|
|
+% F_theo = cat(1, F_theo, f_theo);
|
|
|
+% end
|
|
|
|
|
|
%% Data simulation
|
|
|
|
|
@@ -60,8 +114,10 @@ for i = 1 : N_data
|
|
|
W(xx(idx_data(i)),yy(idx_data(i))) = 1; % Sensor measurement placement
|
|
|
end
|
|
|
|
|
|
-N = var_n*randn(s_n,N_Cpt+1); % Noise simulation
|
|
|
-N(:,end) = 0;
|
|
|
+W = repmat(W, 1, N_sousCpt);
|
|
|
+
|
|
|
+N = var_n*randn(s_n,N_sousCpt*(N_Cpt+1)); % Noise simulation
|
|
|
+N(:,(N_Cpt+1)*(1:N_sousCpt)) = 0;
|
|
|
N = max(N,-X_theo);
|
|
|
|
|
|
X = W.*(X_theo+N); % Data matrix X
|
|
@@ -69,15 +125,54 @@ X = W.*(X_theo+N); % Data matrix X
|
|
|
%% Calibration parameters
|
|
|
|
|
|
% % Common parameters
|
|
|
-Omega_G = [ones(s_n,1),W(:,end)]; % Mask on known values in G (see eq.(14) of [1])
|
|
|
-Omega_F = [zeros(2,N_Cpt),[1;1]]; % Mask on known values in F (see eq.(15) of [1])
|
|
|
-Phi_G = [ones(s_n,1),X(:,end)]; % Known values in G (see eq.(14) of [1])
|
|
|
-Phi_F = [zeros(2,N_Cpt),[0;1]]; % Known values in F (see eq.(15) of [1])
|
|
|
-Ginit = abs(randn(s_n,2)+mean(Phi_G(idx_Ref,end))); % Initial matrix G : randn + mean of known ref values
|
|
|
+Omega_G = [ones(s_n,1),W(:,(N_Cpt+1)*(1:N_sousCpt))]; % Mask on known values in G (see eq.(14) of [1])
|
|
|
+Omega_F = zeros(N_sousCpt+1,N_sousCpt*(N_Cpt+1));
|
|
|
+Omega_F(:,(N_Cpt+1)*(1:N_sousCpt)) = 1; % Mask on known values in F (see eq.(15) of [1])
|
|
|
+Phi_G = [ones(s_n,1),X(:,(N_Cpt+1)*(1:N_sousCpt))]; % Known values in G (see eq.(14) of [1])
|
|
|
+Phi_F = F_theo .* Omega_F; % Known values in F (see eq.(15) of [1])
|
|
|
+Ginit = ones(s_n,1);
|
|
|
+for sensor = 1:N_sousCpt
|
|
|
+ g = zeros(s_n,1);
|
|
|
+ for pic = 1:n_pic
|
|
|
+ mu = 2*(rand(1,2)-0.5);
|
|
|
+ sig = diag([ Bound_phen((sensor-1)*2+1) + (Bound_phen((sensor-1)*2+2) - Bound_phen((sensor-1)*2+1))*abs(randn()+0.5) , ...
|
|
|
+ Bound_phen((sensor-1)*2+1) + (Bound_phen((sensor-1)*2+2) - Bound_phen((sensor-1)*2+1))*abs(randn()+0.5) ]);
|
|
|
+ g = g + mvnpdf(xxyy,mu,sig);
|
|
|
+ end
|
|
|
+ g = (Bound_phen((sensor-1)*2+2) - Bound_phen((sensor-1)*2+1))/(max(g)-min(g))*(g-min(g)) + Bound_phen((sensor-1)*2+1);
|
|
|
+ % .5*(g/max(g))+1e-5
|
|
|
+ Ginit = cat(2, Ginit, g);
|
|
|
+end
|
|
|
Ginit = (1-Omega_G).*Ginit+Phi_G;
|
|
|
-Finit = [max(Bound_beta(1),min(Bound_beta(2),Mu_beta+.5*randn(1,N_Cpt)));...
|
|
|
- max(Bound_alpha(1),min(Bound_alpha(2),Mu_alpha+.5*randn(1,N_Cpt)))];
|
|
|
-Finit = [Finit,[0;1]]; % Initial matrix F
|
|
|
-Finit = (1-Omega_F).*Finit+Phi_F;
|
|
|
+% Ginit = G_theo;
|
|
|
+
|
|
|
+Finit = zeros(N_sousCpt+1, N_sousCpt*(N_Cpt+1));
|
|
|
+
|
|
|
+for sensor = 1:N_sousCpt
|
|
|
+ Finit(1,(sensor-1)*(N_Cpt+1)+1:sensor*(N_Cpt+1)) = ...
|
|
|
+ cat(2, max(Bound_beta((sensor-1)*2+1), min(Bound_beta((sensor-1)*2+2), ...
|
|
|
+ Mu_beta(sensor)+(Bound_beta((sensor-1)*2+2)-Bound_beta((sensor-1)*2+1))*0.25*randn(1,N_Cpt))), 0);
|
|
|
+end
|
|
|
+
|
|
|
+for sen = 1:N_sousCpt
|
|
|
+ finit = cat(2, max(Bound_alpha((sen-1)*2+1),...
|
|
|
+ min( Bound_alpha((sen-1)*2+2), ...
|
|
|
+ Mu_alpha(sen)+(Bound_alpha((sen-1)*2+2)-Bound_alpha((sen-1)*2+1))*0.25*randn(1,N_Cpt))), 1);
|
|
|
+ Finit(sen+1, (sen-1)*(N_Cpt+1)+1:sen*(N_Cpt+1)) = finit;
|
|
|
+
|
|
|
+% C = (1-gamma)/gamma*(Finit(1,(sen-1)*(N_Cpt+1)+1:sen*(N_Cpt+1)-1)+Bound_phen((sen-1)*2+1)*finit(1:end-1));
|
|
|
+% list_nosen = 1:N_sousCpt;
|
|
|
+% list_nosen(sen) = [];
|
|
|
+% maxPhen_nosen = norm(Bound_phen(2*list_nosen));
|
|
|
+ for sor = 1:N_sousCpt
|
|
|
+ if sen~=sor
|
|
|
+% finit_nosen = rand(1,N_Cpt).*C/(sqrt(N_sousCpt)*maxPhen_nosen);
|
|
|
+% other_finit = cat(2, finit_nosen, 0);
|
|
|
+% Finit(sor+1, (sen-1)*(N_Cpt+1)+1:sen*(N_Cpt+1)) = other_finit;
|
|
|
+ Finit(sor+1, (sen-1)*(N_Cpt+1)+1:sen*(N_Cpt+1)) = zeros(1,N_Cpt+1);
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
+% Finit = F_theo;
|
|
|
|
|
|
end
|