Complete population

Bill White bwhite at phg.mc.vanderbilt.edu
Tue Feb 26 08:25:43 EST 2002


>
>
>B) In the method I was thinking of, I would need access to the
>population of a generation. Looking though the Galib manual, I find that
>there is no way to access the "current" GAPopulaiton object, I can only
>get a population of "best" individuals encountered so far. Is there a
>way to access the complete population for a particular generation?
>
I print the complete population with a function:

// 
----------------------------------------------------------------------------
void PrintPopulationToFile(char* popFileName, GASimpleGA& ga,
                                          GARealGenome& genome)
{
  ofstream outfile; 
  outfile.open(popFileName, (ios::out | ios::trunc));
  for(int ii=0; ii<ga.population().size(); ii++) {
    genome = ga.population().individual(ii);
    outfile <<
      "("  <<  genome.gene(0) <<
      ", " <<  genome.gene(1) <<
      ", " <<  genome.gene(2) <<
      ", " <<  genome.gene(3) <<
      ", " <<  genome.gene(4) <<
      ", " <<  genome.gene(5) <<
      ", " <<  genome.gene(6) <<
      ", " <<  genome.gene(7) <<
      ", " <<  genome.gene(8) <<
      ", " <<  genome.gene(9) <<
      ", " <<  genome.gene(10) << 
      ", " <<  genome.gene(11) <<
      ", " <<  genome.gene(12) <<
      ", " <<  genome.gene(13) <<
      ", " <<  genome.gene(14) <<
      ")\t" << genome.score() << "\n";
  }
  outfile.close();
}

If I'm not mistaken, this function was lifted and midified from of one 
of the examples that comes with GAlib. The examples are an invaluable 
resource for "how do I do X?" in Galib.

-- 
Bill White                                   
Systems Software Specialist II
Program in Human Genetics 
Department of Molecular Physiology and Biophysics
519 Light Hall 
Vanderbilt University Medical School
Nashville, TN  37232-0700

Phone: 615-322-6496           Fax:   615-343-8619
Email: bwhite at phg.mc.vanderbilt.edu






More information about the galib mailing list