54 template<
typename InIterator,
typename OutIterator>
57 InIterator it, InIterator itE,
58 OutIterator out, OutIterator outE
60 std::size_t outputSize = std::distance( out, outE );
61 std::vector<KeyValuePair<int, InIterator> > results = performTournament(rng, it, itE);
62 SHARK_RUNTIME_CHECK(results.size() > outputSize,
"Input range must be bigger than output range");
64 for(std::size_t i = 0; i != outputSize; ++i, ++out){
65 *out = *results[i].value;
76 template<
typename Population>
83 typedef typename Population::iterator InIterator;
84 std::vector<KeyValuePair<int, InIterator> > results = performTournament(rng, population.begin(),population.end());
87 for(std::size_t i = 0; i != mu; ++i){
88 individualPerform[i].value->select() =
true;
90 for(std::size_t i = mu; i != results.size()-1; ++i){
91 individualPerform[i].value->select() =
false;
100 template<
class InIterator>
101 std::vector<KeyValuePair<int, InIterator> > performTournament(rng_type& rng, InIterator it, InIterator itE){
102 std::size_t size = std::distance( it, itE );
103 UIntVector selectionProbability(size,0.0);
104 std::vector<KeyValuePair<int, InIterator> > individualPerformance(size);
106 for( std::size_t i = 0; i != size(); ++i ) {
107 individualPerformance[i].value = it+i;
110 if(smaller(*it, *(it+idx)){
111 individualPerformance[i].key -= 1;
116 std::sort( individualPerformance.begin(), individualPerformance.end());
117 return individualPerformance;