예제 #1
0
 def evaluate(self,pop,force = 0):
     #import tree
     #print '1',tree.ref()
     #only send the individuals out that need evaluation
     if force:
         _eval_list = pop.data
     else:
         _eval_list = filter(lambda x: not x.evaluated,pop)
     #print '2',tree.ref()
     eval_list = pop.clone()
     #print '3',tree.ref()
     eval_list.data = _eval_list
     if len(eval_list):
         Nserv = len(pop.server_list)
         groups = divide_list(eval_list,Nserv)
         #print '4',tree.ref()
         sys.setcheckinterval(10)
         finished = sync.event()
         bar = sync.barrier(Nserv)
         #print "EVAL LENGTH!!!", plen(pop.evaluator)
         gr = groups[0]
         print "GROUP LENGTH!!!", plen(groups[0]), len(gr),
         #print "IND!!!", plen(gr[0]),plen(gr[0].root)
         #print '4.5',tree.ref()
         for i in range(len(groups)):
             inputs = {'sub_pop':groups[i], 'evaluator':pop.evaluator, 'force':force}
             returns = ('sub_pop',)
             code = 'evaluator.evaluate(sub_pop,force)'
             data_pack = (inputs,returns,code)
             server = pop.server_list[i]
             thread.start_new_thread(remote_thread_eval,(bar,finished,server,data_pack))
         #print '7',tree.ref()
         finished.wait()
         sys.setcheckinterval(10)
예제 #2
0
 def evaluate(self,pop,settings = None):
 #only send the individuals out that need evaluation
     if len(pop):
         Nserv = len(pop.server_list)
         groups = divide_list(pop,Nserv)
         sys.setcheckinterval(10)
         finished = sync.event()
         bar = sync.barrier(Nserv)
         print '************',len(groups), len(pop.server_list), len(pop)
         for i in range(len(groups)):
             inputs = {'sub_pop':groups[i],'settings':settings, 'initializer':pop.initializer}
             returns = ('sub_pop',)
             code = 'initializer.evaluate(sub_pop,settings)'
             data_pack = (inputs,returns,code)
             server = pop.server_list[i]
             thread.start_new_thread(remote_thread_init,(bar,finished,server,data_pack))
         finished.wait()
         sys.setcheckinterval(10)
예제 #3
0
# Coroutine implementation using Python threads.
예제 #4
0
 def __init__(self, func):
     self.f = func
     self.e = sync.event()
예제 #5
0
 def __init__(self, func):
     self.f = func
     self.e = sync.event()
예제 #6
0
# Coroutine implementation using Python threads.