Salome HOME
Aller Ok pour test017 i
authorAndré Ribes <andre.ribes@edf.fr>
Fri, 1 Apr 2011 08:02:34 +0000 (10:02 +0200)
committerAndré Ribes <andre.ribes@edf.fr>
Fri, 1 Apr 2011 08:02:34 +0000 (10:02 +0200)
(reste à faire lorsqu'il y a plusieurs variables)

src/daSalome/daYacsIntegration/daOptimizerLoop.py
src/tests/daSalome/test017_3DVAR_function_script.py

index edf727efc41da7c9807e8e28db21429546aa9419..dfa5a4f114faf1ed8346a61a668fd51f90bbc272 100644 (file)
@@ -39,20 +39,29 @@ class OptimizerHooks:
 
     # Les données
     # TODO à faire
-    parameter_1D = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
     #print data
     #print data.ndim
     #print data.shape
     #print data[:,0]
     #print data.flatten()
     #print data.flatten().shape
-    it = data.flat
-    for val in it:
-      print val
-      parameter_1D.pushBack(val)
+
+    parameter_1D = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
     parameter_2D = pilot.SequenceAny_New(parameter_1D.getType())
-    parameter_2D.pushBack(parameter_1D)
     parameters_3D = pilot.SequenceAny_New(parameter_2D.getType())
+    if isinstance(data, type((1,2))):
+      for dat in data:
+        param = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
+        it = dat.flat
+        for val in it:
+          param.pushBack(val)
+        parameter_2D.pushBack(param)
+    else:
+      param = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
+      it = data.flat
+      for val in it:
+        param.pushBack(val)
+      parameter_2D.pushBack(param)
     parameters_3D.pushBack(parameter_2D)
     sample.setEltAtRank("inputValues", parameters_3D)
 
@@ -95,7 +104,7 @@ class OptimizerHooks:
             return Y
     else:
       print "sync false is not yet implemented"
-      raise daStudy.daError("sync == false not yet implemented")
+      self.optim_algo.setError("sync == false not yet implemented")
 
   def Tangent(self, X, sync = 1):
     print "Call Tangent OptimizerHooks"
@@ -132,7 +141,7 @@ class OptimizerHooks:
             return Y
     else:
       print "sync false is not yet implemented"
-      raise daStudy.daError("sync == false not yet implemented")
+      self.optim_algo.setError("sync == false not yet implemented")
 
   def Adjoint(self, (X, Y), sync = 1):
     print "Call Adjoint OptimizerHooks"
@@ -143,7 +152,7 @@ class OptimizerHooks:
       local_counter = self.sample_counter
 
       # 2: Put sample in the job pool
-      sample = self.create_sample(Y, "Tangent")
+      sample = self.create_sample((X,Y), "Adjoint")
       self.optim_algo.pool.pushInSample(local_counter, sample)
 
       # 3: Wait
@@ -171,7 +180,7 @@ class OptimizerHooks:
             return Z
     else:
       print "sync false is not yet implemented"
-      raise daStudy.daError("sync == false not yet implemented")
+      self.optim_algo.setError("sync == false not yet implemented")
 
 class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync):
 
index ce55cca42901d999bd921ba7fa666b2f9a43413a..09f2e4ca035a37f11aa7ef5dd52f63f5fa95f22c 100644 (file)
@@ -7,8 +7,6 @@ for param in computation["specificParameters"]:
   if param["name"] == "method":
     method = param["value"]
 print "Method found is", method
-print computation["inputValues"]
-print computation["inputValues"][0][0]
 
 dimension = 300
 H  = numpy.matrix(numpy.core.identity(dimension))
@@ -26,6 +24,6 @@ if method == "Tangent":
   result = FunctionH(numpy.matrix(computation["inputValues"][0][0]).T)
 
 if method == "Adjoint":
-  result = AdjointH(numpy.matrix(computation["inputValues"][0][0]).T)
+  result = AdjointH((numpy.matrix(computation["inputValues"][0][0]).T, numpy.matrix(computation["inputValues"][0][1]).T))
 
 print "Computation end"