]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Nouveau test Aster LBFGSB
authorAndré Ribes <andre.ribes@edf.fr>
Fri, 2 Jul 2010 09:25:23 +0000 (11:25 +0200)
committerAndré Ribes <andre.ribes@edf.fr>
Fri, 2 Jul 2010 09:25:23 +0000 (11:25 +0200)
configure.ac
src/daSalome/daYacsSchemaCreator/methods.py
src/tests/daSalome/Makefile.am
src/tests/daSalome/test_aster_zzzz159a.py.in
src/tests/daSalome/test_aster_zzzz159a_LBFGSB.py.in [new file with mode: 0644]
src/tests/daSalome/test_aster_zzzz159a_init_algorithm_LBFGSB.py [new file with mode: 0644]

index a7fe04e9c69cd2bf211cf89d4700fedcc4ebd103..5b235e56b24db9e6cfade986932588f99c5235cc 100644 (file)
@@ -118,6 +118,7 @@ AC_CONFIG_FILES([
         src/tests/daSalome/test017_3DVAR_par_fonction.py
         src/tests/daSalome/test_aster_zzzz159a_init_parameters.py
         src/tests/daSalome/test_aster_zzzz159a.py
+        src/tests/daSalome/test_aster_zzzz159a_LBFGSB.py
         src/tests/daSalome/zzzz159a.export.esclave
         src/tests/daComposant/Makefile
         src/tests/daComposant/Plateforme/Makefile
index c4f8eef89e8d62725271e3cb8009fec50b9c2b71..5f5b9674429749bdab975d81e2483e26e621dcce 100644 (file)
@@ -254,6 +254,11 @@ def create_yacs_proc(study_config):
       else:
         proc.edAddDFLink(execute_node.getOutputPort("Study"), analysis_node.getInputPort("Study"))
 
+      # Connect node with InitUserData
+      if "Analysis" in init_config["Target"]:
+        analysis_node.edAddInputPort("init_data", t_pyobj)
+        proc.edAddDFLink(init_node.getOutputPort("init_data"), analysis_node.getInputPort("init_data"))
+
     elif analysis_config["From"] == "File":
       factory_analysis_node = catalogAd._nodeMap["SimpleUserAnalysis"]
       analysis_node = factory_analysis_node.cloneNode("User Analysis")
@@ -276,6 +281,10 @@ def create_yacs_proc(study_config):
         proc.edAddDFLink(optimizer_node.edGetAlgoResultPort(), analysis_node.getInputPort("Study"))
       else:
         proc.edAddDFLink(execute_node.getOutputPort("Study"), analysis_node.getInputPort("Study"))
+      # Connect node with InitUserData
+      if "Analysis" in init_config["Target"]:
+        analysis_node.edAddInputPort("init_data", t_pyobj)
+        proc.edAddDFLink(init_node.getOutputPort("init_data"), analysis_node.getInputPort("init_data"))
 
       pass
 
index 52e5ececeb373643d611f2d46680dcec1cddf555..b3b1f65a1fe98047a7c9cfd6737d802c3990157b 100644 (file)
@@ -12,6 +12,8 @@ DATA_INST = \
            test_aster_zzzz159a_init_algorithm.py \
            test_aster_zzzz159a_init_parameters.py \
            test_aster_zzzz159a.py \
+           test_aster_zzzz159a_LBFGSB.py \
+           test_aster_zzzz159a_init_algorithm_LBFGSB.py \
            zzzz159a.3  zzzz159a.export.esclave  zzzz159a.mail
 
 testsdasalome_DATA = ${DATA_INST}
@@ -27,4 +29,6 @@ EXTRA_DIST = test000_Blue_AnalysisCode.py test000_Blue_AnalysisFile.py.in test00
             test_aster_zzzz159a_init_algorithm.py \
             test_aster_zzzz159a_init_parameters.py.in \
             test_aster_zzzz159a.py.in \
+            test_aster_zzzz159a_LBFGSB.py.in \
+            test_aster_zzzz159a_init_algorithm_LBFGSB.py \
             zzzz159a.3  zzzz159a.export.esclave.in  zzzz159a.mail
index 98246f32c8b96b74866aa5c21adda2fde988f01d..6b6109b84e4caa876e782bdc6227517ba9a43c4d 100644 (file)
@@ -8,7 +8,7 @@ Init_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_paramete
 Init_config["Type"] = "Dict"
 Init_config["From"] = "Script"
 Init_config["Target"] = ["AlgorithmParameters", "Background", "BackgroundError",
-    "Observation", "ObservationError", "ObservationOperator"]
+    "Observation", "ObservationError", "ObservationOperator", "Analysis"]
 study_config["Init"] = Init_config
 
 Algorithm_config = {}
@@ -57,8 +57,63 @@ Analysis_config = {}
 Analysis_config["Data"] = """
 import numpy
 
-Xa = ADD.get("Analysis").valueserie(0)
-print "Analyse = ",Xa
+xa = ADD.get("Analysis").valueserie(0)
+Innovation = ADD.get("Innovation").valueserie(0)
+A = []
+J = ADD.get("CostFunctionJ").valueserie()
+#
+ADD.setDiagnostic("PlotVectors", "J")
+MonPlot = ADD.get("J")
+MonPlot.calculate([J,ADD.get("CostFunctionJb").valueserie(),ADD.get("CostFunctionJo").valueserie()],
+    title = "Fonctionnelles J, Jb et Jo",
+    ltitle = ["J","Jb","Jo"],
+    xlabel = "Pas", ylabel = "Valeur",
+    filename = "recherche_xx_Fonctionnelles.ps",
+    pause = False )
+
+
+nbmesures = 11 # De 0 à 1 par pas de 0.1
+instants = numpy.array([0.1*i for i in range(nbmesures)])
+yo = []
+for reponse in init_data['experience']:
+    for t,v in list(reponse):
+        if min(abs(t - instants)) < 1.e-8:
+            yo.append(v)
+xb = []
+Bornes = []
+for parametre in init_data['parametres']:
+    xb.append( parametre[1] )
+    Bornes.append( parametre[2:4] )
+B  = numpy.matrix(numpy.core.identity(len(xb)))
+alpha  = 1.e14
+B[0,0] = alpha * 100
+B[1,1] = alpha * 10
+B[2,2] = alpha * 1
+
+# Calcul de la RMS
+# ----------------
+import test_aster_zzzz159a_aster_functions as Code_Aster
+Hxa = Code_Aster.Calcul_Aster_Ponctuel( xa )
+V1 = numpy.array(Hxa)
+V2 = numpy.array(yo)
+import math
+rms = math.sqrt( ((V2 - V1)**2).sum() / float(V1.size) )
+
+print
+print "========="
+print "Ebauche = ",xb
+print "Analyse = ",xa
+print "RMS     = ",rms
+print
+print "NbSteps = ",len(J)
+print "J       = ",J
+print
+print "B[0,0]  = ",B[0,0]
+print "B[1,1]  = ",B[1,1]
+print "B[2,2]  = ",B[2,2]
+print "Bornes  = ",Bornes
+print "========="
+print
 """
 Analysis_config["From"] = "String"
 study_config["Analysis"] = Analysis_config
diff --git a/src/tests/daSalome/test_aster_zzzz159a_LBFGSB.py.in b/src/tests/daSalome/test_aster_zzzz159a_LBFGSB.py.in
new file mode 100644 (file)
index 0000000..04bfd0e
--- /dev/null
@@ -0,0 +1,119 @@
+#-*-coding:iso-8859-1-*-
+study_config = {}
+study_config["Name"] = "test_aster_zzzz159a"
+study_config["Algorithm"] = "3DVAR"
+
+Init_config = {}
+Init_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_parameters.py"
+Init_config["Type"] = "Dict"
+Init_config["From"] = "Script"
+Init_config["Target"] = ["AlgorithmParameters", "Background", "BackgroundError",
+    "Observation", "ObservationError", "ObservationOperator", "Analysis"]
+study_config["Init"] = Init_config
+
+Algorithm_config = {}
+Algorithm_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_algorithm_LBFGSB.py"
+Algorithm_config["Type"] = "Dict"
+Algorithm_config["From"] = "Script"
+study_config["AlgorithmParameters"] = Algorithm_config
+
+Background_config = {}
+Background_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background.py"
+Background_config["Type"] = "Vector"
+Background_config["From"] = "Script"
+study_config["Background"] = Background_config
+
+BackgroundError_config = {}
+BackgroundError_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background_error.py"
+BackgroundError_config["Type"] = "Matrix"
+BackgroundError_config["From"] = "Script"
+study_config["BackgroundError"] = BackgroundError_config
+
+Observation_config = {}
+Observation_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_observation.py"
+Observation_config["Type"] = "Vector"
+Observation_config["From"] = "Script"
+study_config["Observation"] = Observation_config
+
+ObservationError_config = {}
+ObservationError_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_observation_error.py"
+ObservationError_config["Type"] = "Matrix"
+ObservationError_config["From"] = "Script"
+study_config["ObservationError"] = ObservationError_config
+
+FunctionDict = {}
+FunctionDict["Function"] = ["Direct", "Tangent", "Adjoint"]
+FunctionDict["Script"] = {}
+FunctionDict["Script"]["Direct"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
+FunctionDict["Script"]["Tangent"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
+FunctionDict["Script"]["Adjoint"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
+ObservationOperator_config = {}
+ObservationOperator_config["Data"] = FunctionDict
+ObservationOperator_config["Type"] = "Function"
+ObservationOperator_config["From"] = "Dict"
+study_config["ObservationOperator"] = ObservationOperator_config
+
+Analysis_config = {}
+Analysis_config["Data"] = """
+import numpy
+
+xa = ADD.get("Analysis").valueserie(0)
+Innovation = ADD.get("Innovation").valueserie(0)
+A = []
+J = ADD.get("CostFunctionJ").valueserie()
+#
+ADD.setDiagnostic("PlotVectors", "J")
+MonPlot = ADD.get("J")
+MonPlot.calculate([J,ADD.get("CostFunctionJb").valueserie(),ADD.get("CostFunctionJo").valueserie()],
+    title = "Fonctionnelles J, Jb et Jo",
+    ltitle = ["J","Jb","Jo"],
+    xlabel = "Pas", ylabel = "Valeur",
+    filename = "recherche_xx_Fonctionnelles.ps",
+    pause = False )
+
+
+nbmesures = 11 # De 0 à 1 par pas de 0.1
+instants = numpy.array([0.1*i for i in range(nbmesures)])
+yo = []
+for reponse in init_data['experience']:
+    for t,v in list(reponse):
+        if min(abs(t - instants)) < 1.e-8:
+            yo.append(v)
+xb = []
+Bornes = []
+for parametre in init_data['parametres']:
+    xb.append( parametre[1] )
+    Bornes.append( parametre[2:4] )
+B  = numpy.matrix(numpy.core.identity(len(xb)))
+alpha  = 1.e14
+B[0,0] = alpha * 100
+B[1,1] = alpha * 10
+B[2,2] = alpha * 1
+
+# Calcul de la RMS
+# ----------------
+import test_aster_zzzz159a_aster_functions as Code_Aster
+Hxa = Code_Aster.Calcul_Aster_Ponctuel( xa )
+V1 = numpy.array(Hxa)
+V2 = numpy.array(yo)
+import math
+rms = math.sqrt( ((V2 - V1)**2).sum() / float(V1.size) )
+
+print
+print "========="
+print "Ebauche = ",xb
+print "Analyse = ",xa
+print "RMS     = ",rms
+print
+print "NbSteps = ",len(J)
+print "J       = ",J
+print
+print "B[0,0]  = ",B[0,0]
+print "B[1,1]  = ",B[1,1]
+print "B[2,2]  = ",B[2,2]
+print "Bornes  = ",Bornes
+print "========="
+print
+"""
+Analysis_config["From"] = "String"
+study_config["Analysis"] = Analysis_config
diff --git a/src/tests/daSalome/test_aster_zzzz159a_init_algorithm_LBFGSB.py b/src/tests/daSalome/test_aster_zzzz159a_init_algorithm_LBFGSB.py
new file mode 100644 (file)
index 0000000..68fd1f0
--- /dev/null
@@ -0,0 +1,15 @@
+debug = init_data["debug"]
+parametres = init_data["parametres"]
+
+Bornes = []
+for parametre in parametres:
+    Bornes.append(parametre[2:4])
+
+if debug:
+    print
+    print "Bornes  = ",Bornes
+    print
+
+AlgorithmParameters = { "Minimizer"           : "LBFSGB",
+    "Bounds"              : Bornes,
+    }