本文整理汇总了C++中GAPopulation::div方法的典型用法代码示例。如果您正苦于以下问题:C++ GAPopulation::div方法的具体用法?C++ GAPopulation::div怎么用?C++ GAPopulation::div使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GAPopulation
的用法示例。
在下文中一共展示了GAPopulation::div方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Set the score info to the appropriate values. Update the score count.
void
GAStatistics::setScore(const GAPopulation& pop){
aveCur = pop.ave();
maxCur = pop.max();
minCur = pop.min();
devCur = pop.dev();
divCur = ((dodiv == gaTrue) ? pop.div() : (float)-1.0);
if(Nscrs == 0) return;
gen[nscrs] = curgen;
aveScore[nscrs] = aveCur;
maxScore[nscrs] = maxCur;
minScore[nscrs] = minCur;
devScore[nscrs] = devCur;
divScore[nscrs] = divCur;
nscrs++;
}
示例2: memset
// Reset the GA's statistics based on the population. To do this right you
// should initialize the population before you pass it to this routine. If you
// don't, the stats will be based on a non-initialized population.
void
GAStatistics::reset(const GAPopulation & pop){
curgen = 0;
numsel = numcro = nummut = numrep = numeval = numpeval = 0;
memset(gen, 0, Nscrs*sizeof(int));
memset(aveScore, 0, Nscrs*sizeof(float));
memset(maxScore, 0, Nscrs*sizeof(float));
memset(minScore, 0, Nscrs*sizeof(float));
memset(devScore, 0, Nscrs*sizeof(float));
memset(divScore, 0, Nscrs*sizeof(float));
nscrs = 0;
setScore(pop);
if(Nscrs > 0) flushScores();
memset(cscore, 0, Nconv*sizeof(float));
nconv = 0; // should set to -1 then call setConv
cscore[0] =
((pop.order() == GAPopulation::HIGH_IS_BEST) ? pop.max() : pop.min());
// cscore[0] = pop.max();
// setConvergence(maxScore[0]);
updateBestIndividual(pop, gaTrue);
aveCur = aveInit = pop.ave();
maxCur = maxInit = maxever = pop.max();
minCur = minInit = minever = pop.min();
devCur = devInit = pop.dev();
divCur = divInit = ((dodiv == gaTrue) ? pop.div() : (float)-1.0);
on = pop.ave();
offmax = pop.max();
offmin = pop.min();
numpeval = pop.nevals();
for(int i=0; i<pop.size(); i++)
numeval += pop.individual(i).nevals();
}