当前位置: 首页>>代码示例>>C++>>正文


C++ Bool::getWrappedValue方法代码示例

本文整理汇总了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);
}
开发者ID:GhostGambler,项目名称:beagle,代码行数:41,代码来源:SpambaseEvalOp.cpp

示例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);
}
开发者ID:splodginald,项目名称:MPI-PACC-OpenBeagle,代码行数:22,代码来源:ParityEvalOp.cpp

示例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);
}
开发者ID:GhostGambler,项目名称:beagle,代码行数:28,代码来源:MultiplexerEvalOp.cpp


注:本文中的Bool::getWrappedValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。