1 # Copyright (C) 2006-2014 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 class myalgosync(SALOMERuntime.OptimizerAlgSync):
24 SALOMERuntime.OptimizerAlgSync.__init__(self, None)
25 r=SALOMERuntime.getSALOMERuntime()
26 self.tin=r.getTypeCode("double")
27 self.tout=r.getTypeCode("int")
29 def setPool(self,pool):
30 """Must be implemented to set the pool"""
34 """returns typecode of type expected as Input"""
37 def getTCForOut(self):
38 """returns typecode of type expected as Output"""
41 def initialize(self,input):
42 """Optional method called on initialization. Do nothing here"""
45 """Start to fill the pool with samples to evaluate."""
47 self.pool.pushInSample(4,1.2)
48 self.pool.pushInSample(9,3.4)
50 def takeDecision(self):
51 """ This method is called each time a sample has been evaluated. It can either add
52 new samples to evaluate in the pool, do nothing (wait for more samples), or empty
53 the pool to finish the evaluation.
55 currentId=self.pool.getCurrentId()
58 self.pool.pushInSample(16,5.6)
59 self.pool.pushInSample(25,7.8)
60 self.pool.pushInSample(36,9.)
61 self.pool.pushInSample(49,12.3)
63 self.pool.pushInSample(64,45.6)
64 self.pool.pushInSample(81,78.9)
66 val=self.pool.getCurrentInSample()
67 if abs(val.getDoubleValue()-45.6) < 1.e-12:
68 self.pool.destroyAll()
72 """Optional method called when the algorithm has finished, successfully or not, to
73 perform any necessary clean up. Do nothing here"""