bug fix in eoTournament
This commit is contained in:
parent
29dc5ac034
commit
c0e85685f8
1 changed files with 17 additions and 11 deletions
|
|
@ -61,17 +61,23 @@ public:
|
||||||
|
|
||||||
// Build vector
|
// Build vector
|
||||||
for ( unsigned j = 0; j < thisSize*perc; j ++ ) {
|
for ( unsigned j = 0; j < thisSize*perc; j ++ ) {
|
||||||
// Randomly select a tournamentSize set, and choose the best
|
// Randomly select a tournamentSize set, and choose the best
|
||||||
eoPop<EOT> veoTournament;
|
eoPop<EOT> veoTournament;
|
||||||
eoUniform<unsigned> u( 0, thisSize);
|
eoUniform<unsigned> u( 0, thisSize);
|
||||||
for ( unsigned k = 0; k < repTournamentSize; k++ ) {
|
for ( unsigned k = 0; k < repTournamentSize; k++ ) {
|
||||||
unsigned chosen = u();
|
unsigned chosen = u();
|
||||||
EOT newEO = _vEO[chosen];
|
EOT newEO = _vEO[chosen];
|
||||||
veoTournament.push_back( newEO );
|
veoTournament.push_back( newEO );
|
||||||
}
|
}
|
||||||
sort( veoTournament.begin(), veoTournament.end() );
|
|
||||||
// The first is chosen for the new population
|
eoPop<EOT>::const_iterator best = max_element(veoTournament.begin(),
|
||||||
_aVEO.push_back( veoTournament.front() );
|
veoTournament.end());
|
||||||
|
if (best == veoTournament.end()) {
|
||||||
|
throw runtime_error("error in void eoTournament::operator(eoPop<EOT>&, eoPop<EOT>&)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// The first is chosen for the new population
|
||||||
|
_aVEO.push_back( best );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue