本文整理汇总了C++中Genome::toSmall方法的典型用法代码示例。如果您正苦于以下问题:C++ Genome::toSmall方法的具体用法?C++ Genome::toSmall怎么用?C++ Genome::toSmall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Genome
的用法示例。
在下文中一共展示了Genome::toSmall方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputPopulation
void Neatzsche_MPI::outputPopulation(Population * pop, unsigned int nodes, Coevolution * c,
unsigned int i, bool lastgen)
{
unsigned int s = pop->getMembers()->size();
unsigned int n = (s-i)/nodes;
bool uneven = (floor((s-i)/(double)n)!=(s-i)/(double)n);
GeneSmall * gsv = NULL;
NeuralNodeSmall * nsv = NULL;
Genome * genome = NULL; int genes, nnodes;
int sendtag = Neatzsche_MPI::MPI_Cont;
string sftype;
int sc=0;
if(lastgen)
sendtag = MPI_Stop;
else
sendtag = MPI_Cont;
while(i < s) {
if(uneven && (s-i)<(2*n)){
n = (s-i);
}
sc = (sc % (size-1))+1;
MPI::COMM_WORLD.Send(&n,1,MPI_INT,sc,0);//send number of genomes incoming
for(size_t i2 = 0; i2 < n && i < s; i2++, i++) {
genome = pop->getMembers()->at(i)->getGenome();
genome->toSmall(nsv,gsv,&nnodes,&genes);
MPI::COMM_WORLD.Send(&i,1,MPI_INT,sc,0);//send genome id..
MPI::COMM_WORLD.Send(&nnodes,1,MPI_INT,sc,0);//send number of nodes
MPI::COMM_WORLD.Send(&genes,1,MPI_INT,sc,0);//send number of genes
nodetype = Build_neuralnode_type(&nsv[0]);
MPI::COMM_WORLD.Send(nsv,nnodes,nodetype,sc,0);//send node vector
for(int i=0;i<nnodes;i++){
sftype = "";
sftype = genome->getNodes()->at(i)->getTFunc()->ftype;
MPI::COMM_WORLD.Send(sftype.c_str(),sftype.length(),MPI::CHAR,sc,0);//send gene vector
}
genetype = Build_gene_type(&gsv[0]);
MPI::COMM_WORLD.Send(gsv,genes,genetype,sc,0);//send gene vector
if(nnodes>0)
delete[] nsv;
if(genes>0)
delete[] gsv;
}
MPI::COMM_WORLD.Send(&sendtag,1,MPI::INT,sc,0);//send stop or not
}
}