48 template <
size_t param_index,
size_t grid_size,
typename EvalResult,
typename Tuple,
typename... TupleTypes>
57 template <
size_t grid_size,
typename EvalResult,
typename Tuple,
typename... TupleTypes>
58 struct Looper<grid_size, grid_size, EvalResult, Tuple, TupleTypes...>
60 template <
typename Functor>
61 double operator()(
const Tuple&, Functor functor, EvalResult , std::array<size_t, grid_size>& )
71 template <
size_t param_index,
size_t grid_size,
typename EvalResult,
typename Tuple,
typename FirstTupleType,
typename... TupleTypes>
72 struct Looper<param_index, grid_size, EvalResult, Tuple, FirstTupleType, TupleTypes...>
74 template <
typename Functor>
75 EvalResult operator()(
const Tuple& grid, Functor functor, EvalResult bestValue, std::array<size_t, grid_size>& bestIndices)
77 for (
size_t index = 0; index < std::get<param_index>(grid).size(); ++index)
79 double currVal = Looper<param_index + 1, grid_size, EvalResult, Tuple, TupleTypes...>()
82 [&grid, index, &functor](TupleTypes... rest){
return functor(std::get<param_index>(grid)[index], rest...);},
87 if ( currVal > bestValue )
90 bestIndices[param_index] = index;
98 template <
typename... TupleTypes>
103 grid_(std::make_tuple<std::vector<TupleTypes>...>(std::move(gridValues)...))
107 template <
typename Functor>
108 typename std::result_of<Functor(TupleTypes...)>::type
evaluate(Functor evaluator,
109 typename std::result_of<Functor(TupleTypes...)>::type startValue,
110 std::array<
size_t,std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value>& resultIndices)
112 return Internal::Looper<0,
113 std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value,
114 typename std::result_of<Functor(TupleTypes...)>::type,
115 std::tuple<std::vector<TupleTypes>...>,
117 (
grid_, evaluator, startValue, resultIndices);
122 template <
typename EvalResult>
123 EvalResult
evaluate(EvalResult evaluator(TupleTypes...),
124 EvalResult startValue,
125 std::array<
size_t,std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value>& resultIndices)
127 return Internal::Looper<0,
128 std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value,
130 std::tuple<std::vector<TupleTypes>...>,
132 (
grid_, evaluator, startValue, resultIndices);
149 std::tuple<std::vector<TupleTypes>...>
grid_;
153 template<std::
size_t I = 0>
154 typename std::enable_if<I ==
sizeof...(TupleTypes),
unsigned int>::type
161 template<std::
size_t I = 0>
162 typename std::enable_if<I <
sizeof...(TupleTypes),
unsigned int>::type
166 return nrCombos<I + 1>();
Definition: GridSearch.h:100
std::result_of< Functor(TupleTypes...)>::type evaluate(Functor evaluator, typename std::result_of< Functor(TupleTypes...)>::type startValue, std::array< size_t, std::tuple_size< std::tuple< std::vector< TupleTypes >... >>::value > &resultIndices)
Definition: GridSearch.h:108
unsigned int getNrCombos()
Definition: GridSearch.h:136
std::tuple< std::vector< TupleTypes >... > grid_
Definition: GridSearch.h:149
unsigned int combos_
Definition: GridSearch.h:150
bool combos_ready_
Definition: GridSearch.h:151
EvalResult evaluate(EvalResult evaluator(TupleTypes...), EvalResult startValue, std::array< size_t, std::tuple_size< std::tuple< std::vector< TupleTypes >... >>::value > &resultIndices)
Definition: GridSearch.h:123
std::enable_if< I==sizeof...(TupleTypes), unsigned int >::type nrCombos()
Definition: GridSearch.h:155
GridSearch(std::vector< TupleTypes >... gridValues)
Definition: GridSearch.h:102
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47