void Beagle::MPI::EvaluationOp::evolverOperate(Deme& ioDeme, Context& ioContext) { Beagle_LogTraceM( ioContext.getSystem().getLogger(), "evaluation", "Beagle::MPIEvaluationOp", std::string("Evaluating the individuals fitness of the ")+ uint2ordinal(ioContext.getDemeIndex()+1)+" deme" ); if(ioDeme.size() == 0) return; Individual::Handle lOldIndividualHandle = ioContext.getIndividualHandle(); unsigned int lOldIndividualIndex = ioContext.getIndividualIndex(); ioContext.setProcessedDeme(0); if((ioContext.getGeneration()!=0) && (ioDeme.getStats()->existItem("total-processed"))) { ioContext.setTotalProcessedDeme((unsigned int)ioDeme.getStats()->getItem("total-processed")); } else ioContext.setTotalProcessedDeme(0); ioDeme.getStats()->setInvalid(); if(ioContext.getDemeIndex()==0) { Stats& lVivaStats = *ioContext.getVivarium().getStats(); ioContext.setProcessedVivarium(0); if((ioContext.getGeneration()!=0) && (lVivaStats.existItem("total-processed"))) { ioContext.setTotalProcessedVivarium((unsigned int)lVivaStats.getItem("total-processed")); } else ioContext.setTotalProcessedVivarium(0); lVivaStats.setInvalid(); } distributeDemeEvaluation(ioDeme, ioContext); ioContext.setIndividualIndex(lOldIndividualIndex); ioContext.setIndividualHandle(lOldIndividualHandle); if(mDemeHOFSize->getWrappedValue() > 0) { Beagle_LogDetailedM( ioContext.getSystem().getLogger(), "evaluation", "Beagle::MPIEvaluationOp", "Updating the deme's hall-of-fame" ); ioDeme.getHallOfFame().updateWithDeme(mDemeHOFSize->getWrappedValue(), ioDeme, ioContext); ioDeme.getHallOfFame().log(Logger::eVerbose, ioContext); } if(mVivaHOFSize->getWrappedValue() > 0) { Beagle_LogDetailedM( ioContext.getSystem().getLogger(), "evaluation", "Beagle::MPIEvaluationOp", "Updating the vivarium's hall-of-fame" ); ioContext.getVivarium().getHallOfFame().updateWithDeme(mVivaHOFSize->getWrappedValue(), ioDeme, ioContext); ioContext.getVivarium().getHallOfFame().log(Logger::eVerbose, ioContext); } }
/*! * \brief Calculate the statistics of the current deme/generation. * \param ioDeme Actual deme of the evolution. * \param ioContext Context of the evolution. */ void StatsCalculateOp::operate(Deme& ioDeme, Context& ioContext) { Beagle_StackTraceBeginM(); Beagle_LogTraceM( ioContext.getSystem().getLogger(), "stats", "Beagle::StatsCalculateOp", string("Calculating stats for the ")+ uint2ordinal(ioContext.getDemeIndex()+1)+" deme" ); if(ioContext.getGeneration() != mGenerationCalculated) { mGenerationCalculated = ioContext.getGeneration(); mNbDemesCalculated = 0; } if(ioDeme.getStats() == NULL) { const Factory& lFactory = ioContext.getSystem().getFactory(); Stats::Alloc::Handle lStatsAlloc = castHandleT<Stats::Alloc>(lFactory.getConceptAllocator("Stats")); Stats::Handle lStats = castHandleT<Stats>(lStatsAlloc->allocate()); ioDeme.addMember(lStats); } if(ioDeme.getStats()->isValid() == false) { calculateStatsDeme(*ioDeme.getStats(), ioDeme, ioContext); ioDeme.getStats()->setValid(); } Beagle_LogObjectM( ioContext.getSystem().getLogger(), Logger::eStats, "stats", "Beagle::StatsCalculateOp", *ioDeme.getStats() ); if(++mNbDemesCalculated == mPopSize->size()) { Beagle_LogTraceM( ioContext.getSystem().getLogger(), "stats", "Beagle::StatsCalculateOp", "Calculating stats for the vivarium" ); if(ioContext.getVivarium().getStats() == NULL) { const Factory& lFactory = ioContext.getSystem().getFactory(); Stats::Alloc::Handle lStatsAlloc = castHandleT<Stats::Alloc>(lFactory.getConceptAllocator("Stats")); Stats::Handle lStats = castHandleT<Stats>(lStatsAlloc->allocate()); ioContext.getVivarium().addMember(lStats); } calculateStatsVivarium(*ioContext.getVivarium().getStats(), ioContext.getVivarium(), ioContext); ioContext.getVivarium().getStats()->setValid(); Beagle_LogObjectM( ioContext.getSystem().getLogger(), Logger::eStats, "stats", "Beagle::StatsCalculateOp", *ioContext.getVivarium().getStats() ); } Beagle_StackTraceEndM("void StatsCalculateOp::operate(Deme& ioDeme, Context& ioContext)"); }