default = [],
typecast = tuple,
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
- listval = ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", "APosterioriVariances", "BMA", "OMA", "OMB", "CostFunctionJ", "CostFunctionJb", "CostFunctionJo", "CurrentState", "CurrentOptimum", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", "CostFunctionJAtCurrentOptimum", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum", "SimulatedObservationAtCurrentOptimum"]
+ listval = [
+ "APosterioriCorrelations",
+ "APosterioriCovariance",
+ "APosterioriStandardDeviations",
+ "APosterioriVariances",
+ "BMA",
+ "OMA",
+ "OMB",
+ "CostFunctionJ",
+ "CostFunctionJb",
+ "CostFunctionJo",
+ "CurrentState",
+ "CurrentOptimum",
+ "IndexOfOptimum",
+ "Innovation",
+ "InnovationAtCurrentState",
+ "CostFunctionJAtCurrentOptimum",
+ "CostFunctionJbAtCurrentOptimum",
+ "CostFunctionJoAtCurrentOptimum",
+ "SigmaObs2",
+ "MahalanobisConsistency",
+ "SimulationQuantiles",
+ "SimulatedObservationAtBackground",
+ "SimulatedObservationAtCurrentState",
+ "SimulatedObservationAtOptimum",
+ "SimulatedObservationAtCurrentOptimum",
+ ]
)
self.defineRequiredParameter(
name = "Quantiles",
if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+ "CostFunctionJbAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+ "CostFunctionJoAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps
if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"]:
if "SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( self.StoredVariables["SimulatedObservationAtCurrentState"][IndexMin] )
if "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
+ self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
+ if "CostFunctionJbAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] )
+ if "CostFunctionJoAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] )
- self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
return J
#
def GradientOfCostFunction(x):
default = [],
typecast = tuple,
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
- listval = ["BMA", "CurrentState", "CostFunctionJ", "CostFunctionJb", "CostFunctionJo", "IndexOfOptimum", "CurrentOptimum", "CostFunctionJAtCurrentOptimum"]
+ listval = [
+ "BMA",
+ "CurrentState",
+ "CostFunctionJ",
+ "CostFunctionJb",
+ "CostFunctionJo",
+ "IndexOfOptimum",
+ "CurrentOptimum",
+ "CostFunctionJAtCurrentOptimum",
+ "CostFunctionJbAtCurrentOptimum",
+ "CostFunctionJoAtCurrentOptimum",
+ ]
)
self.defineRequiredParameter( # Pas de type
name = "Bounds",
self.StoredVariables["CostFunctionJ" ].store( J )
if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
- "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
+ "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+ "CostFunctionJbAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+ "CostFunctionJoAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps
if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["IndexOfOptimum"].store( IndexMin )
if "CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CurrentOptimum"].store( self.StoredVariables["CurrentState"][IndexMin] )
if "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
+ self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
+ if "CostFunctionJbAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] )
+ if "CostFunctionJoAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] )
- self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
return J
#
def GradientOfCostFunction(x):
default = [],
typecast = tuple,
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
- listval = ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", "APosterioriVariances", "BMA", "OMA", "OMB", "CurrentState", "CostFunctionJ", "CostFunctionJb", "CostFunctionJo", "Innovation", "SigmaBck2", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum"]
+ listval = [
+ "APosterioriCorrelations",
+ "APosterioriCovariance",
+ "APosterioriStandardDeviations",
+ "APosterioriVariances",
+ "BMA",
+ "OMA",
+ "OMB",
+ "CurrentState",
+ "CostFunctionJ",
+ "CostFunctionJb",
+ "CostFunctionJo",
+ "Innovation",
+ "SigmaBck2",
+ "SigmaObs2",
+ "MahalanobisConsistency",
+ "SimulationQuantiles",
+ "SimulatedObservationAtBackground",
+ "SimulatedObservationAtCurrentState",
+ "SimulatedObservationAtOptimum",
+ ]
)
self.defineRequiredParameter(
name = "Quantiles",
Ha = HO["Adjoint"].asMatrix(Xb)
Ha = Ha.reshape(Xb.size,Y.size) # ADAO & check shape
#
- # Utilisation éventuelle d'un vecteur H(Xb) précalculé (sans cout)
- # ----------------------------------------------------------------
+ # Utilisation éventuelle d'un vecteur H(Xb) précalculé
+ # ----------------------------------------------------
if HO["AppliedInX"] is not None and "HXb" in HO["AppliedInX"]:
HXb = HO["AppliedInX"]["HXb"]
else:
if self._parameters["StoreInternalVariables"] or \
"CostFunctionJ" in self._parameters["StoreSupplementaryCalculations"] or \
"MahalanobisConsistency" in self._parameters["StoreSupplementaryCalculations"]:
- #
Jb = float( 0.5 * (Xa - Xb).T * BI * (Xa - Xb) )
Jo = float( 0.5 * oma.T * RI * oma )
J = Jb + Jo
- #
self.StoredVariables["CostFunctionJb"].store( Jb )
self.StoredVariables["CostFunctionJo"].store( Jo )
self.StoredVariables["CostFunctionJ" ].store( J )
default = [],
typecast = tuple,
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
- listval = ["CurrentState", "CostFunctionJ", "CostFunctionJb", "CostFunctionJo", "CostFunctionJAtCurrentOptimum", "CurrentOptimum", "IndexOfOptimum", "InnovationAtCurrentState", "BMA", "OMA", "OMB", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentOptimum", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum"]
+ listval = [
+ "CurrentState",
+ "CostFunctionJ",
+ "CostFunctionJb",
+ "CostFunctionJo",
+ "CostFunctionJAtCurrentOptimum",
+ "CostFunctionJbAtCurrentOptimum",
+ "CostFunctionJoAtCurrentOptimum",
+ "CurrentOptimum",
+ "IndexOfOptimum",
+ "InnovationAtCurrentState",
+ "BMA",
+ "OMA",
+ "OMB",
+ "SimulatedObservationAtBackground",
+ "SimulatedObservationAtCurrentOptimum",
+ "SimulatedObservationAtCurrentState",
+ "SimulatedObservationAtOptimum",
+ ]
)
self.defineRequiredParameter( # Pas de type
name = "Bounds",
if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+ "CostFunctionJbAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+ "CostFunctionJoAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps
if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"]:
if "SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( self.StoredVariables["SimulatedObservationAtCurrentState"][IndexMin] )
if "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
+ self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
+ if "CostFunctionJbAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] )
+ if "CostFunctionJoAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] )
- self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
return J
#
# Point de démarrage de l'optimisation : Xini = Xb
default = [],
typecast = tuple,
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
- listval = ["CurrentState", "Innovation", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum"]
+ listval = [
+ "CurrentState",
+ "Innovation",
+ "SimulatedObservationAtBackground",
+ "SimulatedObservationAtCurrentState",
+ "SimulatedObservationAtOptimum",
+ ]
)
self.defineRequiredParameter(
name = "SetSeed",
message = "Graine fixée pour le générateur aléatoire",
)
self.requireInputArguments(
- mandatory= ("Xb", "Y", "HO", "R", "B" ),
+ mandatory= ("Xb", "Y", "HO", "R", "B"),
)
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
default = [],
typecast = tuple,
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
- listval = ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", "APosterioriVariances", "BMA", "OMA", "OMB", "CurrentState", "CostFunctionJ", "CostFunctionJb", "CostFunctionJo", "Innovation", "SigmaBck2", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum"]
+ listval = [
+ "APosterioriCorrelations",
+ "APosterioriCovariance",
+ "APosterioriStandardDeviations",
+ "APosterioriVariances",
+ "BMA",
+ "OMA",
+ "OMB",
+ "CurrentState",
+ "CostFunctionJ",
+ "CostFunctionJb",
+ "CostFunctionJo",
+ "Innovation",
+ "SigmaBck2",
+ "SigmaObs2",
+ "MahalanobisConsistency",
+ "SimulationQuantiles",
+ "SimulatedObservationAtBackground",
+ "SimulatedObservationAtCurrentState",
+ "SimulatedObservationAtOptimum",
+ ]
)
self.defineRequiredParameter(
name = "Quantiles",
listval = ["Linear", "NonLinear"]
)
self.requireInputArguments(
- mandatory= ("Xb", "Y", "HO", "R", "B" ),
+ mandatory= ("Xb", "Y", "HO", "R", "B"),
)
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
else:
HXb = H( Xb )
HXb = numpy.asmatrix(numpy.ravel( HXb )).T
+ if Y.size != HXb.size:
+ raise ValueError("The size %i of observations Y and %i of observed calculation H(X) are different, they have to be identical."%(Y.size,HXb.size))
+ if max(Y.shape) != max(HXb.shape):
+ raise ValueError("The shapes %s of observations Y and %s of observed calculation H(X) are different, they have to be identical."%(Y.shape,HXb.shape))
#
# Précalcul des inversions de B et R
# ----------------------------------
#
# Calcul de l'innovation
# ----------------------
- if Y.size != HXb.size:
- raise ValueError("The size %i of observations Y and %i of observed calculation H(X) are different, they have to be identical."%(Y.size,HXb.size))
- if max(Y.shape) != max(HXb.shape):
- raise ValueError("The shapes %s of observations Y and %s of observed calculation H(X) are different, they have to be identical."%(Y.shape,HXb.shape))
d = Y - HXb
#
# Calcul de la matrice de gain et de l'analyse
default = [],
typecast = tuple,
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
- listval = ["BMA", "OMA", "OMB", "CostFunctionJ", "CostFunctionJb", "CostFunctionJo", "CurrentState", "CurrentOptimum", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", "CostFunctionJAtCurrentOptimum", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum", "SimulatedObservationAtCurrentOptimum"]
+ listval = [
+ "BMA",
+ "OMA",
+ "OMB",
+ "CostFunctionJ",
+ "CostFunctionJb",
+ "CostFunctionJo",
+ "CurrentState",
+ "CurrentOptimum",
+ "IndexOfOptimum",
+ "Innovation",
+ "InnovationAtCurrentState",
+ "CostFunctionJAtCurrentOptimum",
+ "CostFunctionJbAtCurrentOptimum",
+ "CostFunctionJoAtCurrentOptimum",
+ "SimulatedObservationAtBackground",
+ "SimulatedObservationAtCurrentState",
+ "SimulatedObservationAtOptimum",
+ "SimulatedObservationAtCurrentOptimum",
+ ]
)
self.defineRequiredParameter( # Pas de type
name = "Bounds",
if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+ "CostFunctionJbAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
+ "CostFunctionJoAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \
"SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps
if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"]:
if "SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( self.StoredVariables["SimulatedObservationAtCurrentState"][IndexMin] )
if "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
+ self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
+ if "CostFunctionJbAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] )
+ if "CostFunctionJoAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] )
- self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] )
return J
#
def GradientOfCostFunction(x):