Пример #1
0
// This is the class-specific copy method.  It will get called by the super
// class since the superclass operator= is set up to call ccopy (and that is
// what we define here - a virtual function).  We should check to be sure that
// both genomes are the same class.
void
BitStringGenome::copy(const GAGenome & orig) {
  if(&orig == this) return;
  if(!sameClass(orig)){
    GAErr(GA_LOC, className(), "copy", gaErrObjectTypeMismatch);
    return;
  }
  GAGenome::copy(orig);
  BitStringGenome &bsg = (BitStringGenome &)orig;
  BitString::operator=(bsg._substr(0,bsg.length()));
}
Пример #2
0
template <class T> void
GA3DArrayGenome<T>::copy(const GAGenome & orig){
  if(&orig == this) return;
  if(!sameClass(orig)){
    GAErr(GA_LOC, className(), "copy", gaErrObjectTypeMismatch);
    return;
  }
  GA3DArrayGenome<T> & c = (GA3DArrayGenome<T> &)orig;
  GAGenome::copy(c);
  GAArray<T>::copy(c);
  nx = c.nx; ny = c.ny; nz = c.nz;
  minX = c.minX; minY = c.minY; minZ = c.minZ;
  maxX = c.maxX; maxY = c.maxY; maxZ = c.maxZ;
}
Пример #3
0
void
GA3DBinaryStringGenome::copy(const GAGenome & orig)
{
  if(&orig == this) return;
  if(!sameClass(orig)){
    GAErr(GA_LOC, className(), "copy", gaErrObjectTypeMismatch);
    return;
  }
  GA3DBinaryStringGenome & c = (GA3DBinaryStringGenome &)orig;
  GAGenome::copy(orig);
  GABinaryString::copy(c);
  nx = c.nx; ny = c.ny; nz = c.nz;
  minX = c.minX; minY = c.minY; minZ = c.minZ;
  maxX = c.maxX; maxY = c.maxY; maxZ = c.maxZ;
}
Пример #4
0
void
GASteadyStateGA::copy(const GAGeneticAlgorithm & g){
  if(sameClass(g)) {
    GAGeneticAlgorithm::copy(g);
    GASteadyStateGA& ga = (GASteadyStateGA&)g;

    pRepl = ga.pRepl;
    nRepl = ga.nRepl;

    if(tmpPop) tmpPop->copy(*(ga.tmpPop));
    else tmpPop = ga.tmpPop->clone();
    tmpPop->geneticAlgorithm(*this);

    which = ga.which;
  }
}
Пример #5
0
void CCombineGenome::copy( const GAGenome & g )
{
	if(&g != this && sameClass(g)){
		GAGenome::copy(g);
		CCombineGenome& genome = (CCombineGenome &)g;

		if(paths == genome.paths){
			for(int i=0; i<paths; i++)
				path(i).copy(*genome.list[i]);
		}
		else{
			int i;
			for(i=0; i<paths; i++)
				delete list[i];
			delete [] list;
			paths = genome.paths;
			list = new GAListGenome<YK_LLONG> * [paths];
			for(i=0; i<paths; i++)
				list[i] = (GAListGenome<YK_LLONG> *)genome.list[i]->clone();
		}
	}
}