31 #ifndef SHARK_ALGORITHMS_DIRECTSEARCH_OPERATORS_SELECTION_ELITIST_SELECTION_H 32 #define SHARK_ALGORITHMS_DIRECTSEARCH_OPERATORS_SELECTION_ELITIST_SELECTION_H 43 template<
typename Ordering >
52 template<
typename InIterator,
typename OutIterator>
54 InIterator it, InIterator itE,
55 OutIterator out, OutIterator outE
57 std::size_t outputSize = std::distance( out, outE );
58 std::vector<InIterator> results = order(it, itE);
59 SHARK_RUNTIME_CHECK(results.size() > outputSize,
"Input range must be bigger than output range");
61 for(std::size_t i = 0; i != outputSize; ++i, ++out){
72 template<
typename Population>
78 typedef typename Population::iterator InIterator;
79 std::vector<InIterator> results = order(population.begin(),population.end());
81 for(std::size_t i = 0; i != mu; ++i){
82 results[i]->select()=
true;
84 for(std::size_t i = mu; i != results.size(); ++i){
85 results[i]->select() =
false;
91 template<
class InIterator>
92 std::vector<InIterator> order(InIterator it, InIterator itE){
93 std::size_t size = std::distance( it, itE );
94 std::vector<InIterator > individuals(size);
95 std::iota(individuals.begin(),individuals.end(),it);
99 [](InIterator lhs, InIterator rhs){
101 return ordering(*lhs,*rhs);