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, NumericObjects
25 from daAlgorithms.Atoms import ecwnlls
27 # ==============================================================================
28 class ElementaryAlgorithm(BasicObjects.Algorithm):
30 BasicObjects.Algorithm.__init__(self, "NONLINEARLEASTSQUARES")
31 self.defineRequiredParameter(
33 default = "NonLinearLeastSquares",
35 message = "Variant ou formulation de la méthode",
37 "NonLinearLeastSquares",
43 self.defineRequiredParameter(
47 message = "Minimiseur utilisé",
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 = "MaximumNumberOfIterations",
70 message = "Nombre maximal de pas d'optimisation",
72 oldname = "MaximumNumberOfSteps",
74 self.defineRequiredParameter(
75 name = "CostDecrementTolerance",
78 message = "Diminution relative minimale du coût lors de l'arrêt",
81 self.defineRequiredParameter(
82 name = "ProjectedGradientTolerance",
85 message = "Maximum des composantes du gradient projeté lors de l'arrêt",
88 self.defineRequiredParameter(
89 name = "GradientNormTolerance",
92 message = "Maximum des composantes du gradient lors de l'arrêt",
95 self.defineRequiredParameter(
96 name = "StoreInternalVariables",
99 message = "Stockage des variables internes ou intermédiaires du calcul",
101 self.defineRequiredParameter(
102 name = "StoreSupplementaryCalculations",
105 message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
110 "CostFunctionJAtCurrentOptimum",
112 "CostFunctionJbAtCurrentOptimum",
114 "CostFunctionJoAtCurrentOptimum",
115 "CurrentIterationNumber",
122 "InnovationAtCurrentAnalysis",
123 "InnovationAtCurrentState",
126 "SimulatedObservationAtBackground",
127 "SimulatedObservationAtCurrentOptimum",
128 "SimulatedObservationAtCurrentState",
129 "SimulatedObservationAtOptimum",
132 self.defineRequiredParameter( # Pas de type
134 message = "Liste des paires de bornes",
136 self.defineRequiredParameter(
137 name = "InitializationPoint",
138 typecast = numpy.ravel,
139 message = "État initial imposé (par défaut, c'est l'ébauche si None)",
141 self.requireInputArguments(
142 mandatory= ("Xb", "Y", "HO", "R"),
143 optional = ("U", "EM", "CM", "Q"),
154 "ParallelDerivativesOnly",
159 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
160 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
162 # --------------------------
163 if self._parameters["Variant"] == "NonLinearLeastSquares":
164 NumericObjects.multiXOsteps(self, Xb, Y, U, HO, EM, CM, R, B, Q, ecwnlls.ecwnlls)
166 # --------------------------
167 elif self._parameters["Variant"] == "OneCorrection":
168 ecwnlls.ecwnlls(self, Xb, Y, U, HO, CM, R, B)
170 # --------------------------
172 raise ValueError("Error in Variant name: %s"%self._parameters["Variant"])
174 self._post_run(HO, EM)
177 # ==============================================================================
178 if __name__ == "__main__":
179 print("\n AUTODIAGNOSTIC\n")