Salome HOME
Documentation corrections for outputs
[modules/adao.git] / src / daComposant / daAlgorithms / ExtendedBlue.py
index a5d5ec34ee6ac9fd7e9973d960647e38579738b4..ea93f62c7465c34a16a7d8cec7d3ee5bdf9dd396 100644 (file)
@@ -1,6 +1,6 @@
 #-*-coding:iso-8859-1-*-
 #
-#  Copyright (C) 2008-2014 EDF R&D
+#  Copyright (C) 2008-2015 EDF R&D
 #
 #  This library is free software; you can redistribute it and/or
 #  modify it under the terms of the GNU Lesser General Public
@@ -21,8 +21,7 @@
 #  Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
 
 import logging
-from daCore import BasicObjects, PlatformInfo
-m = PlatformInfo.SystemUsage()
+from daCore import BasicObjects
 import numpy
 
 # ==============================================================================
@@ -40,13 +39,15 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             default  = [],
             typecast = tuple,
             message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
-            listval  = ["APosterioriCovariance", "BMA", "OMA", "OMB", "Innovation", "SigmaBck2", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles"]
+            listval  = ["APosterioriCovariance", "BMA", "OMA", "OMB", "CostFunctionJ", "Innovation", "SigmaBck2", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles", "SimulatedObservationAtBackground", "SimulatedObservationAtOptimum"]
             )
         self.defineRequiredParameter(
             name     = "Quantiles",
             default  = [],
             typecast = tuple,
             message  = "Liste des valeurs de quantiles",
+            minval   = 0.,
+            maxval   = 1.,
             )
         self.defineRequiredParameter(
             name     = "SetSeed",
@@ -69,8 +70,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             )
 
     def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
-        logging.debug("%s Lancement"%self._name)
-        logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("M")))
+        self._pre_run()
         #
         # Paramètres de pilotage
         # ----------------------
@@ -128,14 +128,17 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         # Calcul de la fonction coût
         # --------------------------
         if self._parameters["StoreInternalVariables"] or \
-           "OMA" in self._parameters["StoreSupplementaryCalculations"] or \
-           "SigmaObs2" in self._parameters["StoreSupplementaryCalculations"] or \
-           "MahalanobisConsistency" in self._parameters["StoreSupplementaryCalculations"] or \
-           "SimulationQuantiles" in self._parameters["StoreSupplementaryCalculations"]:
+           "CostFunctionJ"                 in self._parameters["StoreSupplementaryCalculations"] or \
+           "OMA"                           in self._parameters["StoreSupplementaryCalculations"] or \
+           "SigmaObs2"                     in self._parameters["StoreSupplementaryCalculations"] or \
+           "MahalanobisConsistency"        in self._parameters["StoreSupplementaryCalculations"] or \
+           "SimulatedObservationAtOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+           "SimulationQuantiles"           in self._parameters["StoreSupplementaryCalculations"]:
             HXa  = numpy.matrix(numpy.ravel( H( Xa ) )).T
             oma = Y - HXa
         if self._parameters["StoreInternalVariables"] or \
-           "MahalanobisConsistency" in self._parameters["StoreSupplementaryCalculations"]:
+           "CostFunctionJ"                 in self._parameters["StoreSupplementaryCalculations"] or \
+           "MahalanobisConsistency"        in self._parameters["StoreSupplementaryCalculations"]:
             Jb  = 0.5 * (Xa - Xb).T * BI * (Xa - Xb)
             Jo  = 0.5 * oma.T * RI * oma
             J   = float( Jb ) + float( Jo )
@@ -205,12 +208,12 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 if YQ is None: YQ = YfQ[:,indice]
                 else:          YQ = numpy.hstack((YQ,YfQ[:,indice]))
             self.StoredVariables["SimulationQuantiles"].store( YQ )
+        if "SimulatedObservationAtBackground" in self._parameters["StoreSupplementaryCalculations"]:
+            self.StoredVariables["SimulatedObservationAtBackground"].store( numpy.ravel(HXb) )
+        if "SimulatedObservationAtOptimum" in self._parameters["StoreSupplementaryCalculations"]:
+            self.StoredVariables["SimulatedObservationAtOptimum"].store( numpy.ravel(HXa) )
         #
-        logging.debug("%s Nombre d'évaluation(s) de l'opérateur d'observation direct/tangent/adjoint.: %i/%i/%i"%(self._name, HO["Direct"].nbcalls(0),HO["Tangent"].nbcalls(0),HO["Adjoint"].nbcalls(0)))
-        logging.debug("%s Nombre d'appels au cache d'opérateur d'observation direct/tangent/adjoint..: %i/%i/%i"%(self._name, HO["Direct"].nbcalls(3),HO["Tangent"].nbcalls(3),HO["Adjoint"].nbcalls(3)))
-        logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("M")))
-        logging.debug("%s Terminé"%self._name)
-        #
+        self._post_run(HO)
         return 0
 
 # ==============================================================================