From 967ce0a170eafb3c7ac3f734179099117a1eb2f1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Sun, 27 Dec 2020 07:46:24 +0100 Subject: [PATCH] Fix some coherency choices for *KF algorithms --- .../daAlgorithms/ExtendedKalmanFilter.py | 8 +++++--- src/daComposant/daAlgorithms/KalmanFilter.py | 7 +++++-- .../daAlgorithms/UnscentedKalmanFilter.py | 13 ++++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py index b243668..ee838c8 100644 --- a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py @@ -140,10 +140,12 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if self._toStore("APosterioriCovariance"): self.StoredVariables["APosterioriCovariance"].store( Pn.asfullmatrix(Xn.size) ) covarianceXa = Pn + if self._parameters["EstimationOf"] == "Parameters": + covarianceXaMin = Pn # - Xa = Xn - XaMin = Xn - previousJMinimum = numpy.finfo(float).max + if self._parameters["EstimationOf"] == "Parameters": + XaMin = Xn + previousJMinimum = numpy.finfo(float).max # for step in range(duration-1): if hasattr(Y,"store"): diff --git a/src/daComposant/daAlgorithms/KalmanFilter.py b/src/daComposant/daAlgorithms/KalmanFilter.py index eadb068..257cd26 100644 --- a/src/daComposant/daAlgorithms/KalmanFilter.py +++ b/src/daComposant/daAlgorithms/KalmanFilter.py @@ -131,9 +131,12 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if self._toStore("APosterioriCovariance"): self.StoredVariables["APosterioriCovariance"].store( Pn.asfullmatrix(Xn.size) ) covarianceXa = Pn + if self._parameters["EstimationOf"] == "Parameters": + covarianceXaMin = Pn # - Xa = Xn - previousJMinimum = numpy.finfo(float).max + if self._parameters["EstimationOf"] == "Parameters": + XaMin = Xn + previousJMinimum = numpy.finfo(float).max # for step in range(duration-1): if hasattr(Y,"store"): diff --git a/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py b/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py index 5af253c..4fa7d04 100644 --- a/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py @@ -102,7 +102,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): message = "Liste des valeurs de bornes", ) self.requireInputArguments( - mandatory= ("Xb", "Y", "HO", "R", "B" ), + mandatory= ("Xb", "Y", "HO", "R", "B"), optional = ("U", "EM", "CM", "Q"), ) self.setAttributes(tags=( @@ -178,14 +178,17 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): else: Pn = B # if len(self.StoredVariables["Analysis"])==0 or not self._parameters["nextStep"]: - self.StoredVariables["Analysis"].store( numpy.ravel(Xb) ) + self.StoredVariables["CurrentIterationNumber"].store( len(self.StoredVariables["Analysis"]) ) + self.StoredVariables["Analysis"].store( numpy.ravel(Xn) ) if self._toStore("APosterioriCovariance"): self.StoredVariables["APosterioriCovariance"].store( Pn ) covarianceXa = Pn + if self._parameters["EstimationOf"] == "Parameters": + covarianceXaMin = Pn # - Xa = Xb - XaMin = Xb - previousJMinimum = numpy.finfo(float).max + if self._parameters["EstimationOf"] == "Parameters": + XaMin = Xn + previousJMinimum = numpy.finfo(float).max # for step in range(duration-1): if hasattr(Y,"store"): -- 2.39.2