class ElementaryAlgorithm(BasicObjects.Algorithm):
def __init__(self):
BasicObjects.Algorithm.__init__(self, "BLUE")
+ self.defineRequiredParameter(
+ name = "StoreInternalVariables",
+ default = False,
+ typecast = bool,
+ message = "Stockage des variables internes ou intermédiaires du calcul",
+ )
self.defineRequiredParameter(
name = "StoreSupplementaryCalculations",
default = [],
# Opérateur d'observation
# -----------------------
Hm = HO["Tangent"].asMatrix(Xb)
+ Hm = Hm.reshape(Y.size,Xb.size) # ADAO & check shape
Ha = HO["Adjoint"].asMatrix(Xb)
+ Ha = Ha.reshape(Xb.size,Y.size) # ADAO & check shape
#
# Utilisation éventuelle d'un vecteur H(Xb) précalculé
# ----------------------------------------------------
else:
K = (Ha * RI * Hm + BI).I * Ha * RI
Xa = Xb + K*d
+ self.StoredVariables["Analysis"].store( Xa.A1 )
#
# Calcul de la fonction coût
# --------------------------
- oma = Y - Hm * Xa
- Jb = 0.5 * (Xa - Xb).T * BI * (Xa - Xb)
- Jo = 0.5 * oma.T * RI * oma
- J = float( Jb ) + float( Jo )
- self.StoredVariables["Analysis"].store( Xa.A1 )
- self.StoredVariables["CostFunctionJb"].store( Jb )
- self.StoredVariables["CostFunctionJo"].store( Jo )
- self.StoredVariables["CostFunctionJ" ].store( J )
+ if self._parameters["StoreInternalVariables"] or "OMA" in self._parameters["StoreSupplementaryCalculations"] or "SigmaObs2" in self._parameters["StoreSupplementaryCalculations"] or "MahalanobisConsistency" in self._parameters["StoreSupplementaryCalculations"]:
+ oma = Y - Hm * Xa
+ if self._parameters["StoreInternalVariables"] 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 )
+ self.StoredVariables["CostFunctionJb"].store( Jb )
+ self.StoredVariables["CostFunctionJo"].store( Jo )
+ self.StoredVariables["CostFunctionJ" ].store( J )
#
# Calcul de la covariance d'analyse
# ---------------------------------
class ElementaryAlgorithm(BasicObjects.Algorithm):
def __init__(self):
BasicObjects.Algorithm.__init__(self, "LINEARLEASTSQUARES")
+ self.defineRequiredParameter(
+ name = "StoreInternalVariables",
+ default = False,
+ typecast = bool,
+ message = "Stockage des variables internes ou intermédiaires du calcul",
+ )
self.defineRequiredParameter(
name = "StoreSupplementaryCalculations",
default = [],
# Opérateur d'observation
# -----------------------
Hm = HO["Tangent"].asMatrix(None)
+ Hm = Hm.reshape(Y.size,-1) # ADAO & check shape
Ha = HO["Adjoint"].asMatrix(None)
+ Ha = Ha.reshape(-1,Y.size) # ADAO & check shape
#
if R is not None:
RI = R.I
# --------------------------------------------
K = (Ha * RI * Hm ).I * Ha * RI
Xa = K * Y
+ self.StoredVariables["Analysis"].store( Xa.A1 )
#
# Calcul de la fonction coût
# --------------------------
- oma = Y - Hm * Xa
- Jb = 0.
- Jo = 0.5 * oma.T * RI * oma
- J = float( Jb ) + float( Jo )
- self.StoredVariables["Analysis"].store( Xa.A1 )
- self.StoredVariables["CostFunctionJb"].store( Jb )
- self.StoredVariables["CostFunctionJo"].store( Jo )
- self.StoredVariables["CostFunctionJ" ].store( J )
+ if self._parameters["StoreInternalVariables"] or "OMA" in self._parameters["StoreSupplementaryCalculations"]:
+ oma = Y - Hm * Xa
+ if self._parameters["StoreInternalVariables"]:
+ Jb = 0.
+ Jo = 0.5 * oma.T * RI * oma
+ J = float( Jb ) + float( Jo )
+ self.StoredVariables["CostFunctionJb"].store( Jb )
+ self.StoredVariables["CostFunctionJo"].store( Jo )
+ self.StoredVariables["CostFunctionJ" ].store( J )
#
# Calculs et/ou stockages supplémentaires
# ---------------------------------------