Salome HOME
Test extension for checking algorithms
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Tue, 31 Jan 2017 07:12:35 +0000 (08:12 +0100)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Tue, 31 Jan 2017 07:12:35 +0000 (08:12 +0100)
src/daComposant/daCore/PlatformInfo.py
test/CTestTestfileInstall.cmake.in
test/Makefile.am
test/test6902/CTestTestfile.cmake [new file with mode: 0644]
test/test6902/Verification_des_Checking_Algorithms.py [new file with mode: 0644]

index 14792d77ffe3fa10849f73bbc8b400eec7231ee4..0858883248231ffd962494980d050c5431d4efe6 100644 (file)
@@ -142,6 +142,13 @@ class PlatformInfo(object):
         return "%s %s (%s)"%(dav.name,dav.version,dav.date)
 
 # ==============================================================================
+try:
+    import scipy
+    import scipy.optimize
+    has_scipy = True
+except ImportError:
+    has_scipy = False
+
 try:
     import matplotlib
     has_matplotlib = True
index d786c259ee4793b4d5a0891832a9ff0c93ba9e30..4fe93a419cc43d1ac7fe6868ddfebfd607c06a20 100644 (file)
@@ -32,4 +32,5 @@ SUBDIRS(
     test6702
     test6703
     test6901
+    test6902
     )
index 473ae3e1cdf691af9f8de5940761ee68a6407893..3d286aae5a2aabbc103893fcffb3c0cca3f6d1a4 100644 (file)
@@ -35,6 +35,7 @@ install-data-local:
        cp -R $(DIR)test6702 $(SALOMETESTDIR)
        cp -R $(DIR)test6703 $(SALOMETESTDIR)
        cp -R $(DIR)test6901 $(SALOMETESTDIR)
+       cp -R $(DIR)test6902 $(SALOMETESTDIR)
        cp    $(DIR)CTestTestfileInstall.cmake.in $(SALOMETESTDIR)/CTestTestfile.cmake
 
 uninstall-local:
@@ -45,4 +46,5 @@ uninstall-local:
        rm -rf $(SALOMETESTDIR)/test6702
        rm -rf $(SALOMETESTDIR)/test6703
        rm -rf $(SALOMETESTDIR)/test6901
+       rm -rf $(SALOMETESTDIR)/test6902
        rm     $(SALOMETESTDIR)/CTestTestfile.cmake
diff --git a/test/test6902/CTestTestfile.cmake b/test/test6902/CTestTestfile.cmake
new file mode 100644 (file)
index 0000000..41533e5
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (C) 2008-2017 EDF R&D
+#
+# This file is part of SALOME ADAO module
+#
+# 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, or (at your option) any later version.
+#
+# 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
+#
+
+SET(TEST_NAMES
+  Verification_des_Checking_Algorithms
+  )
+
+FOREACH(tfile ${TEST_NAMES})
+  SET(TEST_NAME ADAO_${tfile})
+  ADD_TEST(${TEST_NAME} python ${tfile}.py)
+  #ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}.py)
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
+ENDFOREACH()
diff --git a/test/test6902/Verification_des_Checking_Algorithms.py b/test/test6902/Verification_des_Checking_Algorithms.py
new file mode 100644 (file)
index 0000000..63a331a
--- /dev/null
@@ -0,0 +1,80 @@
+#-*-coding:iso-8859-1-*-
+#
+# Copyright (C) 2008-2017 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 adaoBuilder
+
+# ==============================================================================
+def test1():
+    for algo in ("AdjointTest", "FunctionTest", "GradientTest", "LinearityTest", "TangentTest"):
+        print
+        msg = "Algorithme en test : %s"%algo
+        print msg+"\n"+"-"*len(msg)
+        #
+        adaopy = adaoBuilder.New()
+        adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"EpsilonMinimumExponent":-10,"NumberOfRepetition":2, "SetSeed":1000})
+        adaopy.setCheckingPoint      (Vector = [0,1,2])
+        adaopy.setBackgroundError    (ScalarSparseMatrix = 1.)
+        adaopy.setObservation        (Vector = [0.5,1.5,2.5])
+        adaopy.setObservationError   (DiagonalSparseMatrix = "1 1 1")
+        adaopy.setObservationOperator(Matrix = "1 0 0;0 2 0;0 0 3")
+        adaopy.execute()
+        del adaopy
+    #
+    for algo in ("ObserverTest", ):
+        print
+        msg = "Algorithme en test : %s"%algo
+        print msg+"\n"+"-"*len(msg)
+        #
+        adaopy = adaoBuilder.New()
+        adaopy.setAlgorithmParameters(Algorithm=algo)
+        adaopy.setCheckingPoint      (Vector = [0,1,2])
+        adaopy.setBackgroundError    (ScalarSparseMatrix = 1.)
+        adaopy.setObservation        (Vector = [0.5,1.5,2.5])
+        adaopy.setObservationError   (DiagonalSparseMatrix = "1 1 1")
+        adaopy.setObservationOperator(Matrix = "1 0 0;0 2 0;0 0 3")
+        adaopy.setObserver("Analysis",Template="ValuePrinter")
+        adaopy.execute()
+        del adaopy
+    #
+    for algo in ("SamplingTest", ):
+        print
+        msg = "Algorithme en test : %s"%algo
+        print msg+"\n"+"-"*len(msg)
+        #
+        adaopy = adaoBuilder.New()
+        adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={
+            "StoreSupplementaryCalculations":["CostFunctionJ","CurrentState",],
+            "SampleAsMinMaxStepHyperCube":[[-1.,1.,1.],[0,2,1],[1,3,1]],
+            })
+        adaopy.setCheckingPoint      (Vector = [0,1,2])
+        adaopy.setBackgroundError    (ScalarSparseMatrix = 1.)
+        adaopy.setObservation        (Vector = [0.5,1.5,2.5])
+        adaopy.setObservationError   (DiagonalSparseMatrix = "1 1 1")
+        adaopy.setObservationOperator(Matrix = "1 0 0;0 2 0;0 0 3")
+        adaopy.setObserver           ("CurrentState",Template="ValuePrinter")
+        adaopy.execute()
+        del adaopy
+
+# ==============================================================================
+if __name__ == "__main__":
+    print '\n AUTODIAGNOSTIC \n'
+    test1()