本文整理汇总了C++中Bool::getWrappedValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Bool::getWrappedValue方法的具体用法?C++ Bool::getWrappedValue怎么用?C++ Bool::getWrappedValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bool
的用法示例。
在下文中一共展示了Bool::getWrappedValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluate
/*!
* \brief Evaluate the individual fitness for the spambase problem.
* \param inIndividual Individual to evaluate.
* \param ioContext Evolutionary context.
* \return Handle to the fitness measure,
*/
Fitness::Handle SpambaseEvalOp::evaluate(GP::Individual& inIndividual, GP::Context& ioContext)
{
// Get reference to data set
DataSetClassification::Handle lDataSet =
castHandleT<DataSetClassification>(ioContext.getSystem().getComponent("DataSet"));
if(lDataSet == NULL) {
throw Beagle_RunTimeExceptionM("Data set is not present in the system, could not proceed further!");
}
// Generate indices used as data subset for fitness evaluation
std::vector<unsigned int> lSubSet(lDataSet->size());
for(unsigned int i=0; i<lSubSet.size(); ++i) lSubSet[i] = i;
std::random_shuffle(lSubSet.begin(), lSubSet.end(),
ioContext.getSystem().getRandomizer());
if(Spambase_TestSize < lSubSet.size()) {
lSubSet.resize(Spambase_TestSize);
}
// Evaluate sampled test cases
unsigned int lCorrectCount = 0;
for(unsigned int i=0; i<Spambase_TestSize; ++i) {
const bool lPositiveID = ((*lDataSet)[lSubSet[i]].first == 1);
const Beagle::Vector& lData = (*lDataSet)[lSubSet[i]].second;
for(unsigned int j=0; j<lData.size(); ++j) {
std::ostringstream lOSS;
lOSS << "IN" << j;
setValue(lOSS.str(), Double(lData[j]), ioContext);
}
Bool lResult;
inIndividual.run(lResult, ioContext);
if(lResult.getWrappedValue() == lPositiveID) ++lCorrectCount;
}
double lFitness = double(lCorrectCount) / Spambase_TestSize;
return new EC::FitnessSimple(lFitness);
}
示例2: evaluate
/*!
* \brief Evaluate the individual fitness for the even-6 parity problem.
* \param inIndividual Individual to evaluate.
* \param ioContext Evolutionary context.
* \return Handle to the fitness measure,
*/
Fitness::Handle ParityEvalOp::evaluate(GP::Individual& inIndividual, GP::Context& ioContext)
{
unsigned int lGood = 0;
for(unsigned int i=0; i<ParitySizeM; i++) {
for(unsigned int j=0; j<ParityFanInM; j++) {
std::string lName = "IN";
lName += uint2str(j);
setValue(lName, mInputs[i][j], ioContext);
}
Bool lResult;
inIndividual.run(lResult, ioContext);
if(lResult.getWrappedValue() == mOutputs[i].getWrappedValue()) lGood++;
}
double lFitness = double(lGood) / ParitySizeM;
return new FitnessSimple(lFitness);
}
示例3: evaluate
/*!
* \brief Evaluate the individual fitness for the boolean 11-multiplexer problem.
* \param inIndividual Individual to evaluate.
* \param ioContext Evolutionary context.
* \return Handle to the fitness measure,
*/
Fitness::Handle MultiplexerEvalOp::evaluate(GP::Individual& inIndividual, GP::Context& ioContext)
{
unsigned int lNbGood = 0;
for(unsigned int i=0; i<2048; ++i) {
setValue("A0", mInputs[i][0], ioContext);
setValue("A1", mInputs[i][1], ioContext);
setValue("A2", mInputs[i][2], ioContext);
setValue("D0", mInputs[i][3], ioContext);
setValue("D1", mInputs[i][4], ioContext);
setValue("D2", mInputs[i][5], ioContext);
setValue("D3", mInputs[i][6], ioContext);
setValue("D4", mInputs[i][7], ioContext);
setValue("D5", mInputs[i][8], ioContext);
setValue("D6", mInputs[i][9], ioContext);
setValue("D7", mInputs[i][10], ioContext);
Bool lResult;
inIndividual.run(lResult, ioContext);
if(lResult.getWrappedValue() == mOutputs[i].getWrappedValue()) ++lNbGood;
}
double lFitness = double(lNbGood) / 2048.;
return new EC::FitnessSimple(lFitness);
}