[galib] bug in TerminateUponPopConvergence?
brianco@sas.upenn.edu
brianco at sas.upenn.edu
Tue Dec 6 10:04:09 EST 2011
In GABaseGA.C, do the >= and <= conditionals need to be switched within
TerminateUponPopConvergence as follows:
GABoolean
GAGeneticAlgorithm::TerminateUponPopConvergence(GAGeneticAlgorithm & ga){
GABoolean val = gaFalse;
if(ga.statistics().current(GAStatistics::Maximum) == 0) {
return val;
}
float ratio =
ga.statistics().current(GAStatistics::Minimum) /
ga.statistics().current(GAStatistics::Maximum);
cout<<"ga.statistics().current(GAStatistics::Minimum)="<<ga.statistics().current(GAStatistics::Minimum);
cout<<"
ga.statistics().current(GAStatistics::Maximum)="<<ga.statistics().current(GAStatistics::Maximum);
if(ga.minimaxi() == GAGeneticAlgorithm::MINIMIZE) {
cout<<" ratio="<<ratio<<endl;
// if(ratio <= ga.pConvergence()) // brian kludge
if(ratio >= ga.pConvergence()) // brian kludge
val = gaTrue;
else
val = gaFalse;
}
else {
// if(ratio >= ga.pConvergence()) // brian kludge
if(ratio <= ga.pConvergence()) // brian kludge
val = gaTrue;
else
val = gaFalse;
}
return val;
}
Thank you,
Brian Connolly
More information about the galib
mailing list