1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2021 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 from daCore import BasicObjects, NumericObjects
26 # ==============================================================================
27 class ElementaryAlgorithm(BasicObjects.Algorithm):
29 BasicObjects.Algorithm.__init__(self, "3DVAR")
30 self.defineRequiredParameter(
34 message = "Minimiseur utilisé",
43 self.defineRequiredParameter(
47 message = "Variant ou formulation de la méthode",
59 self.defineRequiredParameter(
60 name = "EstimationOf",
61 default = "Parameters",
63 message = "Estimation d'état ou de paramètres",
64 listval = ["State", "Parameters"],
66 self.defineRequiredParameter(
67 name = "MaximumNumberOfSteps",
70 message = "Nombre maximal de pas d'optimisation",
73 self.defineRequiredParameter(
74 name = "CostDecrementTolerance",
77 message = "Diminution relative minimale du coût lors de l'arrêt",
80 self.defineRequiredParameter(
81 name = "ProjectedGradientTolerance",
84 message = "Maximum des composantes du gradient projeté lors de l'arrêt",
87 self.defineRequiredParameter(
88 name = "GradientNormTolerance",
91 message = "Maximum des composantes du gradient lors de l'arrêt",
94 self.defineRequiredParameter(
95 name = "StoreInternalVariables",
98 message = "Stockage des variables internes ou intermédiaires du calcul",
100 self.defineRequiredParameter(
101 name = "StoreSupplementaryCalculations",
104 message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
107 "APosterioriCorrelations",
108 "APosterioriCovariance",
109 "APosterioriStandardDeviations",
110 "APosterioriVariances",
113 "CostFunctionJAtCurrentOptimum",
115 "CostFunctionJbAtCurrentOptimum",
117 "CostFunctionJoAtCurrentOptimum",
118 "CurrentIterationNumber",
124 "InnovationAtCurrentState",
125 "JacobianMatrixAtBackground",
126 "JacobianMatrixAtOptimum",
127 "KalmanGainAtOptimum",
128 "MahalanobisConsistency",
132 "SimulatedObservationAtBackground",
133 "SimulatedObservationAtCurrentOptimum",
134 "SimulatedObservationAtCurrentState",
135 "SimulatedObservationAtOptimum",
136 "SimulationQuantiles",
139 self.defineRequiredParameter(
143 message = "Liste des valeurs de quantiles",
147 self.defineRequiredParameter(
149 typecast = numpy.random.seed,
150 message = "Graine fixée pour le générateur aléatoire",
152 self.defineRequiredParameter(
153 name = "NumberOfSamplesForQuantiles",
156 message = "Nombre d'échantillons simulés pour le calcul des quantiles",
159 self.defineRequiredParameter(
160 name = "SimulationForQuantiles",
163 message = "Type de simulation pour l'estimation des quantiles",
164 listval = ["Linear", "NonLinear"]
166 self.defineRequiredParameter( # Pas de type
168 message = "Liste des valeurs de bornes",
170 self.defineRequiredParameter(
171 name = "InitializationPoint",
172 typecast = numpy.ravel,
173 message = "État initial imposé (par défaut, c'est l'ébauche si None)",
175 self.requireInputArguments(
176 mandatory= ("Xb", "Y", "HO", "R", "B" ),
178 self.setAttributes(tags=(
184 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
185 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
187 #--------------------------
189 if self._parameters["Variant"] in ["3DVAR", "3DVAR-Std"]:
190 NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.std3dvar)
192 elif self._parameters["Variant"] == "3DVAR-VAN":
193 NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.van3dvar)
195 elif self._parameters["Variant"] in ["3DVAR-Incr", "Incr3DVAR"]:
196 NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.incr3dvar)
198 elif self._parameters["Variant"] == "3DVAR-PSAS":
199 NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.psas3dvar)
201 #--------------------------
202 elif self._parameters["Variant"] == "OneCycle3DVAR-Std":
203 NumericObjects.std3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q)
205 #--------------------------
207 raise ValueError("Error in Variant name: %s"%self._parameters["Variant"])
212 # ==============================================================================
213 if __name__ == "__main__":
214 print('\n AUTODIAGNOSTIC\n')