1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2023 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é",
57 self.defineRequiredParameter(
58 name = "EstimationOf",
59 default = "Parameters",
61 message = "Estimation d'état ou de paramètres",
62 listval = ["State", "Parameters"],
64 self.defineRequiredParameter(
65 name = "MaximumNumberOfIterations",
68 message = "Nombre maximal de pas d'optimisation",
70 oldname = "MaximumNumberOfSteps",
72 self.defineRequiredParameter(
73 name = "CostDecrementTolerance",
76 message = "Diminution relative minimale du coût lors de l'arrêt",
79 self.defineRequiredParameter(
80 name = "ProjectedGradientTolerance",
83 message = "Maximum des composantes du gradient projeté lors de l'arrêt",
86 self.defineRequiredParameter(
87 name = "GradientNormTolerance",
90 message = "Maximum des composantes du gradient lors de l'arrêt",
93 self.defineRequiredParameter(
94 name = "StoreInternalVariables",
97 message = "Stockage des variables internes ou intermédiaires du calcul",
99 self.defineRequiredParameter(
100 name = "StoreSupplementaryCalculations",
103 message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
108 "CostFunctionJAtCurrentOptimum",
110 "CostFunctionJbAtCurrentOptimum",
112 "CostFunctionJoAtCurrentOptimum",
113 "CurrentIterationNumber",
120 "InnovationAtCurrentAnalysis",
121 "InnovationAtCurrentState",
124 "SimulatedObservationAtBackground",
125 "SimulatedObservationAtCurrentOptimum",
126 "SimulatedObservationAtCurrentState",
127 "SimulatedObservationAtOptimum",
130 self.defineRequiredParameter( # Pas de type
132 message = "Liste des paires de bornes",
134 self.defineRequiredParameter(
135 name = "InitializationPoint",
136 typecast = numpy.ravel,
137 message = "État initial imposé (par défaut, c'est l'ébauche si None)",
139 self.requireInputArguments(
140 mandatory= ("Xb", "Y", "HO", "R"),
141 optional = ("U", "EM", "CM", "Q"),
143 self.setAttributes(tags=(
149 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
150 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
152 #--------------------------
153 if self._parameters["Variant"] == "NonLinearLeastSquares":
154 NumericObjects.multiXOsteps(self, Xb, Y, U, HO, EM, CM, R, B, Q, ecwnlls.ecwnlls)
156 #--------------------------
157 elif self._parameters["Variant"] == "OneCorrection":
158 ecwnlls.ecwnlls(self, Xb, Y, U, HO, CM, R, B)
160 #--------------------------
162 raise ValueError("Error in Variant name: %s"%self._parameters["Variant"])
167 # ==============================================================================
168 if __name__ == "__main__":
169 print('\n AUTODIAGNOSTIC\n')