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
|
||||
for ( unsigned j = 0; j < thisSize*perc; j ++ ) {
|
||||
// Randomly select a tournamentSize set, and choose the best
|
||||
eoPop<EOT> veoTournament;
|
||||
eoUniform<unsigned> u( 0, thisSize);
|
||||
for ( unsigned k = 0; k < repTournamentSize; k++ ) {
|
||||
unsigned chosen = u();
|
||||
EOT newEO = _vEO[chosen];
|
||||
veoTournament.push_back( newEO );
|
||||
}
|
||||
sort( veoTournament.begin(), veoTournament.end() );
|
||||
// The first is chosen for the new population
|
||||
_aVEO.push_back( veoTournament.front() );
|
||||
// Randomly select a tournamentSize set, and choose the best
|
||||
eoPop<EOT> veoTournament;
|
||||
eoUniform<unsigned> u( 0, thisSize);
|
||||
for ( unsigned k = 0; k < repTournamentSize; k++ ) {
|
||||
unsigned chosen = u();
|
||||
EOT newEO = _vEO[chosen];
|
||||
veoTournament.push_back( newEO );
|
||||
}
|
||||
|
||||
eoPop<EOT>::const_iterator best = max_element(veoTournament.begin(),
|
||||
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 );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue