data_gen.m 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. 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)
  2. rng(run+1306) % Random seed
  3. %% Scene simulation
  4. phenLowerBound = 0.05;
  5. phenUpperBound = 0.15;
  6. n_pic = 15;
  7. s_n = s_width*s_length; % Total number of areas in the scene
  8. [xx,yy] = meshgrid((-1:2/(s_width-1):1),(-1:2/(s_length-1):1));
  9. xxyy = cat(2,xx(:),yy(:));
  10. g = zeros(1,s_n);
  11. for pic = 1:n_pic
  12. mu = 2*(rand(1,2)-0.5);
  13. sig = diag([ phenLowerBound + (phenUpperBound - phenLowerBound)*abs(randn()+0.5) , phenLowerBound + (phenUpperBound - phenLowerBound)*abs(randn()+0.5) ]);
  14. g = g + mvnpdf(xxyy,mu,sig);
  15. end
  16. g = g-min(g);
  17. g = .5*(g/max(g))+1e-5;
  18. G_theo = [ones(s_n,1),g]; % Theoretical matrix G (see eq.(3) of [1])
  19. %% Sensors simulation
  20. F_theo = [max(Bound_beta(1),min(Bound_beta(2),Mu_beta+.5*randn(1,N_Cpt)));...
  21. max(Bound_alpha(1),min(Bound_alpha(2),Mu_alpha+.5*randn(1,N_Cpt)))];
  22. F_theo = [F_theo,[0;1]]; % Theoretical matrix F (see eq.(3) of [1])
  23. %% Data simulation
  24. X_theo = G_theo*F_theo; % Theoretical matrix X (see eq.(2) of [1])
  25. W = zeros(s_n,N_Cpt+1);
  26. idx_Ref = randperm(s_n);
  27. idx_Ref = idx_Ref(1:N_Ref); % Reference measurement locations
  28. W(idx_Ref,end) = 1;
  29. N_RV = round(N_Cpt*RV); % Nb. of sensors having a RendezVous
  30. idx_CptRV = randperm(N_Cpt);
  31. idx_CptRV = idx_CptRV(1:N_RV); % Selection of sensors having a RendezVous
  32. idx_RefRV = randi(N_Ref,1,N_Cpt);
  33. idx_RefRV = idx_Ref(idx_RefRV(1:N_RV)); % Selection of the references for each RendezVous
  34. for i = 1 : N_RV
  35. W(idx_RefRV(i),idx_CptRV(i)) = 1;
  36. end
  37. N_data = round((1-MV)*(N_Cpt)*(s_n-N_Ref)); % Nb. of measurements in data matrix X
  38. xCpt = 1 : s_n;
  39. xCpt(idx_Ref) = []; % Reference free locations
  40. [xx,yy] = meshgrid(xCpt,1:N_Cpt); % Possibly sensed locations
  41. idx_data = randperm((s_n-N_Ref)*N_Cpt);
  42. for i = 1 : N_data
  43. W(xx(idx_data(i)),yy(idx_data(i))) = 1; % Sensor measurement placement
  44. end
  45. N = var_n*randn(s_n,N_Cpt+1); % Noise simulation
  46. N(:,end) = 0;
  47. N = max(N,-X_theo);
  48. X = W.*(X_theo+N); % Data matrix X
  49. %% Calibration parameters
  50. % % Common parameters
  51. Omega_G = [ones(s_n,1),W(:,end)]; % Mask on known values in G (see eq.(14) of [1])
  52. Omega_F = [zeros(2,N_Cpt),[1;1]]; % Mask on known values in F (see eq.(15) of [1])
  53. Phi_G = [ones(s_n,1),X(:,end)]; % Known values in G (see eq.(14) of [1])
  54. Phi_F = [zeros(2,N_Cpt),[0;1]]; % Known values in F (see eq.(15) of [1])
  55. Ginit = abs(randn(s_n,2)+mean(Phi_G(idx_Ref,end))); % Initial matrix G : randn + mean of known ref values
  56. Ginit = (1-Omega_G).*Ginit+Phi_G;
  57. Finit = [max(Bound_beta(1),min(Bound_beta(2),Mu_beta+.5*randn(1,N_Cpt)));...
  58. max(Bound_alpha(1),min(Bound_alpha(2),Mu_alpha+.5*randn(1,N_Cpt)))];
  59. Finit = [Finit,[0;1]]; % Initial matrix F
  60. Finit = (1-Omega_F).*Finit+Phi_F;
  61. end