1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2019 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
26 from adao import adaoBuilder
28 # ==============================================================================
29 class Test_Adao(unittest.TestCase):
31 for algo in ("AdjointTest", "FunctionTest", "GradientTest", "LinearityTest", "TangentTest"):
33 msg = "Algorithme en test : %s"%algo
34 print(msg+"\n"+"-"*len(msg))
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")
46 for algo in ("ObserverTest", ):
48 msg = "Algorithme en test : %s"%algo
49 print(msg+"\n"+"-"*len(msg))
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")
62 for algo in ("SamplingTest", ):
64 msg = "Algorithme en test : %s"%algo
65 print(msg+"\n"+"-"*len(msg))
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]],
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")
81 #===============================================================================
82 if __name__ == "__main__":
83 print("\nAUTODIAGNOSTIC\n==============")
84 sys.stderr = sys.stdout
85 unittest.main(verbosity=2)