本文整理汇总了C++中Chromosome::convertGenesToDecimals方法的典型用法代码示例。如果您正苦于以下问题:C++ Chromosome::convertGenesToDecimals方法的具体用法?C++ Chromosome::convertGenesToDecimals怎么用?C++ Chromosome::convertGenesToDecimals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chromosome
的用法示例。
在下文中一共展示了Chromosome::convertGenesToDecimals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decimals
boost::shared_ptr<double> LCEBEvaluation::evaluate(Chromosome const & chr)const {
int length = chr.numberOfGenes();
boost::scoped_array<int> decimals(new int[length]);
chr.convertGenesToDecimals(decimals.get());
boost::shared_ptr<double> res;
if (!isValidSequence(decimals.get()))
return res;
/*std::stack<double> operands;
for(int i = 0; i < length; ++i){
int index = decimals[i];
int nDrawnBooklets = game.getNumberOfDrawnBooklets();
if(index < nDrawnBooklets){
operands.push((double)game.getDrawnBooklet(index));
}
else{
if(index < nDrawnBooklets + OPERATORS.length){
double operand2;
double operand1;
try{
operand2 = operands.pop();
}
catch(EmptyStackException e){
return res;
}
try{
operand1 = operands.pop();
}
catch(EmptyStackException e){
return res;
}
if(res == null){
res = 0.0;
}
switch(OPERATORS[(index-nDrawnBooklets)]){
case '*':
res = operand1 * operand2;
break;
case '/':
if( operand2 != 0.0f && operand1 != 0.0f &&
operand1 % operand2 == 0){
res = operand1 / operand2;
}
else{
res = null;
return res;
}
break;
case '+':
res = operand1 + operand2;
break;
case '-':
res = operand1 - operand2;
break;
default:
break;
}
operands.push(res);
}
}
}*/
return res;
}