[galib] Dumping Population and restarting

TIMOTHY RONALD PHILLIPS t.r.phillips at newcastle.ac.uk
Sat Sep 29 05:51:31 EDT 2007


I am interested in storing the current generation of solutions to files,
and being able to start the GA from the population stored in a file. I
am at present using a Dec2Bin representation

Any suggestions on how I would do this? I have got the the phenotype
writing to file using STD_OFSTREAM, which will write the phenotype of
the population to file using the code below

float Objective(GAGenome &);

int main(int argc, char **argv)
{

	ofstream outfile;

...
while(!ga.done())
	{
		++ga;
		Gen=Gen+1;
		ofstream outfile;
		char myname [50];
		sprintf_s(myname, 50,
"29-09-07--10-00-IncBestSolGen%d.dat\n", Gen);
		outfile.open(myname, (STD_IOS_OUT | STD_IOS_TRUNC));
		

		//fopen_s( &stream, "Filename.dat", "w" );

		for (int popmem=0; popmem<ga.populationSize(); popmem++)
		{
	
outfile<<((ga.population().individual(popmem)))<<"\n";
		}
		outfile.close();	;
	}
How would I go about importing this as the start population? Could the
best genomes also be populated by importing from file in a similar way?

Thank you for you assistance


Tim




More information about the galib mailing list