本文整理汇总了C++中beagle::Context::getDemeIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::getDemeIndex方法的具体用法?C++ Context::getDemeIndex怎么用?C++ Context::getDemeIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beagle::Context
的用法示例。
在下文中一共展示了Context::getDemeIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expand
/*!
* \brief Expand modules in trees of actual population.
* \param ioDeme Deme to apply operation.
* \param ioContext Evolutionary context.
*/
void GP::ModuleExpandOp::operate(Beagle::Deme& ioDeme, Beagle::Context& ioContext)
{
Beagle_StackTraceBeginM();
Beagle_LogTraceM(
ioContext.getSystem().getLogger(),
"EMA", "GP::ModuleExpandOp",
std::string("Expanding modules of the ")+
uint2ordinal(ioContext.getDemeIndex()+1)+" deme"
);
if(mExpandProba->getWrappedValue()==0.0) return;
Beagle_LogVerboseM(
ioContext.getSystem().getLogger(),
"EMA", "GP::ModuleExpandOp",
std::string("Expanding modules with probability ")+
dbl2str(mExpandProba->getWrappedValue())
);
GP::Context& lGPContext = castObjectT<GP::Context&>(ioContext);
GP::Individual::Handle lOldIndividualHandle = lGPContext.getIndividualHandle();
unsigned int lOldIndividualIndex = lGPContext.getIndividualIndex();
GP::Tree::Handle lOldGenotypeHandle = lGPContext.getGenotypeHandle();
unsigned int lOldGenotypeIndex = lGPContext.getGenotypeIndex();
const std::string lModuleName = mModulePrimitName->getWrappedValue();
for(unsigned int i=0; i<ioDeme.size(); i++) {
for(unsigned int j=0; j<ioDeme[i]->size(); ++j) {
GP::Tree& lTree = castObjectT<GP::Tree&>(*(*ioDeme[i])[j]);
for(unsigned int k=0; k<lTree.size(); ++k) {
if(lTree[k].mPrimitive->getName() == lModuleName) {
if(ioContext.getSystem().getRandomizer().rollUniform() <= mExpandProba->getWrappedValue()) {
lGPContext.setIndividualHandle(castHandleT<GP::Individual>(ioDeme[i]));
lGPContext.setIndividualIndex(i);
lGPContext.setGenotypeHandle(castHandleT<GP::Tree>((*ioDeme[i])[j]));
lGPContext.setGenotypeIndex(j);
Beagle_LogVerboseM(
ioContext.getSystem().getLogger(),
"expand", "ExpandOp",
std::string("Expanding the ") +uint2ordinal(i+1)+" individual"
);
expand(k, lTree, lGPContext);
}
}
}
}
}
lGPContext.setGenotypeHandle(lOldGenotypeHandle);
lGPContext.setGenotypeIndex(lOldGenotypeIndex);
lGPContext.setIndividualHandle(lOldIndividualHandle);
lGPContext.setIndividualIndex(lOldIndividualIndex);
Beagle_LogObjectDebugM(
ioContext.getSystem().getLogger(),
"EMA", "GP::ModuleExpandOp",
*(ioContext.getSystem().getComponent("ModuleVector"))
);
Beagle_StackTraceEndM();
}
示例2: maxOf
/*!
* \brief Calculate MCC statistics of a given deme.
* \param outStats Evaluated statistics.
* \param ioDeme Deme to evalute.
* \param ioContext Context of the evolution.
*
* The following statistics are calculated and made available in outStats:
* + mcc (as returned by FitnessMCC::getValue)
* + true-positives
* + false-positives
* + true-negatives
* + false-negatives
* + true-positives-relative
* + false-positives-relative
* + true-negatives-relative
* + false-negatives-relative
* + treedepth
* + treesize
*
*/
void GP::StatsCalcFitnessMCCOp::calculateStatsDeme(Beagle::Stats& outStats,
Beagle::Deme& ioDeme,
Beagle::Context& ioContext) const
{
Beagle_StackTraceBeginM();
outStats.clear();
outStats.clearItems();
outStats.addItem("processed", ioContext.getProcessedDeme());
outStats.addItem("total-processed", ioContext.getTotalProcessedDeme());
//std::cerr << ioDeme.size() << std::endl;
if(ioDeme.size() == 0) {
/*
* The deme does not contain any individuals.
* Set all statistics to 0.0.
*/
outStats.setGenerationValues(std::string("deme")+uint2str(ioContext.getDemeIndex()),
ioContext.getGeneration(), 0, true);
outStats.resize(11);
outStats[0].mID = "mcc";
outStats[0].mAvg = 0.0;
outStats[0].mStd = 0.0;
outStats[0].mMax = 0.0;
outStats[0].mMin = 0.0;
outStats[1].mID = "true-positives";
outStats[1].mAvg = 0.0;
outStats[1].mStd = 0.0;
outStats[1].mMax = 0.0;
outStats[1].mMin = 0.0;
outStats[2].mID = "false-positives";
outStats[2].mAvg = 0.0;
outStats[2].mStd = 0.0;
outStats[2].mMax = 0.0;
outStats[2].mMin = 0.0;
outStats[3].mID = "true-negatives";
outStats[3].mAvg = 0.0;
outStats[3].mStd = 0.0;
outStats[3].mMax = 0.0;
outStats[3].mMin = 0.0;
outStats[4].mID = "false-negatives";
outStats[4].mAvg = 0.0;
outStats[4].mStd = 0.0;
outStats[4].mMax = 0.0;
outStats[4].mMin = 0.0;
outStats[5].mID = "true-positives-relative";
outStats[5].mAvg = 0.0;
outStats[5].mStd = 0.0;
outStats[5].mMax = 0.0;
outStats[5].mMin = 0.0;
outStats[6].mID = "false-positives-relative";
outStats[6].mAvg = 0.0;
outStats[6].mStd = 0.0;
outStats[6].mMax = 0.0;
outStats[6].mMin = 0.0;
outStats[7].mID = "true-negatives-relative";
outStats[7].mAvg = 0.0;
outStats[7].mStd = 0.0;
outStats[7].mMax = 0.0;
outStats[7].mMin = 0.0;
outStats[8].mID = "false-negatives-relative";
outStats[8].mAvg = 0.0;
outStats[8].mStd = 0.0;
outStats[8].mMax = 0.0;
outStats[8].mMin = 0.0;
outStats[9].mID = "treedepth";
outStats[9].mAvg = 0.0;
outStats[9].mStd = 0.0;
outStats[9].mMax = 0.0;
//.........这里部分代码省略.........
示例3: maxOf
/*!
* \brief Calculate statistics of a given deme.
* \param outStats Evaluated statistics.
* \param ioDeme Deme to evalute the statistics.
* \param ioContext Context of the evolution.
*/
void GP::StatsCalcFitnessKozaOp::calculateStatsDeme(Beagle::Stats& outStats,
Beagle::Deme& ioDeme,
Beagle::Context& ioContext) const
{
Beagle_StackTraceBeginM();
outStats.clear();
outStats.clearItems();
outStats.addItem("processed", ioContext.getProcessedDeme());
outStats.addItem("total-processed", ioContext.getTotalProcessedDeme());
if(ioDeme.size() == 0) {
outStats.setGenerationValues(std::string("deme")+uint2str(ioContext.getDemeIndex()),
ioContext.getGeneration(), 0, true);
outStats.resize(7);
outStats[0].mID = "normalized";
outStats[0].mAvg = 0.0;
outStats[0].mStd = 0.0;
outStats[0].mMax = 0.0;
outStats[0].mMin = 0.0;
outStats[1].mID = "adjusted";
outStats[1].mAvg = 0.0;
outStats[1].mStd = 0.0;
outStats[1].mMax = 0.0;
outStats[1].mMin = 0.0;
outStats[2].mID = "standardized";
outStats[2].mAvg = 0.0;
outStats[2].mStd = 0.0;
outStats[2].mMax = 0.0;
outStats[2].mMin = 0.0;
outStats[3].mID = "raw";
outStats[3].mAvg = 0.0;
outStats[3].mStd = 0.0;
outStats[3].mMax = 0.0;
outStats[3].mMin = 0.0;
outStats[4].mID = "hits";
outStats[4].mAvg = 0.0;
outStats[4].mStd = 0.0;
outStats[4].mMax = 0.0;
outStats[4].mMin = 0.0;
outStats[5].mID = "treedepth";
outStats[5].mAvg = 0.0;
outStats[5].mStd = 0.0;
outStats[5].mMax = 0.0;
outStats[5].mMin = 0.0;
outStats[6].mID = "treesize";
outStats[6].mAvg = 0.0;
outStats[6].mStd = 0.0;
outStats[6].mMax = 0.0;
outStats[6].mMin = 0.0;
return;
}
const GP::Individual::Handle lFirstIndiv =
castHandleT<GP::Individual>(ioDeme[0]);
const GP::FitnessKoza::Handle lFirstIndivFitness =
castHandleT<GP::FitnessKoza>(lFirstIndiv->getFitness());
if(ioDeme.size() == 1) {
outStats.setGenerationValues(std::string("deme")+uint2str(ioContext.getDemeIndex()),
ioContext.getGeneration(), 1, true);
outStats.resize(7);
outStats[0].mID = "normalized";
outStats[0].mAvg = lFirstIndivFitness->getNormalizedFitness();
outStats[0].mStd = 0.0;
outStats[0].mMax = lFirstIndivFitness->getNormalizedFitness();
outStats[0].mMin = lFirstIndivFitness->getNormalizedFitness();
outStats[1].mID = "adjusted";
outStats[1].mAvg = lFirstIndivFitness->getAdjustedFitness();
outStats[1].mStd = 0.0;
outStats[1].mMax = lFirstIndivFitness->getAdjustedFitness();
outStats[1].mMin = lFirstIndivFitness->getAdjustedFitness();
outStats[2].mID = "standardized";
outStats[2].mAvg = lFirstIndivFitness->getStandardizedFitness();
outStats[2].mStd = 0.0;
outStats[2].mMax = lFirstIndivFitness->getStandardizedFitness();
outStats[2].mMin = lFirstIndivFitness->getStandardizedFitness();
outStats[3].mID = "raw";
outStats[3].mAvg = lFirstIndivFitness->getRawFitness();
outStats[3].mStd = 0.0;
outStats[3].mMax = lFirstIndivFitness->getRawFitness();
outStats[3].mMin = lFirstIndivFitness->getRawFitness();
//.........这里部分代码省略.........