[galib] how to write the best genome to a file
Olivier Parisy
parisy at labri.fr
Wed Apr 14 08:58:25 EDT 2004
Ooops. no reply-to ?
sunyanxin at sh.com wrote:
> 1.I have got the best geome,how to write to a file .
> generate a file pointer to a file ,then replace cout=file stream?
>
> cout << "ga :\n" << ga1.statistics().bestIndividual() << endl;
This won't work. You'll have to create a file stream ;
then you'll be able to feed it your data, exactly as if
it was cout.
So it'll be something along the line of :
#include <fstream>
...
std::ofstream file("mygenome.txt");
file << "ga :\n" << ga1.statistics().bestIndividual() << std::endl;
The file will be close as soon as the associed object is destroyed,
so you won't have to do this manually most of the time.
Olivier.
More information about the galib
mailing list