From 28338682467c902977355d5cb253b11046b21fa0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Ribes?= Date: Mon, 21 Jun 2010 16:47:19 +0200 Subject: [PATCH] Patch pour passage de daStudy dans le canal de l'Optimizer Loop --- .../daYacsIntegration/daOptimizerLoop.py | 26 ++++++++++++++----- src/daSalome/daYacsIntegration/daStudy.py | 5 +++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/daSalome/daYacsIntegration/daOptimizerLoop.py b/src/daSalome/daYacsIntegration/daOptimizerLoop.py index bace79c..1642171 100644 --- a/src/daSalome/daYacsIntegration/daOptimizerLoop.py +++ b/src/daSalome/daYacsIntegration/daOptimizerLoop.py @@ -6,6 +6,7 @@ import numpy import threading from daCore.AssimilationStudy import AssimilationStudy +import daStudy class OptimizerHooks: @@ -16,9 +17,9 @@ class OptimizerHooks: self.sample_counter = 0 self.counter_lock = threading.Lock() - def Direct(self, X, sync = true): + def Direct(self, X, sync = 1): print "Call Direct OptimizerHooks" - if sync == true: + if sync == 1: # 1: Get a unique sample number self.counter_lock.acquire() self.sample_counter += 1 @@ -53,9 +54,9 @@ class OptimizerHooks: print "sync false is not yet implemented" raise ValueError("sync == false not yet implemented") - def Tangent(self, X, sync = true): + def Tangent(self, X, sync = 1): print "Call Tangent OptimizerHooks" - if sync == true: + if sync == 1: # 1: Get a unique sample number self.counter_lock.acquire() self.sample_counter += 1 @@ -90,9 +91,9 @@ class OptimizerHooks: print "sync false is not yet implemented" raise ValueError("sync == false not yet implemented") - def Adjoint(self, (X, Y), sync = true): + def Adjoint(self, (X, Y), sync = 1): print "Call Adjoint OptimizerHooks" - if sync == true: + if sync == 1: # 1: Get a unique sample number self.counter_lock.acquire() self.sample_counter += 1 @@ -144,10 +145,18 @@ class AssimilationAlgorithm_asynch_3DVAR(SALOMERuntime.OptimizerAlgASync): def initialize(self,input): print "Algorithme initialize" + # get the daStudy + print "Input is ", input + str_da_study = input.getStringValue() + da_study = pickle.loads(str_da_study) + print "da_study is ", da_study + da_study.initAlgorithm() + self.ADD = da_study.getAssimilationStudy() + def startToTakeDecision(self): print "Algorithme startToTakeDecision" - TODO !! + #TODO !! precision = 1.e-13 dimension = 3 @@ -199,3 +208,6 @@ class AssimilationAlgorithm_asynch_3DVAR(SALOMERuntime.OptimizerAlgASync): return self.tin def getTCForOut(self): return self.tout + def getTCForAlgoInit(self): + return self.tin + diff --git a/src/daSalome/daYacsIntegration/daStudy.py b/src/daSalome/daYacsIntegration/daStudy.py index ad2cb8e..a54a928 100644 --- a/src/daSalome/daYacsIntegration/daStudy.py +++ b/src/daSalome/daYacsIntegration/daStudy.py @@ -14,7 +14,10 @@ class daStudy: self.ADD = AssimilationStudy(name) self.ADD.setControls() - self.ADD.setAlgorithm(choice="Blue") + self.algorithm = algorithm + + def initAlgorithm(): + self.ADD.setAlgorithm(choice=self.algorithm) def getAssimilationStudy(self): -- 2.39.2