29 if(state->getCommunicator()->getCommRank() != MASTER)
35 voidP tsizep = state->getRegistry()->getEntry(
name_ +
".tsize");
36 nTournament = *((uint*) tsizep.get());
38 voidP jobSizeP = state->getRegistry()->getEntry(
name_ +
".jobsize");
39 jobSize = *((uint*) jobSizeP.get());
46 CommunicatorP comm = state->getCommunicator();
48 if(comm->getCommRank() == MASTER) {
50 std::vector<IndividualP> evalPool;
53 while(iIter < deme->size()) {
56 for(uint ind = 0; ind < jobSize && iIter < deme->size(); ind++, iIter++) {
57 std::vector<IndividualP> tournament;
58 for (uint i = 0; i < nTournament; ++i) {
59 tournament.push_back(
selectionOp[RANDOM]->select(*deme));
62 IndividualP worst =
selectionOp[WORST]->select(tournament);
65 crossover_->mate(tournament[0], tournament[1], worst);
67 std::vector<IndividualP> mutationPool;
68 mutationPool.push_back(worst);
71 if(
isMember(worst, evalPool) ==
false)
72 evalPool.push_back(worst);
79 comm->recvDemeFitness(*deme, Comm::ANY_PROCESS);
80 uint iWorker = comm->getLastSource();
82 comm->sendIndividuals(evalPool, iWorker);
103 uint remainingWorkers = comm->getCommSize() - 1;
104 while(remainingWorkers > 0) {
105 comm->recvDemeFitness(*deme, Comm::ANY_PROCESS);
106 uint iWorker = comm->getLastSource();
108 comm->sendIndividuals(evalPool, iWorker);
114 std::vector<IndividualP> empty;
116 comm->sendFitness(empty, MASTER);
119 myJobSize = comm->recvReplaceIndividuals(myJob, MASTER);
122 while(myJobSize > 0) {
123 for(uint i = 0; i < myJobSize; i++)
126 comm->sendFitness(myJob, MASTER, myJobSize);
128 myJobSize = comm->recvReplaceIndividuals(myJob, MASTER);