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
23 from daCore import BasicObjects
24 from daAlgorithms.Atoms import ecwukf, ecw2ukf
26 # ==============================================================================
27 class ElementaryAlgorithm(BasicObjects.Algorithm):
30 BasicObjects.Algorithm.__init__(self, "UNSCENTEDKALMANFILTER")
31 self.defineRequiredParameter(
35 message = "Variant ou formulation de la méthode",
50 self.defineRequiredParameter(
51 name = "EstimationOf",
54 message = "Estimation d'état ou de paramètres",
55 listval = ["State", "Parameters"],
57 self.defineRequiredParameter(
58 name = "ConstrainedBy",
59 default = "EstimateProjection",
61 message = "Prise en compte des contraintes",
62 listval = ["EstimateProjection"],
64 self.defineRequiredParameter(
68 message = "Coefficient Alpha d'échelle",
72 self.defineRequiredParameter(
76 message = "Coefficient Beta d'information a priori sur la distribution",
78 self.defineRequiredParameter(
82 message = "Coefficient Kappa secondaire d'échelle",
85 self.defineRequiredParameter(
86 name = "Reconditioner",
89 message = "Coefficient de reconditionnement",
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",
106 "APosterioriCorrelations",
107 "APosterioriCovariance",
108 "APosterioriStandardDeviations",
109 "APosterioriVariances",
112 "CostFunctionJAtCurrentOptimum",
114 "CostFunctionJbAtCurrentOptimum",
116 "CostFunctionJoAtCurrentOptimum",
119 "ForecastCovariance",
122 "InnovationAtCurrentAnalysis",
123 "InnovationAtCurrentState",
124 "SimulatedObservationAtCurrentAnalysis",
125 "SimulatedObservationAtCurrentOptimum",
126 "SimulatedObservationAtCurrentState",
129 self.defineRequiredParameter( # Pas de type
131 message = "Liste des valeurs de bornes",
133 self.requireInputArguments(
134 mandatory= ("Xb", "Y", "HO", "R", "B"),
135 optional = ("U", "EM", "CM", "Q"),
150 "ConvergenceOnStatic",
154 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
155 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
157 # --------------------------
158 if self._parameters["Variant"] in ["UKF", "UKF-Std"]:
159 ecwukf.ecwukf(self, Xb, Y, U, HO, EM, CM, R, B, Q, "UKF")
161 elif self._parameters["Variant"] == "S3F":
162 ecwukf.ecwukf(self, Xb, Y, U, HO, EM, CM, R, B, Q, "S3F")
164 elif self._parameters["Variant"] == "MSS":
165 ecwukf.ecwukf(self, Xb, Y, U, HO, EM, CM, R, B, Q, "MSS")
167 elif self._parameters["Variant"] == "5OS":
168 ecwukf.ecwukf(self, Xb, Y, U, HO, EM, CM, R, B, Q, "5OS")
170 # --------------------------
171 elif self._parameters["Variant"] in ["CUKF", "2UKF"]:
172 ecw2ukf.ecw2ukf(self, Xb, Y, U, HO, EM, CM, R, B, Q, "UKF")
174 elif self._parameters["Variant"] in ["CS3F", "2S3F"]:
175 ecw2ukf.ecw2ukf(self, Xb, Y, U, HO, EM, CM, R, B, Q, "S3F")
177 elif self._parameters["Variant"] in ["CMSS", "2MSS"]:
178 ecw2ukf.ecw2ukf(self, Xb, Y, U, HO, EM, CM, R, B, Q, "MSS")
180 elif self._parameters["Variant"] in ["C5OS", "25OS"]:
181 ecw2ukf.ecw2ukf(self, Xb, Y, U, HO, EM, CM, R, B, Q, "5OS")
183 # --------------------------
185 raise ValueError("Error in Variant name: %s"%self._parameters["Variant"])
187 self._post_run(HO, EM)
190 # ==============================================================================
191 if __name__ == "__main__":
192 print("\n AUTODIAGNOSTIC\n")