GAlib with MFC

Markku Laukkanen markku at ailabsolutions.com
Mon Jan 13 00:50:44 EST 2003


One example how to do it. 
Unfortunately unnecessary copying in genom setting.

There is many examples in the example directory for doing this. I think


	PKY

template <class FloatType> void
Dim3<FloatType>::dumpInitialPopulation(const char* fileName) {
  // Dump the current population into file
  ofstream outfile;
  outfile.open(fileName, (ios::out | ios::trunc));
  GA1DArrayGenome<FloatType> genome(6, objectiveFunction);
  for (int i=0; i<((::GAGeneticAlgorithm *)ga)->population().size(); i++){
    genome = ((::GAGeneticAlgorithm *)ga)->population().individual(i);
    outfile << genome.gene(3) << " " 
	    << genome.gene(4) << " " 
	    << genome.gene(5) << " " 
	    << genome.gene(0) << " " 
	    << genome.gene(1) << " " 
	    << genome.gene(2) << " " 
	    << genome.score() << "\n";
  }
  outfile.close();
}

On Fri, 10 Jan 2003, Flt. Lt.Otsin  Nilubol wrote:

> Hi,
> I’m a new user of GALib class, I got some difficulties to use this class
> with MFC. One of your member advices me define NO_STREAMS at the
> beginning of file gaconfig.h and recompile. Because he might Windows has
> two difference versions of Streams; however I want to let the GALib
> class write some result in the file (stream) to check and compare them.
> If anyone has any ideas to solve it, please mail me at
> er060614 at cranfield.ac.uk. Thank you very much in advance for your help.
> Best Regards,
> Otsin
> 
> --------------------------------------------------------
> Flt.Lt.Otsin  Nilubol (Ot)
> PhD Research Student
> College of Aeronautics
> School of Engineering (Building 83)
> Cranfield University
> Cranfield, Bedford
> MK43 0AL
> United Kingdom
> Tel: 00-44-(0)1234-750111 ext. 5254
> Email: er060614 at cranfield.ac.uk; otsin at lycos.co.uk
> -------------------------------------------------------- 
> 
> 
> _______________________________________________
> galib mailing list
> galib at mit.edu
> http://lancet.mit.edu/mailman/listinfo/galib
> 




More information about the galib mailing list