47 template <
size_t param_index,
size_t grid_size,
typename EvalResult,
typename Tuple,
typename... TupleTypes>
56 template <
size_t grid_size,
typename EvalResult,
typename Tuple,
typename... TupleTypes>
57 struct Looper<grid_size, grid_size, EvalResult, Tuple, TupleTypes...>
59 template <
typename Functor>
60 double operator()(
const Tuple&, Functor functor, EvalResult , std::array<size_t, grid_size>& )
70 template <
size_t param_index,
size_t grid_size,
typename EvalResult,
typename Tuple,
typename FirstTupleType,
typename... TupleTypes>
71 struct Looper<param_index, grid_size, EvalResult, Tuple, FirstTupleType, TupleTypes...>
73 template <
typename Functor>
74 EvalResult operator()(
const Tuple& grid, Functor functor, EvalResult bestValue, std::array<size_t, grid_size>& bestIndices)
76 for (
size_t index = 0; index < std::get<param_index>(grid).size(); ++index)
78 double currVal = Looper<param_index + 1, grid_size, EvalResult, Tuple, TupleTypes...>()
81 [&grid, index, &functor](TupleTypes... rest){
return functor(std::get<param_index>(grid)[index], rest...);},
86 if ( currVal > bestValue )
89 bestIndices[param_index] = index;
97 template <
typename... TupleTypes>
102 grid_(std::make_tuple<std::vector<TupleTypes>...>(std::move(gridValues)...))
106 template <
typename Functor>
107 typename std::result_of<Functor(TupleTypes...)>::type
evaluate(Functor evaluator,
108 typename std::result_of<Functor(TupleTypes...)>::type startValue,
109 std::array<
size_t,std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value>& resultIndices)
111 return Internal::Looper<0,
112 std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value,
113 typename std::result_of<Functor(TupleTypes...)>::type,
114 std::tuple<std::vector<TupleTypes>...>,
116 (
grid_, evaluator, startValue, resultIndices);
121 template <
typename EvalResult>
122 EvalResult
evaluate(EvalResult evaluator(TupleTypes...),
123 EvalResult startValue,
124 std::array<
size_t,std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value>& resultIndices)
126 return Internal::Looper<0,
127 std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value,
129 std::tuple<std::vector<TupleTypes>...>,
131 (
grid_, evaluator, startValue, resultIndices);
148 std::tuple<std::vector<TupleTypes>...>
grid_;
152 template<std::
size_t I = 0>
153 typename std::enable_if<I ==
sizeof...(TupleTypes),
unsigned int>::type
160 template<std::
size_t I = 0>
161 typename std::enable_if<I <
sizeof...(TupleTypes),
unsigned int>::type
165 return nrCombos<I + 1>();
Definition: GridSearch.h:99
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:107
unsigned int getNrCombos()
Definition: GridSearch.h:135
std::tuple< std::vector< TupleTypes >... > grid_
Definition: GridSearch.h:148
unsigned int combos_
Definition: GridSearch.h:149
bool combos_ready_
Definition: GridSearch.h:150
EvalResult evaluate(EvalResult evaluator(TupleTypes...), EvalResult startValue, std::array< size_t, std::tuple_size< std::tuple< std::vector< TupleTypes >... >>::value > &resultIndices)
Definition: GridSearch.h:122
std::enable_if< I==sizeof...(TupleTypes), unsigned int >::type nrCombos()
Definition: GridSearch.h:154
GridSearch(std::vector< TupleTypes >... gridValues)
Definition: GridSearch.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47