本文整理汇总了C++中Population::StartSubtreeMode方法的典型用法代码示例。如果您正苦于以下问题:C++ Population::StartSubtreeMode方法的具体用法?C++ Population::StartSubtreeMode怎么用?C++ Population::StartSubtreeMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population
的用法示例。
在下文中一共展示了Population::StartSubtreeMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoMasterSW
//.........这里部分代码省略.........
//tree we got from it is worse by some amount, or if it is still working
//on a subtree
double updateThresh=paraMan->updateThresh;
//DEBUG
// if(paraMan->subtreeModeActive==false && (paraMan->needToSend[who]==true || ((scorediff > nonSubThresh && paraMan->beforeFirstSubtree==false) || (scorediff > startThresh && paraMan->beforeFirstSubtree==true) || remoteSubtreeDef>0))){
if(paraMan->subtreeModeActive==false){
if((paraMan->perturbModeActive==false && (scorediff > updateThresh || remoteSubtreeDef>0))/* || (paraMan->needToSend[who]==true)*/){
debug_mpi("\tupdate thresh = %f, send indiv", updateThresh);
//cases 5, 6 and 8
*which = (int)pop->cumfit[pop->total_size-1][0];
subtreeNum=0;
send=true;
}
else debug_mpi("\tupdate thresh = %f", updateThresh);
}
else if(paraMan->subtreeModeActive==true){
//cases 1-4
if((scorediff > updateThresh) || (subtreesCurrent==false)/* || paraMan->perturb==true*/){
//cases 2 and 4. send the best accurate tree
*which=pop->bestAccurateIndiv;
if(paraMan->remoteSubtreeAssign[who] != 0) subtreeNum=paraMan->remoteSubtreeAssign[who];
else subtreeNum=paraMan->ChooseSubtree();
debug_mpi("\tsend best accurate ind, %f (best=%f)", pop->indiv[*which].Fitness(), pop->bestFitness);
// debug_mpi("\tperturb=%d, bestFit=%f, indFit=%f", paraMan->perturb, pop->bestFitness, pop->indiv[*which].Fitness());
send=true;
}
else if(recalcSubtrees==true && subtreesCurrent==false){
//case 3
//if the new inaccurate tree that came in is better than what we have,
//recalcuate the subtrees, and send the same tree back, but with a
//subtree asignment
pop->StartSubtreeMode();
debug_mpi("Recalculating subtrees");
subtreeNum=paraMan->ChooseSubtree();
send=true;
}
}
if(paraMan->needToSend[who]){
char pertbuf[5];
int perttype = (pop->pertMan->pertType > 0 ? pop->pertMan->pertType : (int)(rnd.uniform() * 2 + 1));
sprintf(pertbuf, "%d", perttype);
SendMPIMessage(pertbuf, strlen(pertbuf)+2, who, TAG_PERTURB);
debug_mpi("sending pertub message to %d, type %d", who, perttype);
paraMan->needToSend[who]=false;
}
if(send==true){
pop->GetSpecifiedTreeStrings(&out_tree_strings, 1, which);
assert(*out_tree_strings == '(');
int model_size=pop->GetSpecifiedModels(&out_models, 1, which);
SendMPIMessage(out_tree_strings, strlen2(out_tree_strings)+2, who, TAG_TREE_STRINGS);
SendMPIMessage((char*)out_models, sizeof(double)*model_size, who, TAG_MODEL);
/* if(paraMan->needToSend[who]){
char pertbuf[5];
int perttype = (pop->pertMan->pertType > 0 ? pop->pertMan->pertType : (rnd.uniform() * 2 + 1));
sprintf(pertbuf, "%d", subtreeNum);
SendMPIMessage(NULL, 0, who, TAG_PERTURB);
debug_mpi("sending pertub message to %d, type %d", who, perttype);
paraMan->needToSend[who]=false;