GA within GA
Mineo Morohashi
moro at mineo.com
Thu Apr 8 02:32:22 EDT 1999
Hello,
I'm trying to implement GA within GA as a part of my program.
Being different from sample program ex13.C, internal genome size is
dependent on the result of external GA. That's why I declare Genome,
and GA inside the evaluation function. However, when I execute it, the
program finishes without putting out any error. The program is likely
to end at the line of GA->done(), just after receiving gaTrue.
I cannot figure out what is wrong with my program.
Would you let me know what the problem is?
Best regards,
M.Morohashi
==============================================================
float GAEvaluate(GAGenome& g)
{
GARealGenome* teriGenome;
GARealAlleleSetArray map;
GASimpleGA* GA;
int** connect;
GA2DArrayAlleleGenome<int> & genome = (GA2DArrayAlleleGenome<int> &) g;
for (int y=0; y<10; y++){
for (int x=0; x<10; x++){
if (genome.gene(x,y) == 1){
map.add(0,1);
}else if (genome.gene(x,y) == -1){
map.add((float)-1,(float)0);
}
}
}
CompositeData data;
selector = new GATournamentSelector;
teriGenome = new GARealGenome((GARealAlleleSetArray&)map, internalGAEvaluate, (void*)&data);
teriGenome->crossover(GARealGenome::TwoPointCrossover);
GA = new GASimpleGA((GARealGenome&)*teriGenome);
GA->selector(*selector);
GA->minimize();
GA->scoreFilename("hoge.log");
GA->nGenerations(3);
GA->populationSize(5);
GA->pMutation(0.01);
GA->pCrossover(0.8);
GA->selectScores(GAStatistics::AllScores);
GA->nBestGenomes(10);
// initTeritiaryGA(argc,argv);
GA->initialize();
while(!GA->done()){
GA->step();
}
GARealGenome& Genome = (GARealGenome&)GA->population().best();
......
......
......
return ***;
}
More information about the galib
mailing list