SpIN_Cal.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function [ G , F , R ] = SpIN_Cal( W , X , G , F , Omega_G , Omega_F , Phi_G , Phi_F , D , k , lambda , F_theo , N_iter )
  2. % Author: Clément DORFFER
  3. % Date: 26/11/2018
  4. % @: clement.dorffer@ensta-bretagne.fr
  5. % Goal: perform mobile sensor calibration using the Sparsity-Constrained Informed NMF calibraton technique.
  6. % If you use this code for research or educational purpose, please cite:
  7. %
  8. % C. Dorffer, M. Puigt, G. Delmaire, G. Roussel, Informed Nonnegative Matrix Factorization Methods for
  9. % Mobile Sensor Network Calibration, IEEE Transactions on Signal and Information Processing over Networks,
  10. % Volume 4, Issue 4, pp. 667-682, December 2018.
  11. %
  12. W2 = W.^2;
  13. tilde_W2 = [W2,lambda*ones(size(W,1),1)];
  14. Omega_Bar_G = ones(size(G))-Omega_G;
  15. Omega_Bar_F = ones(size(F))-Omega_F;
  16. Delta_G = G.*Omega_Bar_G;
  17. Delta_F = F.*Omega_Bar_F;
  18. R = zeros(N_iter+1,1);
  19. R(1) = norm(F(2,1:end-1)-F_theo(2,1:end-1),2)/sqrt(size(F_theo,2)-1);
  20. for i = 1 : N_iter
  21. x = OMP(G(:,2),D,k);
  22. tilde_X = [X,D*x];
  23. tilde_F = [F,[0;1]];
  24. % updating G
  25. Delta_G = Updt_Delta_G( tilde_W2 , tilde_X , Delta_G , Phi_G , tilde_F , Omega_Bar_G );
  26. G = Phi_G + Delta_G;
  27. % updating F
  28. Delta_F = Updt_Delta_F( W2 , X , G , Delta_F , Phi_F , Omega_Bar_F );
  29. F = Phi_F + Delta_F;
  30. R(i+1) = norm(F(2,1:end-1)-F_theo(2,1:end-1),2)/sqrt(size(F_theo,2)-1);
  31. end
  32. end
  33. function [ Delta_F ] = Updt_Delta_F( W , X , G , Delta_F , Phi_F , Omega_B_F )
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  35. % Update rule for Delta_F %
  36. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  37. Delta_F = Delta_F.*(Omega_B_F).*((G'*(W.*secu_plus(X-G*Phi_F)))./(G'*(W.*(G*Delta_F))));
  38. Delta_F(isnan(Delta_F))=0;
  39. end
  40. function [ Delta_G ] = Updt_Delta_G( W , X , Delta_G , Phi_G , F , Omega_B_G )
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  42. % Update rule for Delta_G %
  43. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  44. Delta_G = Delta_G.*(Omega_B_G).*((W.*secu_plus(X-Phi_G*F))*F')./((W.*(Delta_G*F)*F')); % mise à jour
  45. Delta_G(isnan(Delta_G))=0;
  46. end
  47. function [toto] = secu_plus(tutu,s)
  48. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  49. % Goal: Security in the NMF procedure which project the negative data to
  50. % epsilon (small user-defined threshold
  51. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  52. if(nargin<2)
  53. s=1.e-12;
  54. end
  55. toto=max(tutu,s);
  56. toto(isnan(tutu)) = 0;
  57. end