+ self.__Q = Covariance(
+ name = "EvolutionError",
+ asCovariance = asCovariance,
+ asEyeByScalar = asEyeByScalar,
+ asEyeByVector = asEyeByVector,
+ asCovObject = asCovObject,
+ toBeChecked = toBeChecked,
+ )
+ if toBeStored:
+ self.__StoredInputs["EvolutionError"] = self.__Q
+ return 0
+
+ # -----------------------------------------------------------
+ def setControlModel(self,
+ asFunction = {"Direct":None, "Tangent":None, "Adjoint":None,
+ "useApproximatedDerivatives":False,
+ "withCenteredDF" :False,
+ "withIncrement" :0.01,
+ "withdX" :None,
+ },
+ asMatrix = None,
+ Scheduler = None,
+ toBeStored = False,
+ avoidRC = True,
+ ):
+ """
+ Permet de définir un opérateur de controle C. L'ordre de priorité des
+ définitions et leur sens sont les suivants :
+ - si asFunction["Tangent"] et asFunction["Adjoint"] ne sont pas None
+ alors on définit l'opérateur à l'aide de fonctions. Si la fonction
+ "Direct" n'est pas définie, on prend la fonction "Tangent".
+ Si "useApproximatedDerivatives" est vrai, on utilise une approximation
+ des opérateurs tangents et adjoints. On utilise par défaut des
+ différences finies non centrées ou centrées (si "withCenteredDF" est
+ vrai) avec un incrément multiplicatif "withIncrement" de 1% autour
+ du point courant ou sur le point fixe "withdX".
+ - si les fonctions ne sont pas disponibles et si asMatrix n'est pas
+ None, alors on définit l'opérateur "Direct" et "Tangent" à l'aide de
+ la matrice, et l'opérateur "Adjoint" à l'aide de la transposée. La
+ matrice fournie doit être sous une forme compatible avec le
+ constructeur de numpy.matrix.
+ - toBeStored : booléen indiquant si la donnée d'entrée est sauvée pour
+ être rendue disponible au même titre que les variables de calcul
+ L'argument "asFunction" peut prendre la forme complète suivante, avec
+ les valeurs par défaut standards :
+ asFunction = {"Direct":None, "Tangent":None, "Adjoint":None,
+ "useApproximatedDerivatives":False,
+ "withCenteredDF" :False,
+ "withIncrement" :0.01,
+ "withdX" :None,
+ "withAvoidingRedundancy" :True,
+ "withToleranceInRedundancy" :1.e-18,
+ "withLenghtOfRedundancy" :-1,
+ "withmpEnabled" :False,
+ "withmpWorkers" :None,
+ }
+ """
+ if isinstance(asFunction, dict) and \
+ ("useApproximatedDerivatives" in asFunction) and bool(asFunction["useApproximatedDerivatives"]) and \
+ ("Direct" in asFunction) and (asFunction["Direct"] is not None):
+ if "withCenteredDF" not in asFunction: asFunction["withCenteredDF"] = False
+ if "withIncrement" not in asFunction: asFunction["withIncrement"] = 0.01
+ if "withdX" not in asFunction: asFunction["withdX"] = None
+ if "withAvoidingRedundancy" not in asFunction: asFunction["withAvoidingRedundancy"] = True
+ if "withToleranceInRedundancy" not in asFunction: asFunction["withToleranceInRedundancy"] = 1.e-18
+ if "withLenghtOfRedundancy" not in asFunction: asFunction["withLenghtOfRedundancy"] = -1
+ if "withmpEnabled" not in asFunction: asFunction["withmpEnabled"] = False
+ if "withmpWorkers" not in asFunction: asFunction["withmpWorkers"] = None
+ from daNumerics.ApproximatedDerivatives import FDApproximation
+ FDA = FDApproximation(
+ Function = asFunction["Direct"],
+ centeredDF = asFunction["withCenteredDF"],
+ increment = asFunction["withIncrement"],
+ dX = asFunction["withdX"],
+ avoidingRedundancy = asFunction["withAvoidingRedundancy"],
+ toleranceInRedundancy = asFunction["withToleranceInRedundancy"],
+ lenghtOfRedundancy = asFunction["withLenghtOfRedundancy"],
+ mpEnabled = asFunction["withmpEnabled"],
+ mpWorkers = asFunction["withmpWorkers"],
+ )
+ self.__CM["Direct"] = Operator( fromMethod = FDA.DirectOperator, avoidingRedundancy = avoidRC )
+ self.__CM["Tangent"] = Operator( fromMethod = FDA.TangentOperator, avoidingRedundancy = avoidRC )
+ self.__CM["Adjoint"] = Operator( fromMethod = FDA.AdjointOperator, avoidingRedundancy = avoidRC )
+ elif isinstance(asFunction, dict) and \
+ ("Tangent" in asFunction) and ("Adjoint" in asFunction) and \
+ (asFunction["Tangent"] is not None) and (asFunction["Adjoint"] is not None):
+ if ("Direct" not in asFunction) or (asFunction["Direct"] is None):
+ self.__CM["Direct"] = Operator( fromMethod = asFunction["Tangent"], avoidingRedundancy = avoidRC )
+ else:
+ self.__CM["Direct"] = Operator( fromMethod = asFunction["Direct"], avoidingRedundancy = avoidRC )
+ self.__CM["Tangent"] = Operator( fromMethod = asFunction["Tangent"], avoidingRedundancy = avoidRC )
+ self.__CM["Adjoint"] = Operator( fromMethod = asFunction["Adjoint"], avoidingRedundancy = avoidRC )
+ elif asMatrix is not None:
+ matrice = numpy.matrix( asMatrix, numpy.float )
+ self.__CM["Direct"] = Operator( fromMatrix = matrice, avoidingRedundancy = avoidRC )
+ self.__CM["Tangent"] = Operator( fromMatrix = matrice, avoidingRedundancy = avoidRC )
+ self.__CM["Adjoint"] = Operator( fromMatrix = matrice.T, avoidingRedundancy = avoidRC )
+ del matrice
+ else:
+ raise ValueError("Improperly defined input control model, it requires at minima either a matrix, a Direct for approximate derivatives or a Tangent/Adjoint pair.")
+ #
+ if toBeStored:
+ self.__StoredInputs["ControlModel"] = self.__CM
+ return 0
+
+ def setControlInput(self,
+ asVector = None,
+ asPersistentVector = None,
+ Scheduler = None,
+ toBeStored = False,
+ ):
+ """
+ Permet de définir le controle en entree :
+ - asVector : entrée des données, comme un vecteur compatible avec le
+ constructeur de numpy.matrix
+ - asPersistentVector : entrée des données, comme un vecteur de type
+ persistent contruit avec la classe ad-hoc "Persistence"
+ - Scheduler est le contrôle temporel des données disponibles
+ - toBeStored : booléen indiquant si la donnée d'entrée est sauvée pour
+ être rendue disponible au même titre que les variables de calcul
+ """
+ if asVector is not None:
+ self.__U = numpy.matrix( numpy.ravel(numpy.matrix(asVector)), numpy.float ).T
+ elif asPersistentVector is not None:
+ if type(asPersistentVector) in [type([]),type(()),type(numpy.array([])),type(numpy.matrix([]))]:
+ self.__U = Persistence.OneVector("ControlInput", basetype=numpy.matrix)
+ for member in asPersistentVector:
+ self.__U.store( numpy.matrix( numpy.asmatrix(member).A1, numpy.float ).T )
+ else:
+ self.__U = asPersistentVector
+ else:
+ raise ValueError("Error: improperly defined control input, it requires at minima either a vector, a list/tuple of vectors or a persistent object")
+ if toBeStored:
+ self.__StoredInputs["ControlInput"] = self.__U