1 #-*-coding:iso-8859-1-*-
3 # Copyright (C) 2008-2012 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 from daCore import BasicObjects, PlatformInfo
24 m = PlatformInfo.SystemUsage()
26 # ==============================================================================
27 class ElementaryAlgorithm(BasicObjects.Algorithm):
29 BasicObjects.Algorithm.__init__(self, "LINEARLEASTSQUARES")
31 def run(self, Xb=None, Y=None, H=None, M=None, R=None, B=None, Q=None, Parameters=None):
33 Calcul de l'estimateur moindres carrés pondérés linéaires
34 (assimilation variationnelle sans ébauche)
36 logging.debug("%s Lancement"%self._name)
37 logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("Mo")))
39 # Paramètres de pilotage
40 # ----------------------
41 self.setParameters(Parameters)
43 # Opérateur d'observation
44 # -----------------------
45 Hm = H["Tangent"].asMatrix(None)
46 Ha = H["Adjoint"].asMatrix(None)
50 elif self._parameters["R_scalar"] is not None:
51 RI = 1.0 / self._parameters["R_scalar"]
53 raise ValueError("Observation error covariance matrix has to be properly defined!")
55 # Calcul de la matrice de gain et de l'analyse
56 # --------------------------------------------
57 K = (Ha * RI * Hm ).I * Ha * RI
59 logging.debug("%s Analyse Xa = %s"%(self._name, Xa))
61 # Calcul de la fonction coût
62 # --------------------------
65 Jo = 0.5 * d.T * RI * d
66 J = float( Jb ) + float( Jo )
67 logging.debug("%s CostFunction Jb = %s"%(self._name, Jb))
68 logging.debug("%s CostFunction Jo = %s"%(self._name, Jo))
69 logging.debug("%s CostFunction J = %s"%(self._name, J))
71 self.StoredVariables["Analysis"].store( Xa.A1 )
72 self.StoredVariables["Innovation"].store( d.A1 )
73 self.StoredVariables["CostFunctionJb"].store( Jb )
74 self.StoredVariables["CostFunctionJo"].store( Jo )
75 self.StoredVariables["CostFunctionJ" ].store( J )
77 logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("Mo")))
78 logging.debug("%s Terminé"%self._name)
82 # ==============================================================================
83 if __name__ == "__main__":
84 print '\n AUTODIAGNOSTIC \n'