From 09c7ff1c6bc292cc2f2b8a95cbeabd0a66f01115 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Sun, 4 May 2014 18:55:33 +0200 Subject: [PATCH] Adding observers test algorithm --- bin/AdaoCatalogGenerator.py | 1 + doc/en/reference.rst | 13 ++++ doc/fr/reference.rst | 14 ++++ src/daComposant/daAlgorithms/ObserverTest.py | 70 +++++++++++++++++++ .../daYacsSchemaCreator/infos_daComposant.py | 4 ++ 5 files changed, 102 insertions(+) create mode 100644 src/daComposant/daAlgorithms/ObserverTest.py diff --git a/bin/AdaoCatalogGenerator.py b/bin/AdaoCatalogGenerator.py index 8cc64c2..79c4054 100644 --- a/bin/AdaoCatalogGenerator.py +++ b/bin/AdaoCatalogGenerator.py @@ -214,6 +214,7 @@ CHECKING_STUDY = PROC(nom="CHECKING_STUDY", ObservationOperator = F_ObservationOperator("o"), AlgorithmParameters = F_AlgorithmParameters("f"), UserDataInit = F_Init("f"), + Observers = F_Observers("f") ) """ diff --git a/doc/en/reference.rst b/doc/en/reference.rst index 42a8c9a..0861af8 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -758,6 +758,7 @@ Optional and required commands for checking algorithms .. index:: single: FunctionTest .. index:: single: GradientTest .. index:: single: LinearityTest +.. index:: single: ObserverTest .. index:: single: AlgorithmParameters .. index:: single: AmplitudeOfInitialDirection @@ -911,6 +912,18 @@ for an ADAO checking case`_. 1000. By default, the seed is left uninitialized, and so use the default initialization from the computer. +**"ObserverTest"** + + *Required commands* + *"Observers"* + + *Tip for this command:* + Because *"CheckingPoint"* and *"ObservationOperator"* are required commands + for ALL checking algorithms in the interface, you have to provide a value + for them, despite the fact that these commands are not required for + *"ObserverTest"*, and will not be used. The easiest way is to give "1" as a + STRING for both, *"ObservationOperator"* having to be of type *Matrix*. + Requirements for functions describing an operator ------------------------------------------------- diff --git a/doc/fr/reference.rst b/doc/fr/reference.rst index ccc96fb..0993e46 100644 --- a/doc/fr/reference.rst +++ b/doc/fr/reference.rst @@ -795,6 +795,7 @@ Commandes optionnelles et requises pour les algorithmes de v .. index:: single: FunctionTest .. index:: single: GradientTest .. index:: single: LinearityTest +.. index:: single: ObserverTest .. index:: single: AlgorithmParameters .. index:: single: AmplitudeOfInitialDirection @@ -955,6 +956,19 @@ commandes et mots-cl par exemple 1000. Par défaut, la graine est laissée non initialisée, et elle utilise ainsi l'initialisation par défaut de l'ordinateur. +**"ObserverTest"** + + *Commandes obligatoires* + *"Observers"* + + *Astuce pour cette commande :* + Comme les commandes *"CheckingPoint"* et *"ObservationOperator"* sont + requises pour TOUS les algorithmes de vérification dans l'interface, vous + devez fournir une valeur, malgré le fait que ces commandes ne sont pas + requises pour *"ObserverTest"*, et ne seront pas utilisées. La manière la + plus simple est de donner "1" comme un STRING pour les deux, + l'*"ObservationOperator"* devant être de type *Matrix*. + Exigences pour les fonctions décrivant un opérateur --------------------------------------------------- diff --git a/src/daComposant/daAlgorithms/ObserverTest.py b/src/daComposant/daAlgorithms/ObserverTest.py new file mode 100644 index 0000000..20fc83c --- /dev/null +++ b/src/daComposant/daAlgorithms/ObserverTest.py @@ -0,0 +1,70 @@ +#-*-coding:iso-8859-1-*- +# +# Copyright (C) 2008-2014 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D + +import logging +from daCore import BasicObjects +import numpy + +# ============================================================================== +class ElementaryAlgorithm(BasicObjects.Algorithm): + def __init__(self): + BasicObjects.Algorithm.__init__(self, "OBSERVERTEST") + + def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None): + self._pre_run() + print "Results of observer check on all potential variables or commands," + print " only activated on selected ones by explicit association." + print + # + # Paramètres de pilotage + # ---------------------- + self.setParameters(Parameters) + # + __Xa = 1.+numpy.arange(3.) + __Xb = numpy.zeros(3) + __YY = 1.+numpy.arange(5.) + # + # Activation des observers sur toutes les variables stockables + # ------------------------------------------------------------ + self.StoredVariables["Analysis"].store( __Xa ) + self.StoredVariables["CurrentState"].store( __Xa ) + self.StoredVariables["CostFunctionJb"].store( 1. ) + self.StoredVariables["CostFunctionJo"].store( 2. ) + self.StoredVariables["CostFunctionJ" ].store( 3. ) + # + self.StoredVariables["APosterioriCovariance"].store( numpy.diag(__Xa) ) + self.StoredVariables["BMA"].store( __Xb - __Xa ) + self.StoredVariables["OMA"].store( __YY ) + self.StoredVariables["OMB"].store( __YY ) + self.StoredVariables["Innovation"].store( __YY ) + self.StoredVariables["SigmaObs2"].store( 1. ) + self.StoredVariables["SigmaBck2"].store( 1. ) + self.StoredVariables["MahalanobisConsistency"].store( 1. ) + self.StoredVariables["SimulationQuantiles"].store( numpy.matrix((__YY,__YY,__YY)) ) + # + print + self._post_run() + return 0 + +# ============================================================================== +if __name__ == "__main__": + print '\n AUTODIAGNOSTIC \n' diff --git a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py index 70336c5..326da38 100644 --- a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py +++ b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py @@ -75,6 +75,7 @@ CheckAlgos = [ "LinearityTest", "GradientTest", "AdjointTest", + "ObserverTest", ] AlgoDataRequirements = {} @@ -148,6 +149,9 @@ AlgoDataRequirements["AdjointTest"] = [ "CheckingPoint", "ObservationOperator", ] +AlgoDataRequirements["ObserverTest"] = [ + "Observers", + ] AlgoType = {} AlgoType["3DVAR"] = "Optim" -- 2.39.2