1 #-*-coding:iso-8859-1-*-
3 # Copyright (C) 2008-2011 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)
30 self._name = "LINEARLEASTSQUARES"
32 def run(self, Xb=None, Y=None, H=None, M=None, R=None, B=None, Q=None, Parameters=None):
34 Calcul de l'estimateur moindres carrés pondérés linéaires
35 (assimilation variationnelle sans ébauche)
37 logging.debug("%s Lancement"%self._name)
38 logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("Mo")))
40 Hm = H["Direct"].asMatrix()
41 Ht = H["Adjoint"].asMatrix()
45 elif Parameters["R_scalar"] is not None:
46 RI = 1.0 / Parameters["R_scalar"]
48 K = (Ht * RI * Hm ).I * Ht * RI
50 logging.debug("%s Analyse Xa = %s"%(self._name, Xa))
52 # Calcul de la fonction coût
53 # --------------------------
56 Jo = 0.5 * d.T * RI * d
57 J = float( Jb ) + float( Jo )
58 logging.debug("%s CostFunction Jb = %s"%(self._name, Jb))
59 logging.debug("%s CostFunction Jo = %s"%(self._name, Jo))
60 logging.debug("%s CostFunction J = %s"%(self._name, J))
62 self.StoredVariables["Analysis"].store( Xa.A1 )
63 self.StoredVariables["Innovation"].store( d.A1 )
64 self.StoredVariables["CostFunctionJb"].store( Jb )
65 self.StoredVariables["CostFunctionJo"].store( Jo )
66 self.StoredVariables["CostFunctionJ" ].store( J )
68 logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("Mo")))
69 logging.debug("%s Terminé"%self._name)
73 # ==============================================================================
74 if __name__ == "__main__":
75 print '\n AUTODIAGNOSTIC \n'