]> SALOME platform Git repositories - modules/adao.git/blob - test/test6902/Verification_des_Checking_Algorithms.py
Salome HOME
Minor print update (+ check git repos update)
[modules/adao.git] / test / test6902 / Verification_des_Checking_Algorithms.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2008-2019 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 sys
24 import unittest
25 import numpy
26 from adao import adaoBuilder
27
28 # ==============================================================================
29 class Test_Adao(unittest.TestCase):
30     def test1(self):
31         for algo in ("AdjointTest", "FunctionTest", "GradientTest", "LinearityTest", "TangentTest"):
32             print("")
33             msg = "Algorithme en test : %s"%algo
34             print(msg+"\n"+"-"*len(msg))
35             #
36             adaopy = adaoBuilder.New()
37             adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"EpsilonMinimumExponent":-10,"NumberOfRepetition":2, "SetSeed":1000})
38             adaopy.setCheckingPoint      (Vector = [0,1,2])
39             adaopy.setBackgroundError    (ScalarSparseMatrix = 1.)
40             adaopy.setObservation        (Vector = [0.5,1.5,2.5])
41             adaopy.setObservationError   (DiagonalSparseMatrix = "1 1 1")
42             adaopy.setObservationOperator(Matrix = "1 0 0;0 2 0;0 0 3")
43             adaopy.execute()
44             del adaopy
45         #
46         for algo in ("ObserverTest", ):
47             print("")
48             msg = "Algorithme en test : %s"%algo
49             print(msg+"\n"+"-"*len(msg))
50             #
51             adaopy = adaoBuilder.New()
52             adaopy.setAlgorithmParameters(Algorithm=algo)
53             adaopy.setCheckingPoint      (Vector = [0,1,2])
54             adaopy.setBackgroundError    (ScalarSparseMatrix = 1.)
55             adaopy.setObservation        (Vector = [0.5,1.5,2.5])
56             adaopy.setObservationError   (DiagonalSparseMatrix = "1 1 1")
57             adaopy.setObservationOperator(Matrix = "1 0 0;0 2 0;0 0 3")
58             adaopy.setObserver("Analysis",Template="ValuePrinter")
59             adaopy.execute()
60             del adaopy
61         #
62         for algo in ("SamplingTest", ):
63             print("")
64             msg = "Algorithme en test : %s"%algo
65             print(msg+"\n"+"-"*len(msg))
66             #
67             adaopy = adaoBuilder.New()
68             adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={
69                 "StoreSupplementaryCalculations":["CostFunctionJ","CurrentState",],
70                 "SampleAsMinMaxStepHyperCube":[[-1.,1.,1.],[0,2,1],[1,3,1]],
71                 })
72             adaopy.setCheckingPoint      (Vector = [0,1,2])
73             adaopy.setBackgroundError    (ScalarSparseMatrix = 1.)
74             adaopy.setObservation        (Vector = [0.5,1.5,2.5])
75             adaopy.setObservationError   (DiagonalSparseMatrix = "1 1 1")
76             adaopy.setObservationOperator(Matrix = "1 0 0;0 2 0;0 0 3")
77             adaopy.setObserver           ("CurrentState",Template="ValuePrinter")
78             adaopy.execute()
79             del adaopy
80
81 #===============================================================================
82 if __name__ == "__main__":
83     print("\nAUTODIAGNOSTIC\n==============")
84     sys.stderr = sys.stdout
85     unittest.main(verbosity=2)