3 class myalgosync(SALOMERuntime.OptimizerAlgSync):
5 SALOMERuntime.OptimizerAlgSync.__init__(self, None)
6 r=SALOMERuntime.getSALOMERuntime()
7 self.tin=r.getTypeCode("int")
8 self.tout=r.getTypeCode("int")
9 self.tAlgoInit=r.getTypeCode("int")
10 self.tAlgoResult=r.getTypeCode("int")
12 def setPool(self,pool):
13 """Must be implemented to set the pool"""
17 """return typecode of type expected as Input the internal node """
20 def getTCForOut(self):
21 """return typecode of type expected as Output the internal node"""
24 def getTCForAlgoInit(self):
25 """return typecode of type expected as input for initialize """
28 def getTCForAlgoResult(self):
29 """return typecode of type expected as output of the algorithm """
30 return self.tAlgoResult
32 def initialize(self,input):
33 """Optional method called on initialization.
34 The type of "input" is returned by "getTCForAlgoInit"
36 print "Algo initialize, input = ", input.getIntValue()
39 """Start to fill the pool with samples to evaluate."""
42 # pushInSample(id, value)
43 self.pool.pushInSample(self.iter, 1)
45 def takeDecision(self):
46 """ This method is called each time a sample has been evaluated. It can
47 either add new samples to evaluate in the pool, do nothing (wait for
48 more samples), or empty the pool to finish the evaluation.
50 currentId=self.pool.getCurrentId()
51 valIn = self.pool.getCurrentInSample().getIntValue()
52 valOut = self.pool.getCurrentOutSample().getIntValue()
53 print "Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut)
58 nextSample = valIn + 1
59 self.pool.pushInSample(self.iter, nextSample)
62 """Optional method called when the algorithm has finished, successfully
63 or not, to perform any necessary clean up."""
65 self.pool.destroyAll()
67 def getAlgoResult(self):
68 """return the result of the algorithm.
69 The object returned is of type indicated by getTCForAlgoResult.