本文整理汇总了C++中beagle::Context::getGeneration方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::getGeneration方法的具体用法?C++ Context::getGeneration怎么用?C++ Context::getGeneration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beagle::Context
的用法示例。
在下文中一共展示了Context::getGeneration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
//.........这里部分代码省略.........
示例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: lArrayA
//.........这里部分代码省略.........
std::copy(lCt.begin(), lCt.end(), lValueC);
mwArray lArrayC(lCt.getCols(),lCt.getRows(), mxDOUBLE_CLASS, mxREAL);
lArrayC.SetData(lValueC,lCt.size());
double *lValueD = new double[lDt.size()];
std::copy(lDt.begin(), lDt.end(), lValueD);
mwArray lArrayD(lDt.getCols(),lDt.getRows(), mxDOUBLE_CLASS, mxREAL);
lArrayD.SetData(lValueD,lDt.size());
// Create output array
mwArray loutArray;
// Call the library function
AnalogFilterEval(1, loutArray, lArrayA, lArrayB, lArrayC,lArrayD);
// Extract the output
int lNbOutput = loutArray.NumberOfElements();
double* loutValues = new double[lNbOutput];
loutArray.GetData(loutValues, lNbOutput);
// Bundle the fitness
lFitness->setValue(loutValues[0]);
delete [] lValueA;
delete [] lValueB;
delete [] lValueC;
delete [] lValueD;
delete [] loutValues;
#else
lFitness->setValue(ioContext.getSystem().getRandomizer().getFloat());
#endif
}
}
catch (const mwException& inException) {
std::cerr << inException.what() << std::endl;
PACC::Matrix lA,lB,lB2,lC,lD,lD2;
lBondGraph->getStateMatrix(lA,lB,lB2);
lBondGraph->getOutputMatrix(lC,lD,lD2);
PACC::XML::Streamer lStream(cerr);
lA.write(lStream);
cerr << endl;
lB.write(lStream);
cerr << endl;
lC.write(lStream);
cerr << endl;
lD.write(lStream);
cerr << endl;
//Save bond graph for debuging
std::ostringstream lFilename;
lFilename << "bug/bondgraph_bug_" << ioContext.getGeneration() << "_" << ioContext.getIndividualIndex();
#ifndef WITHOUT_GRAPHVIZ
lBondGraph->plotGraph(lFilename.str()+std::string(".svg"));
#endif
ofstream lFileStream((lFilename.str()+std::string(".xml")).c_str());
PACC::XML::Streamer lStreamer(lFileStream);
lBondGraph->write(lStreamer);
#ifdef STOP_ON_ERROR
exit(EXIT_FAILURE);
#endif
}
catch(std::runtime_error inError) {
std::cerr << "Error catched while evaluating the bond graph: " << inError.what() << std::endl;
//Save bond graph for debuging
std::ostringstream lFilename;
lFilename << "bug/bondgraph_bug_" << ioContext.getGeneration() << "_" << ioContext.getIndividualIndex();
#ifndef WITHOUT_GRAPHVIZ
lBondGraph->plotGraph(lFilename.str()+std::string(".svg"));
#endif
ofstream lFileStream((lFilename.str()+std::string(".xml")).c_str());
PACC::XML::Streamer lStreamer(lFileStream);
lBondGraph->write(lStreamer);
//Assign null fitness
lFitness->setValue(0);
#ifdef XMLBEAGLE
XMLStreamer lStreamer2(std::cout);
inIndividual.write(lStreamer2);
#else
inIndividual.write(lStreamer);
#endif
#ifdef STOP_ON_ERROR
exit(EXIT_FAILURE);
#endif
}
//delete lBondGraph;
return lFitness;
}
开发者ID:ComputationalIntelligenceAndMechatronics,项目名称:HBGGP,代码行数:101,代码来源:AnalogFilterParameterEvalOp.cpp