X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FdaComposant%2FdaCore%2FBasicObjects.py;h=eefbea3806812c12230658e7ad229270ecbf40a7;hb=a6845547d27bcdc0928f898a4c8a2e4fc276c69e;hp=9d12eac30ae5621a174ccab4e526e6ad2efef0b4;hpb=e5a70dbf1ff528a1428da3d7637ab02a26451597;p=modules%2Fadao.git diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 9d12eac..eefbea3 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2008-2022 EDF R&D +# Copyright (C) 2008-2023 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 @@ -44,14 +44,14 @@ class CacheManager(object): """ def __init__(self, toleranceInRedundancy = 1.e-18, - lenghtOfRedundancy = -1, + lengthOfRedundancy = -1, ): """ Les caractéristiques de tolérance peuvent être modifiées à la création. """ self.__tolerBP = float(toleranceInRedundancy) - self.__lenghtOR = int(lenghtOfRedundancy) - self.__initlnOR = self.__lenghtOR + self.__lengthOR = int(lengthOfRedundancy) + self.__initlnOR = self.__lengthOR self.__seenNames = [] self.__enabled = True self.clearCache() @@ -66,7 +66,7 @@ class CacheManager(object): __alc = False __HxV = None if self.__enabled: - for i in range(min(len(self.__listOPCV),self.__lenghtOR)-1,-1,-1): + for i in range(min(len(self.__listOPCV),self.__lengthOR)-1,-1,-1): if not hasattr(xValue, 'size'): pass elif (str(oName) != self.__listOPCV[i][3]): @@ -83,15 +83,15 @@ class CacheManager(object): def storeValueInX(self, xValue, HxValue, oName="" ): "Stocke pour un opérateur o un calcul Hx correspondant à la valeur x" - if self.__lenghtOR < 0: - self.__lenghtOR = 2 * min(xValue.size, 50) + 2 # 2 * xValue.size + 2 - self.__initlnOR = self.__lenghtOR + if self.__lengthOR < 0: + self.__lengthOR = 2 * min(numpy.size(xValue), 50) + 2 + self.__initlnOR = self.__lengthOR self.__seenNames.append(str(oName)) if str(oName) not in self.__seenNames: # Etend la liste si nouveau - self.__lenghtOR += 2 * min(xValue.size, 50) + 2 # 2 * xValue.size + 2 - self.__initlnOR += self.__lenghtOR + self.__lengthOR += 2 * min(numpy.size(xValue), 50) + 2 + self.__initlnOR += self.__lengthOR self.__seenNames.append(str(oName)) - while len(self.__listOPCV) > self.__lenghtOR: + while len(self.__listOPCV) > self.__lengthOR: self.__listOPCV.pop(0) self.__listOPCV.append( ( copy.copy(numpy.ravel(xValue)), # 0 Previous point @@ -102,13 +102,13 @@ class CacheManager(object): def disable(self): "Inactive le cache" - self.__initlnOR = self.__lenghtOR - self.__lenghtOR = 0 + self.__initlnOR = self.__lengthOR + self.__lengthOR = 0 self.__enabled = False def enable(self): "Active le cache" - self.__lenghtOR = self.__initlnOR + self.__lengthOR = self.__initlnOR self.__enabled = True # ============================================================================== @@ -529,7 +529,7 @@ class FullOperator(object): if "withReducingMemoryUse" not in __Function: __Function["withReducingMemoryUse"] = __reduceM if "withAvoidingRedundancy" not in __Function: __Function["withAvoidingRedundancy"] = __avoidRC if "withToleranceInRedundancy" not in __Function: __Function["withToleranceInRedundancy"] = 1.e-18 - if "withLenghtOfRedundancy" not in __Function: __Function["withLenghtOfRedundancy"] = -1 + if "withLengthOfRedundancy" not in __Function: __Function["withLengthOfRedundancy"] = -1 if "NumberOfProcesses" not in __Function: __Function["NumberOfProcesses"] = None if "withmfEnabled" not in __Function: __Function["withmfEnabled"] = inputAsMF from daCore import NumericObjects @@ -543,7 +543,7 @@ class FullOperator(object): reducingMemoryUse = __Function["withReducingMemoryUse"], avoidingRedundancy = __Function["withAvoidingRedundancy"], toleranceInRedundancy = __Function["withToleranceInRedundancy"], - lenghtOfRedundancy = __Function["withLenghtOfRedundancy"], + lengthOfRedundancy = __Function["withLengthOfRedundancy"], mpEnabled = __Function["EnableMultiProcessingInDerivatives"], mpWorkers = __Function["NumberOfProcesses"], mfEnabled = __Function["withmfEnabled"], @@ -681,6 +681,11 @@ class Algorithm(object): - CurrentOptimum : état optimal courant lors d'itérations - CurrentState : état courant lors d'itérations - CurrentStepNumber : pas courant d'avancement dans les algorithmes en évolution, à partir de 0 + - EnsembleOfSimulations : ensemble d'états (sorties, simulations) rangés par colonne dans une matrice + - EnsembleOfSnapshots : ensemble d'états rangés par colonne dans une matrice + - EnsembleOfStates : ensemble d'états (entrées, paramètres) rangés par colonne dans une matrice + - ForecastCovariance : covariance de l'état prédit courant lors d'itérations + - ForecastState : état prédit courant lors d'itérations - GradientOfCostFunctionJ : gradient de la fonction-coût globale - GradientOfCostFunctionJb : gradient de la partie ébauche de la fonction-coût - GradientOfCostFunctionJo : gradient de la partie observations de la fonction-coût @@ -694,8 +699,6 @@ class Algorithm(object): - MahalanobisConsistency : indicateur de consistance des covariances - OMA : Observation moins Analyse : Y - Xa - OMB : Observation moins Background : Y - Xb - - ForecastCovariance : covariance de l'état prédit courant lors d'itérations - - ForecastState : état prédit courant lors d'itérations - Residu : dans le cas des algorithmes de vérification - SampledStateForQuantiles : échantillons d'états pour l'estimation des quantiles - SigmaBck2 : indicateur de correction optimale des erreurs d'ébauche @@ -742,6 +745,9 @@ class Algorithm(object): self.StoredVariables["CurrentOptimum"] = Persistence.OneVector(name = "CurrentOptimum") self.StoredVariables["CurrentState"] = Persistence.OneVector(name = "CurrentState") self.StoredVariables["CurrentStepNumber"] = Persistence.OneIndex(name = "CurrentStepNumber") + self.StoredVariables["EnsembleOfSimulations"] = Persistence.OneMatrix(name = "EnsembleOfSimulations") + self.StoredVariables["EnsembleOfSnapshots"] = Persistence.OneMatrix(name = "EnsembleOfSnapshots") + self.StoredVariables["EnsembleOfStates"] = Persistence.OneMatrix(name = "EnsembleOfStates") self.StoredVariables["ForecastCovariance"] = Persistence.OneMatrix(name = "ForecastCovariance") self.StoredVariables["ForecastState"] = Persistence.OneVector(name = "ForecastState") self.StoredVariables["GradientOfCostFunctionJ"] = Persistence.OneVector(name = "GradientOfCostFunctionJ") @@ -758,7 +764,10 @@ class Algorithm(object): self.StoredVariables["MahalanobisConsistency"] = Persistence.OneScalar(name = "MahalanobisConsistency") self.StoredVariables["OMA"] = Persistence.OneVector(name = "OMA") self.StoredVariables["OMB"] = Persistence.OneVector(name = "OMB") + self.StoredVariables["OptimalPoints"] = Persistence.OneVector(name = "OptimalPoints") + self.StoredVariables["ReducedBasis"] = Persistence.OneMatrix(name = "ReducedBasis") self.StoredVariables["Residu"] = Persistence.OneScalar(name = "Residu") + self.StoredVariables["Residus"] = Persistence.OneVector(name = "Residus") self.StoredVariables["SampledStateForQuantiles"] = Persistence.OneMatrix(name = "SampledStateForQuantiles") self.StoredVariables["SigmaBck2"] = Persistence.OneScalar(name = "SigmaBck2") self.StoredVariables["SigmaObs2"] = Persistence.OneScalar(name = "SigmaObs2") @@ -783,7 +792,7 @@ class Algorithm(object): logging.debug("%s Taille mémoire utilisée de %.0f Mio"%(self._name, self._m.getUsedMemory("Mio"))) self._getTimeState(reset=True) # - # Mise a jour des paramètres internes avec le contenu de Parameters, en + # Mise à jour des paramètres internes avec le contenu de Parameters, en # reprenant les valeurs par défauts pour toutes celles non définies self.__setParameters(Parameters, reset=True) for k, v in self.__variable_names_not_public.items(): @@ -969,10 +978,9 @@ class Algorithm(object): def run(self, Xb=None, Y=None, H=None, M=None, R=None, B=None, Q=None, Parameters=None): """ - Doit implémenter l'opération élémentaire de calcul d'assimilation sous - sa forme mathématique la plus naturelle possible. + Doit implémenter l'opération élémentaire de calcul algorithmique. """ - raise NotImplementedError("Mathematical assimilation calculation has not been implemented!") + raise NotImplementedError("Mathematical algorithmic calculation has not been implemented!") def defineRequiredParameter(self, name = None, @@ -1237,7 +1245,7 @@ class AlgorithmAndParameters(object): asDict = None, asScript = None, ): - "Mise a jour des parametres" + "Mise à jour des paramètres" if asDict is None and asScript is not None: __Dict = Interfaces.ImportFromScript(asScript).getvalue( self.__name, "Parameters" ) else: @@ -1739,7 +1747,7 @@ class UserScript(object): # ============================================================================== class ExternalParameters(object): """ - Classe générale d'interface de type texte de script utilisateur + Classe générale d'interface pour le stockage des paramètres externes """ def __init__(self, name = "GenericExternalParameters", @@ -1757,7 +1765,7 @@ class ExternalParameters(object): asDict = None, asScript = None, ): - "Mise a jour des parametres" + "Mise à jour des paramètres" if asDict is None and asScript is not None: __Dict = Interfaces.ImportFromScript(asScript).getvalue( self.__name, "ExternalParameters" ) else: