]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Improvement of conditional variables output for filters
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Sun, 24 Mar 2019 13:57:44 +0000 (14:57 +0100)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Sun, 24 Mar 2019 13:57:44 +0000 (14:57 +0100)
src/daComposant/daAlgorithms/EnsembleKalmanFilter.py
src/daComposant/daAlgorithms/ExtendedKalmanFilter.py
src/daComposant/daAlgorithms/KalmanFilter.py
src/daComposant/daAlgorithms/UnscentedKalmanFilter.py

index 8563d693ab0fd62a5ee0906c504fffa7d2c3d2d4..4a8449347d98003b7547a00be987bb6635419091 100644 (file)
@@ -60,16 +60,25 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             typecast = tuple,
             message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
             listval  = [
+                "Analysis",
                 "APosterioriCorrelations",
                 "APosterioriCovariance",
                 "APosterioriStandardDeviations",
                 "APosterioriVariances",
                 "BMA",
                 "CostFunctionJ",
+                "CostFunctionJAtCurrentOptimum",
                 "CostFunctionJb",
+                "CostFunctionJbAtCurrentOptimum",
                 "CostFunctionJo",
+                "CostFunctionJoAtCurrentOptimum",
+                "CurrentOptimum",
                 "CurrentState",
-                "Innovation",
+                "IndexOfOptimum",
+                "InnovationAtCurrentState",
+                "PredictedState",
+                "SimulatedObservationAtCurrentOptimum",
+                "SimulatedObservationAtCurrentState",
                 ]
             )
         self.requireInputArguments(
@@ -106,11 +115,11 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         #
         # Précalcul des inversions de B et R
         # ----------------------------------
-        if self._parameters["StoreInternalVariables"] or \
-            self._toStore("CostFunctionJ") or \
-            self._toStore("CostFunctionJb") or \
-            self._toStore("CostFunctionJo") or \
-            self._toStore("APosterioriCovariance"):
+        if self._parameters["StoreInternalVariables"] \
+            or self._toStore("CostFunctionJ") \
+            or self._toStore("CostFunctionJb") \
+            or self._toStore("CostFunctionJo") \
+            or self._toStore("APosterioriCovariance"):
             BI = B.getI()
             RI = R.getI()
         BIdemi = B.choleskyI()
@@ -188,33 +197,65 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             #
             for i in range(__m):
                 Xn[:,i] = Xn_predicted[:,i] + K * (Yo[:,i] - HX_predicted[:,i])
+            del Yo, PfHT, HPfHT
             #
             Xa = Xn.mean(axis=1, dtype=mfp)
-            self.StoredVariables["Analysis"].store( Xa )
             #
-            del Yo, PfHT, HPfHT
-            if self._parameters["StoreInternalVariables"] or \
-                self._toStore("CostFunctionJ") or \
-                self._toStore("CostFunctionJb") or \
-                self._toStore("CostFunctionJo") or \
-                self._toStore("APosterioriCovariance") or \
-                self._toStore("Innovation"):
-                d = Ynpu - numpy.asmatrix(numpy.ravel( H((Xa, Un)) )).T
-                self.StoredVariables["Innovation"].store( d )
             if self._parameters["StoreInternalVariables"] \
-                or self._toStore("CurrentState"):
-                self.StoredVariables["CurrentState"].store( Xn )
-            if self._parameters["StoreInternalVariables"] or \
-                self._toStore("CostFunctionJ") or \
-                self._toStore("CostFunctionJb") or \
-                self._toStore("CostFunctionJo") or \
-                self._toStore("APosterioriCovariance"):
-                Jb  = 0.5 * (Xa - Xb).T * BI * (Xa - Xb)
-                Jo  = 0.5 * d.T * RI * d
-                J   = float( Jb ) + float( Jo )
+                or self._toStore("CostFunctionJ") \
+                or self._toStore("CostFunctionJb") \
+                or self._toStore("CostFunctionJo") \
+                or self._toStore("APosterioriCovariance") \
+                or self._toStore("InnovationAtCurrentState") \
+                or self._toStore("SimulatedObservationAtCurrentState") \
+                or self._toStore("SimulatedObservationAtCurrentOptimum"):
+                _HX          = numpy.asmatrix(numpy.ravel( H((Xa, Un)) )).T
+                _Innovation = Ynpu - _HX
+            #
+            self.StoredVariables["Analysis"].store( Xa )
+            if self._parameters["StoreInternalVariables"] \
+                or self._toStore("CurrentState") \
+                or self._toStore("CurrentOptimum"):
+                self.StoredVariables["CurrentState"].store( Xa )
+            if self._toStore("BMA"):
+                self.StoredVariables["BMA"].store( Xn_predicted - Xa )
+            if self._toStore("InnovationAtCurrentState"):
+                self.StoredVariables["InnovationAtCurrentState"].store( _Innovation )
+            if self._toStore("SimulatedObservationAtCurrentState") \
+                or self._toStore("SimulatedObservationAtCurrentOptimum"):
+                self.StoredVariables["SimulatedObservationAtCurrentState"].store( _HX )
+            if self._parameters["StoreInternalVariables"] \
+                or self._toStore("CostFunctionJ") \
+                or self._toStore("CostFunctionJb") \
+                or self._toStore("CostFunctionJo") \
+                or self._toStore("CurrentOptimum") \
+                or self._toStore("APosterioriCovariance"):
+                Jb  = float( 0.5 * (Xa - Xb).T * BI * (Xa - Xb) )
+                Jo  = float( 0.5 * _Innovation.T * RI * _Innovation )
+                J   = Jb + Jo
                 self.StoredVariables["CostFunctionJb"].store( Jb )
                 self.StoredVariables["CostFunctionJo"].store( Jo )
                 self.StoredVariables["CostFunctionJ" ].store( J )
+                #
+                if self._toStore("IndexOfOptimum") \
+                    or self._toStore("CurrentOptimum") \
+                    or self._toStore("CostFunctionJAtCurrentOptimum") \
+                    or self._toStore("CostFunctionJbAtCurrentOptimum") \
+                    or self._toStore("CostFunctionJoAtCurrentOptimum") \
+                    or self._toStore("SimulatedObservationAtCurrentOptimum"):
+                    IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps
+                if self._toStore("IndexOfOptimum"):
+                    self.StoredVariables["IndexOfOptimum"].store( IndexMin )
+                if self._toStore("CurrentOptimum"):
+                    self.StoredVariables["CurrentOptimum"].store( self.StoredVariables["CurrentState"][IndexMin] )
+                if self._toStore("SimulatedObservationAtCurrentOptimum"):
+                    self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( self.StoredVariables["SimulatedObservationAtCurrentState"][IndexMin] )
+                if self._toStore("CostFunctionJbAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] )
+                if self._toStore("CostFunctionJoAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] )
+                if self._toStore("CostFunctionJAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
             if self._toStore("APosterioriCovariance"):
                 Ht = HO["Tangent"].asMatrix(ValueForMethodForm = Xa)
                 Ht = Ht.reshape(__p,__n) # ADAO & check shape
@@ -224,20 +265,20 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 Pf = (1./(__m-1)) * Pf
                 Pn = (1. - K * Ht) * Pf
                 self.StoredVariables["APosterioriCovariance"].store( Pn )
-                if J < previousJMinimum:
+                if self._parameters["EstimationOf"] == "Parameters" \
+                    and J < previousJMinimum:
                     previousJMinimum  = J
-                    Xa                = Xn
-                    covarianceXa      = Pn
+                    # Inutile ici : Xa = Xa
+                    covarianceXa = Pn
         #
-        # Stockage supplementaire de l'optimum en estimation de parametres
-        # ----------------------------------------------------------------
+        # Stockage final supplémentaire de l'optimum en estimation de paramètres
+        # ----------------------------------------------------------------------
         if self._parameters["EstimationOf"] == "Parameters":
             self.StoredVariables["Analysis"].store( Xa.A1 )
             if self._toStore("APosterioriCovariance"):
                 self.StoredVariables["APosterioriCovariance"].store( covarianceXa )
-        #
-        if self._toStore("BMA"):
-            self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
+            if self._toStore("BMA"):
+                self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
         #
         self._post_run(HO)
         return 0
index 6454610d44b825054d4ff2c1c07350a27314e482..5670a6bd74c83b49c3cace59f316199eb5e24ebe 100644 (file)
@@ -54,17 +54,25 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             typecast = tuple,
             message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
             listval  = [
+                "Analysis",
                 "APosterioriCorrelations",
                 "APosterioriCovariance",
                 "APosterioriStandardDeviations",
                 "APosterioriVariances",
                 "BMA",
-                "CurrentState",
                 "CostFunctionJ",
+                "CostFunctionJAtCurrentOptimum",
                 "CostFunctionJb",
+                "CostFunctionJbAtCurrentOptimum",
                 "CostFunctionJo",
-                "Innovation",
+                "CostFunctionJoAtCurrentOptimum",
+                "CurrentOptimum",
+                "CurrentState",
+                "IndexOfOptimum",
+                "InnovationAtCurrentState",
                 "PredictedState",
+                "SimulatedObservationAtCurrentOptimum",
+                "SimulatedObservationAtCurrentState",
                 ]
             )
         self.defineRequiredParameter( # Pas de type
@@ -72,7 +80,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             message  = "Liste des valeurs de bornes",
             )
         self.requireInputArguments(
-            mandatory= ("Xb", "Y", "HO", "R", "B" ),
+            mandatory= ("Xb", "Y", "HO", "R", "B"),
             optional = ("U", "EM", "CM", "Q"),
             )
 
@@ -106,7 +114,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         if self._parameters["StoreInternalVariables"] \
             or self._toStore("CostFunctionJ") \
             or self._toStore("CostFunctionJb") \
-            or self._toStore("CostFunctionJo"):
+            or self._toStore("CostFunctionJo") \
+            or self._toStore("CurrentOptimum") \
+            or self._toStore("APosterioriCovariance"):
             BI = B.getI()
             RI = R.getI()
         #
@@ -165,57 +175,82 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 Xn_predicted = numpy.min(numpy.hstack((Xn_predicted,numpy.asmatrix(self._parameters["Bounds"])[:,1])),axis=1)
             #
             if self._parameters["EstimationOf"] == "State":
-                d  = Ynpu - numpy.asmatrix(numpy.ravel( Hm( (Xn_predicted, None) ) )).T
+                _HX          = numpy.asmatrix(numpy.ravel( Hm( (Xn_predicted, None) ) )).T
+                _Innovation  = Ynpu - _HX
             elif self._parameters["EstimationOf"] == "Parameters":
-                d  = Ynpu - numpy.asmatrix(numpy.ravel( Hm( (Xn_predicted, Un) ) )).T
+                _HX          = numpy.asmatrix(numpy.ravel( Hm( (Xn_predicted, Un) ) )).T
+                _Innovation  = Ynpu - _HX
                 if Cm is not None and Un is not None: # Attention : si Cm est aussi dans H, doublon !
-                    d = d - Cm * Un
+                    _Innovation = _Innovation - Cm * Un
             #
             _A = R + numpy.dot(Ht, Pn_predicted * Ha)
-            _u = numpy.linalg.solve( _A , d )
+            _u = numpy.linalg.solve( _A , _Innovation )
             Xn = Xn_predicted + Pn_predicted * Ha * _u
             Kn = Pn_predicted * Ha * (R + numpy.dot(Ht, Pn_predicted * Ha)).I
             Pn = Pn_predicted - Kn * Ht * Pn_predicted
             #
-            self.StoredVariables["Analysis"].store( Xn.A1 )
-            if self._toStore("APosterioriCovariance"):
-                self.StoredVariables["APosterioriCovariance"].store( Pn )
-            if self._toStore("Innovation"):
-                self.StoredVariables["Innovation"].store( numpy.ravel( d.A1 ) )
+            self.StoredVariables["Analysis"].store( Xn )
             if self._parameters["StoreInternalVariables"] \
-                or self._toStore("CurrentState"):
+                or self._toStore("CurrentState") \
+                or self._toStore("CurrentOptimum"):
                 self.StoredVariables["CurrentState"].store( Xn )
-            if self._parameters["StoreInternalVariables"] \
-                or self._toStore("PredictedState"):
+            if self._toStore("PredictedState"):
                 self.StoredVariables["PredictedState"].store( Xn_predicted )
+            if self._toStore("BMA"):
+                self.StoredVariables["BMA"].store( Xn_predicted - Xn )
+            if self._toStore("InnovationAtCurrentState"):
+                self.StoredVariables["InnovationAtCurrentState"].store( _Innovation )
+            if self._toStore("SimulatedObservationAtCurrentState") \
+                or self._toStore("SimulatedObservationAtCurrentOptimum"):
+                self.StoredVariables["SimulatedObservationAtCurrentState"].store( _HX )
             if self._parameters["StoreInternalVariables"] \
                 or self._toStore("CostFunctionJ") \
                 or self._toStore("CostFunctionJb") \
-                or self._toStore("CostFunctionJo"):
-                Jb  = 0.5 * (Xn - Xb).T * BI * (Xn - Xb)
-                Jo  = 0.5 * d.T * RI * d
-                J   = float( Jb ) + float( Jo )
+                or self._toStore("CostFunctionJo") \
+                or self._toStore("CurrentOptimum") \
+                or self._toStore("APosterioriCovariance"):
+                Jb  = float( 0.5 * (Xn - Xb).T * BI * (Xn - Xb) )
+                Jo  = float( 0.5 * _Innovation.T * RI * _Innovation )
+                J   = Jb + Jo
                 self.StoredVariables["CostFunctionJb"].store( Jb )
                 self.StoredVariables["CostFunctionJo"].store( Jo )
                 self.StoredVariables["CostFunctionJ" ].store( J )
-                if J < previousJMinimum:
+                if self._parameters["EstimationOf"] == "Parameters" \
+                    and J < previousJMinimum:
                     previousJMinimum  = J
                     Xa                = Xn
-                    if self._toStore("APosterioriCovariance"):
-                        covarianceXa  = Pn
-            else:
-                Xa = Xn
-            #
+                    if self._toStore("APosterioriCovariance"): covarianceXa = Pn
+                #
+                if self._toStore("IndexOfOptimum") \
+                    or self._toStore("CurrentOptimum") \
+                    or self._toStore("CostFunctionJAtCurrentOptimum") \
+                    or self._toStore("CostFunctionJbAtCurrentOptimum") \
+                    or self._toStore("CostFunctionJoAtCurrentOptimum") \
+                    or self._toStore("SimulatedObservationAtCurrentOptimum"):
+                    IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps
+                if self._toStore("IndexOfOptimum"):
+                    self.StoredVariables["IndexOfOptimum"].store( IndexMin )
+                if self._toStore("CurrentOptimum"):
+                    self.StoredVariables["CurrentOptimum"].store( self.StoredVariables["CurrentState"][IndexMin] )
+                if self._toStore("SimulatedObservationAtCurrentOptimum"):
+                    self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( self.StoredVariables["SimulatedObservationAtCurrentState"][IndexMin] )
+                if self._toStore("CostFunctionJbAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] )
+                if self._toStore("CostFunctionJoAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] )
+                if self._toStore("CostFunctionJAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
+            if self._toStore("APosterioriCovariance"):
+                self.StoredVariables["APosterioriCovariance"].store( Pn )
         #
-        # Stockage supplementaire de l'optimum en estimation de parametres
-        # ----------------------------------------------------------------
+        # Stockage final supplémentaire de l'optimum en estimation de paramètres
+        # ----------------------------------------------------------------------
         if self._parameters["EstimationOf"] == "Parameters":
             self.StoredVariables["Analysis"].store( Xa.A1 )
             if self._toStore("APosterioriCovariance"):
                 self.StoredVariables["APosterioriCovariance"].store( covarianceXa )
-        #
-        if self._toStore("BMA"):
-            self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
+            if self._toStore("BMA"):
+                self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
         #
         self._post_run(HO)
         return 0
index bfb5205267a72a7e3902e3bcf91b14216a1ead14..e8115b4e6ca4b934d112eed07e7beb62262865ac 100644 (file)
@@ -47,21 +47,29 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             typecast = tuple,
             message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
             listval  = [
+                "Analysis",
                 "APosterioriCorrelations",
                 "APosterioriCovariance",
                 "APosterioriStandardDeviations",
                 "APosterioriVariances",
                 "BMA",
-                "CurrentState",
                 "CostFunctionJ",
+                "CostFunctionJAtCurrentOptimum",
                 "CostFunctionJb",
+                "CostFunctionJbAtCurrentOptimum",
                 "CostFunctionJo",
-                "Innovation",
+                "CostFunctionJoAtCurrentOptimum",
+                "CurrentOptimum",
+                "CurrentState",
+                "IndexOfOptimum",
+                "InnovationAtCurrentState",
                 "PredictedState",
+                "SimulatedObservationAtCurrentOptimum",
+                "SimulatedObservationAtCurrentState",
                 ]
             )
         self.requireInputArguments(
-            mandatory= ("Xb", "Y", "HO", "R", "B" ),
+            mandatory= ("Xb", "Y", "HO", "R", "B"),
             optional = ("U", "EM", "CM", "Q"),
             )
 
@@ -97,7 +105,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         if self._parameters["StoreInternalVariables"] \
             or self._toStore("CostFunctionJ") \
             or self._toStore("CostFunctionJb") \
-            or self._toStore("CostFunctionJo"):
+            or self._toStore("CostFunctionJo") \
+            or self._toStore("CurrentOptimum") \
+            or self._toStore("APosterioriCovariance"):
             BI = B.getI()
             RI = R.getI()
         #
@@ -141,57 +151,82 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 Pn_predicted = Pn
             #
             if self._parameters["EstimationOf"] == "State":
-                d  = Ynpu - Ht * Xn_predicted
+                _HX          = Ht * Xn_predicted
+                _Innovation  = Ynpu - _HX
             elif self._parameters["EstimationOf"] == "Parameters":
-                d  = Ynpu - Ht * Xn_predicted
+                _HX          = Ht * Xn_predicted
+                _Innovation  = Ynpu - _HX
                 if Cm is not None and Un is not None: # Attention : si Cm est aussi dans H, doublon !
-                    d = d - Cm * Un
+                    _Innovation = _Innovation - Cm * Un
             #
             _A = R + numpy.dot(Ht, Pn_predicted * Ha)
-            _u = numpy.linalg.solve( _A , d )
+            _u = numpy.linalg.solve( _A , _Innovation )
             Xn = Xn_predicted + Pn_predicted * Ha * _u
             Kn = Pn_predicted * Ha * (R + numpy.dot(Ht, Pn_predicted * Ha)).I
             Pn = Pn_predicted - Kn * Ht * Pn_predicted
             #
-            self.StoredVariables["Analysis"].store( Xn.A1 )
-            if self._toStore("APosterioriCovariance"):
-                self.StoredVariables["APosterioriCovariance"].store( Pn )
-            if self._toStore("Innovation"):
-                self.StoredVariables["Innovation"].store( numpy.ravel( d.A1 ) )
+            self.StoredVariables["Analysis"].store( Xn )
             if self._parameters["StoreInternalVariables"] \
-                or self._toStore("CurrentState"):
+                or self._toStore("CurrentState") \
+                or self._toStore("CurrentOptimum"):
                 self.StoredVariables["CurrentState"].store( Xn )
-            if self._parameters["StoreInternalVariables"] \
-                or self._toStore("PredictedState"):
+            if self._toStore("PredictedState"):
                 self.StoredVariables["PredictedState"].store( Xn_predicted )
+            if self._toStore("BMA"):
+                self.StoredVariables["BMA"].store( Xn_predicted - Xn )
+            if self._toStore("InnovationAtCurrentState"):
+                self.StoredVariables["InnovationAtCurrentState"].store( _Innovation )
+            if self._toStore("SimulatedObservationAtCurrentState") \
+                or self._toStore("SimulatedObservationAtCurrentOptimum"):
+                self.StoredVariables["SimulatedObservationAtCurrentState"].store( _HX )
             if self._parameters["StoreInternalVariables"] \
                 or self._toStore("CostFunctionJ") \
                 or self._toStore("CostFunctionJb") \
-                or self._toStore("CostFunctionJo"):
-                Jb  = 0.5 * (Xn - Xb).T * BI * (Xn - Xb)
-                Jo  = 0.5 * d.T * RI * d
-                J   = float( Jb ) + float( Jo )
+                or self._toStore("CostFunctionJo") \
+                or self._toStore("CurrentOptimum") \
+                or self._toStore("APosterioriCovariance"):
+                Jb  = float( 0.5 * (Xn - Xb).T * BI * (Xn - Xb) )
+                Jo  = float( 0.5 * _Innovation.T * RI * _Innovation )
+                J   = Jb + Jo
                 self.StoredVariables["CostFunctionJb"].store( Jb )
                 self.StoredVariables["CostFunctionJo"].store( Jo )
                 self.StoredVariables["CostFunctionJ" ].store( J )
-                if J < previousJMinimum:
+                if self._parameters["EstimationOf"] == "Parameters" \
+                    and J < previousJMinimum:
                     previousJMinimum  = J
                     Xa                = Xn
-                    if self._toStore("APosterioriCovariance"):
-                        covarianceXa  = Pn
-            else:
-                Xa = Xn
-            #
+                    if self._toStore("APosterioriCovariance"): covarianceXa = Pn
+                #
+                if self._toStore("IndexOfOptimum") \
+                    or self._toStore("CurrentOptimum") \
+                    or self._toStore("CostFunctionJAtCurrentOptimum") \
+                    or self._toStore("CostFunctionJbAtCurrentOptimum") \
+                    or self._toStore("CostFunctionJoAtCurrentOptimum") \
+                    or self._toStore("SimulatedObservationAtCurrentOptimum"):
+                    IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps
+                if self._toStore("IndexOfOptimum"):
+                    self.StoredVariables["IndexOfOptimum"].store( IndexMin )
+                if self._toStore("CurrentOptimum"):
+                    self.StoredVariables["CurrentOptimum"].store( self.StoredVariables["CurrentState"][IndexMin] )
+                if self._toStore("SimulatedObservationAtCurrentOptimum"):
+                    self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( self.StoredVariables["SimulatedObservationAtCurrentState"][IndexMin] )
+                if self._toStore("CostFunctionJbAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] )
+                if self._toStore("CostFunctionJoAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] )
+                if self._toStore("CostFunctionJAtCurrentOptimum"):
+                    self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
+            if self._toStore("APosterioriCovariance"):
+                self.StoredVariables["APosterioriCovariance"].store( Pn )
         #
-        # Stockage supplementaire de l'optimum en estimation de parametres
-        # ----------------------------------------------------------------
+        # Stockage final supplémentaire de l'optimum en estimation de paramètres
+        # ----------------------------------------------------------------------
         if self._parameters["EstimationOf"] == "Parameters":
             self.StoredVariables["Analysis"].store( Xa.A1 )
             if self._toStore("APosterioriCovariance"):
                 self.StoredVariables["APosterioriCovariance"].store( covarianceXa )
-        #
-        if self._toStore("BMA"):
-            self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
+            if self._toStore("BMA"):
+                self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
         #
         self._post_run(HO)
         return 0
index 5f078cc38d2c737bf9cf2b5620c79235bea115b6..bb3da550645dd38e7d6b383fc0cc6e0b84826c4d 100644 (file)
@@ -83,16 +83,17 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             typecast = tuple,
             message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
             listval  = [
+                "Analysis",
                 "APosterioriCorrelations",
                 "APosterioriCovariance",
                 "APosterioriStandardDeviations",
                 "APosterioriVariances",
                 "BMA",
-                "CurrentState",
                 "CostFunctionJ",
                 "CostFunctionJb",
                 "CostFunctionJo",
-                "Innovation",
+                "CurrentState",
+                "InnovationAtCurrentState",
                 ]
             )
         self.defineRequiredParameter( # Pas de type
@@ -164,10 +165,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         # Initialisation
         # --------------
         Xn = Xb
-        if hasattr(B,"asfullmatrix"):
-            Pn = B.asfullmatrix(Xn.size)
-        else:
-            Pn = B
+        if hasattr(B,"asfullmatrix"): Pn = B.asfullmatrix(Xn.size)
+        else:                         Pn = B
         #
         self.StoredVariables["Analysis"].store( Xn.A1 )
         if self._toStore("APosterioriCovariance"):
@@ -273,8 +272,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             self.StoredVariables["Analysis"].store( Xn.A1 )
             if self._toStore("APosterioriCovariance"):
                 self.StoredVariables["APosterioriCovariance"].store( Pn )
-            if self._toStore("Innovation"):
-                self.StoredVariables["Innovation"].store( numpy.ravel( d.A1 ) )
+            if self._toStore("InnovationAtCurrentState"):
+                self.StoredVariables["InnovationAtCurrentState"].store( numpy.ravel( d.A1 ) )
             if self._parameters["StoreInternalVariables"] \
                 or self._toStore("CurrentState"):
                 self.StoredVariables["CurrentState"].store( Xn )
@@ -295,7 +294,6 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                         covarianceXa  = Pn
             else:
                 Xa = Xn
-            #
         #
         # Stockage supplementaire de l'optimum en estimation de parametres
         # ----------------------------------------------------------------
@@ -303,9 +301,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             self.StoredVariables["Analysis"].store( Xa.A1 )
             if self._toStore("APosterioriCovariance"):
                 self.StoredVariables["APosterioriCovariance"].store( covarianceXa )
-        #
-        if self._toStore("BMA"):
-            self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
+            if self._toStore("BMA"):
+                self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
         #
         self._post_run(HO)
         return 0