(self)
This is the main method, is where the individuals
      are exchanged
This is the main method, is where the individuals
      are exchanged
This is the main method is where the individuals are exchanged
def exchange(self):
      """ This is the main method, is where the individuals
      are exchanged """

      if not self.isReady():
         return

      # Client section --------------------------------------
      # How many will migrate ?
      pool = self.selectPool(self.getNumIndividuals())

      for individual in pool:
         # (code, group name, individual)
         networkObject = (Consts.CDefNetworkIndividual, self.getGroupName(), individual)
         networkData = Network.pickleAndCompress(networkObject, self.getCompressionLevel())
         # Send the individuals to the topology
         self.clientThread.addData(networkData)

      # Server section --------------------------------------
      pool = []
      while self.serverThread.isReady():
         # (IP source, data)
         networkData = self.serverThread.popPool()
         networkObject = Network.unpickleAndDecompress(networkData[1])
         # (code, group name, individual)
         pool.append(networkObject)

      # No individuals received
      if len(pool) <= 0:
         return

      population = self.GAEngine.getPopulation()

      for i in xrange(self.getNumReplacement()):
         if len(pool) <= 0:
            break
         choice = rand_choice(pool)
         pool.remove(choice)

         # replace the worst
         population[len(population) - 1 - i] = choice[2]
def exchange ( self ) : if not self . isReady ( ) : return # Client section -------------------------------------- # How many will migrate ? pool = self . selectPool ( self . getNumIndividuals ( ) ) for individual in pool : # (code, group name, individual) networkObject = ( Consts . CDefNetworkIndividual , self . getGroupName ( ) , individual ) networkData = Network . pickleAndCompress ( networkObject , self . getCompressionLevel ( ) ) # Send the individuals to the topology self . clientThread . addData ( networkData ) # Server section -------------------------------------- pool = [ ] while self . serverThread . isReady ( ) : # (IP source, data) networkData = self . serverThread . popPool ( ) networkObject = Network . unpickleAndDecompress ( networkData [ 1 ] ) # (code, group name, individual) pool . append ( networkObject ) # No individuals received if len ( pool ) <= 0 : return population = self . GAEngine . getPopulation ( ) for i in xrange ( self . getNumReplacement ( ) ) : if len ( pool ) <= 0 : break choice = rand_choice ( pool ) pool . remove ( choice ) # replace the worst population [ len ( population ) - 1 - i ] = choice [ 2 ]