1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2024 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
25 from daAlgorithms.Atoms import std4dvar
27 # ==============================================================================
28 class ElementaryAlgorithm(BasicObjects.Algorithm):
31 BasicObjects.Algorithm.__init__(self, "4DVAR")
32 self.defineRequiredParameter(
33 name = "ConstrainedBy",
34 default = "EstimateProjection",
36 message = "Prise en compte des contraintes",
37 listval = ["EstimateProjection"],
39 self.defineRequiredParameter(
43 message = "Variant ou formulation de la méthode",
51 self.defineRequiredParameter(
52 name = "EstimationOf",
55 message = "Estimation d'état ou de paramètres",
56 listval = ["State", "Parameters"],
58 self.defineRequiredParameter(
62 message = "Minimiseur utilisé",
73 self.defineRequiredParameter(
74 name = "MaximumNumberOfIterations",
77 message = "Nombre maximal de pas d'optimisation",
79 oldname = "MaximumNumberOfSteps",
81 self.defineRequiredParameter(
82 name = "CostDecrementTolerance",
85 message = "Diminution relative minimale du coût lors de l'arrêt",
88 self.defineRequiredParameter(
89 name = "ProjectedGradientTolerance",
92 message = "Maximum des composantes du gradient projeté lors de l'arrêt",
95 self.defineRequiredParameter(
96 name = "GradientNormTolerance",
99 message = "Maximum des composantes du gradient lors de l'arrêt",
102 self.defineRequiredParameter(
103 name = "StoreInternalVariables",
106 message = "Stockage des variables internes ou intermédiaires du calcul",
108 self.defineRequiredParameter(
109 name = "StoreSupplementaryCalculations",
112 message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
117 "CostFunctionJAtCurrentOptimum",
119 "CostFunctionJbAtCurrentOptimum",
121 "CostFunctionJoAtCurrentOptimum",
122 "CurrentIterationNumber",
128 self.defineRequiredParameter( # Pas de type
130 message = "Liste des valeurs de bornes",
132 self.defineRequiredParameter(
133 name = "InitializationPoint",
134 typecast = numpy.ravel,
135 message = "État initial imposé (par défaut, c'est l'ébauche si None)",
137 self.requireInputArguments(
138 mandatory= ("Xb", "Y", "HO", "EM", "R", "B"),
139 optional = ("U", "CM", "Q"),
149 "NonLocalOptimization",
151 "ParallelDerivativesOnly",
156 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
157 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
159 # --------------------------
160 if self._parameters["Variant"] in ["4DVAR", "4DVAR-Std"]:
161 std4dvar.std4dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q)
163 # --------------------------
165 raise ValueError("Error in Variant name: %s"%self._parameters["Variant"])
167 self._post_run(HO, EM)
170 # ==============================================================================
171 if __name__ == "__main__":
172 print("\n AUTODIAGNOSTIC\n")