ACIN_Cal.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. function [ G , F , R ] = ACIN_Cal( W , X , G , F , Omega_G , Omega_F , Phi_G , Phi_F , Mean_F , mu , 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 Average-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. Omega_Bar_G = ones(size(G))-Omega_G;
  14. Omega_Bar_F = ones(size(F))-Omega_F;
  15. Delta_G = G.*Omega_Bar_G;
  16. Delta_F = F.*Omega_Bar_F;
  17. m = size(F,2)-1;
  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. % updating G
  22. Delta_G = Updt_Delta_G( W2 , X , Delta_G , Phi_G , F , Omega_Bar_G );
  23. G = Phi_G + Delta_G;
  24. % updating F
  25. Delta_F = Updt_Delta_F( W2 , X , G , Delta_F , Phi_F , Omega_Bar_F , Mean_F , mu , m );
  26. F = Phi_F + Delta_F;
  27. R(i+1) = norm(F(2,1:end-1)-F_theo(2,1:end-1),2)/sqrt(size(F_theo,2)-1);
  28. end
  29. end
  30. function [ Delta_F ] = Updt_Delta_F( W , X , G , Delta_F , Phi_F , Omega_B_F , Mean_F , mu , m )
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  32. % Update rule for Delta_F %
  33. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  34. Delta_F = Delta_F.*(Omega_B_F.*(G'*(W.*secu_plus(X-G*Phi_F)))+mu/m*diag(Mean_F)*Omega_B_F)./(Omega_B_F.*(G'*(W.*(G*Delta_F)))+mu/m^2*diag(Delta_F*ones(m+1,1))*Omega_B_F);
  35. Delta_F(isnan(Delta_F))=0;
  36. end
  37. function [ Delta_G ] = Updt_Delta_G( W , X , Delta_G , Phi_G , F , Omega_B_G )
  38. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  39. % Update rule for Delta_G %
  40. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  41. Delta_G = Delta_G.*(Omega_B_G).*((W.*secu_plus(X-Phi_G*F))*F')./((W.*(Delta_G*F)*F')); % mise à jour
  42. Delta_G(isnan(Delta_G))=0;
  43. end
  44. function [toto] = secu_plus(tutu,s)
  45. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  46. % Goal: Security in the NMF procedure which project the negative data to
  47. % epsilon (small user-defined threshold)
  48. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  49. if(nargin<2)
  50. s=1.e-12;
  51. end
  52. toto=max(tutu,s);
  53. toto(isnan(tutu)) = 0;
  54. end