Salome HOME
Updating copyright date information and version
[modules/adao.git] / src / daComposant / daAlgorithms / ObserverTest.py
1 #-*-coding:iso-8859-1-*-
2 #
3 #  Copyright (C) 2008-2015 EDF R&D
4 #
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.
9 #
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.
14 #
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
18 #
19 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21 #  Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
22
23 import logging
24 from daCore import BasicObjects
25 import numpy
26
27 # ==============================================================================
28 class ElementaryAlgorithm(BasicObjects.Algorithm):
29     def __init__(self):
30         BasicObjects.Algorithm.__init__(self, "OBSERVERTEST")
31
32     def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
33         self._pre_run()
34         print "Results of observer check on all potential variables or commands,"
35         print "         only activated on selected ones by explicit association."
36         print
37         #
38         # Paramètres de pilotage
39         # ----------------------
40         self.setParameters(Parameters)
41         #
42         __Xa = 1.+numpy.arange(3.)
43         __Xb = numpy.zeros(3)
44         __YY = 1.+numpy.arange(5.)
45         #
46         # Activation des observers sur toutes les variables stockables
47         # ------------------------------------------------------------
48         self.StoredVariables["Analysis"].store( __Xa )
49         self.StoredVariables["CurrentState"].store( __Xa )
50         self.StoredVariables["CostFunctionJb"].store( 1. )
51         self.StoredVariables["CostFunctionJo"].store( 2. )
52         self.StoredVariables["CostFunctionJ" ].store( 3. )
53         #
54         self.StoredVariables["APosterioriCovariance"].store( numpy.diag(__Xa) )
55         self.StoredVariables["BMA"].store( __Xb - __Xa )
56         self.StoredVariables["OMA"].store( __YY )
57         self.StoredVariables["OMB"].store( __YY )
58         self.StoredVariables["Innovation"].store( __YY )
59         self.StoredVariables["SigmaObs2"].store( 1. )
60         self.StoredVariables["SigmaBck2"].store( 1. )
61         self.StoredVariables["MahalanobisConsistency"].store( 1. )
62         self.StoredVariables["SimulationQuantiles"].store( numpy.matrix((__YY,__YY,__YY)) )
63         #
64         print
65         self._post_run()
66         return 0
67
68 # ==============================================================================
69 if __name__ == "__main__":
70     print '\n AUTODIAGNOSTIC \n'