[galib] Help- Showing the best individual with Borland C++ Builder 6.0

Pawel czeslavus at wp.pl
Mon Feb 7 12:17:24 EST 2005


> Solucao1->Memo1->Lines->Add("best individual is: " +
> (ga.statistics().bestIndividual()) + "\n");

first, you need to get text form for genome, e.g.

#include <sstream> 

using namespace std; 

...

ostringstream ostr; 
ostr << ga.statistics().bestIndividual(); 
AnsiString besttxt = ostr.str().c_str(); 

then you can add received text to memo: 

Solucao1->Memo1->Lines->Add(AnsiString("best individual is: ") + besttxt);

Direct AnsiString constructor can be usefull, because BCB sometimes has a 
problem with automatic conversion from - to AnsiString. 

And if you are using method Add - you do not need to add additional line end 
mark. 

Regards, 

Pawel


More information about the galib mailing list