21 template <
size_t param_index,
size_t grid_size,
typename EvalResult,
typename Tuple,
typename... TupleTypes>
30 template <
size_t grid_size,
typename EvalResult,
typename Tuple,
typename... TupleTypes>
31 struct Looper<grid_size, grid_size, EvalResult, Tuple, TupleTypes...>
33 template <
typename Functor>
34 double operator()(
const Tuple&, Functor functor, EvalResult , std::array<size_t, grid_size>& )
44 template <
size_t param_index,
size_t grid_size,
typename EvalResult,
typename Tuple,
typename FirstTupleType,
typename... TupleTypes>
45 struct Looper<param_index, grid_size, EvalResult, Tuple, FirstTupleType, TupleTypes...>
47 template <
typename Functor>
48 EvalResult
operator()(
const Tuple& grid, Functor functor, EvalResult bestValue, std::array<size_t, grid_size>& bestIndices)
50 for (
size_t index = 0; index < std::get<param_index>(grid).size(); ++index)
52 double currVal =
Looper<param_index + 1, grid_size, EvalResult, Tuple, TupleTypes...>()
55 [&grid, index, &functor](TupleTypes... rest){
return functor(std::get<param_index>(grid)[index], rest...);},
60 if ( currVal > bestValue )
63 bestIndices[param_index] = index;
71 template <
typename... TupleTypes>
75 explicit GridSearch(std::vector<TupleTypes>... gridValues):
76 grid_(std::make_tuple<std::vector<TupleTypes>...>(std::move(gridValues)...))
80 template <
typename Functor>
81 typename std::result_of<Functor(TupleTypes...)>::type
evaluate(Functor evaluator,
82 typename std::result_of<Functor(TupleTypes...)>::type startValue,
83 std::array<
size_t,std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value>& resultIndices)
86 std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value,
87 typename std::result_of<Functor(TupleTypes...)>::type,
88 std::tuple<std::vector<TupleTypes>...>,
90 (
grid_, evaluator, startValue, resultIndices);
95 template <
typename EvalResult>
96 EvalResult
evaluate(EvalResult evaluator(TupleTypes...),
97 EvalResult startValue,
98 std::array<
size_t,std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value>& resultIndices)
101 std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value,
103 std::tuple<std::vector<TupleTypes>...>,
105 (
grid_, evaluator, startValue, resultIndices);
122 std::tuple<std::vector<TupleTypes>...>
grid_;
126 template<std::
size_t I = 0>
127 typename std::enable_if<I ==
sizeof...(TupleTypes),
unsigned int>::type
134 template<std::
size_t I = 0>
135 typename std::enable_if<I <
sizeof...(TupleTypes),
unsigned int>::type
139 return nrCombos<I + 1>();
Definition: GridSearch.h:73
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:81
unsigned int getNrCombos()
Definition: GridSearch.h:109
std::tuple< std::vector< TupleTypes >... > grid_
Definition: GridSearch.h:122
unsigned int combos_
Definition: GridSearch.h:123
bool combos_ready_
Definition: GridSearch.h:124
EvalResult evaluate(EvalResult evaluator(TupleTypes...), EvalResult startValue, std::array< size_t, std::tuple_size< std::tuple< std::vector< TupleTypes >... >>::value > &resultIndices)
Definition: GridSearch.h:96
std::enable_if< I==sizeof...(TupleTypes), unsigned int >::type nrCombos()
Definition: GridSearch.h:128
GridSearch(std::vector< TupleTypes >... gridValues)
Definition: GridSearch.h:75
Definition: GridSearch.h:23
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
double operator()(const Tuple &, Functor functor, EvalResult, std::array< size_t, grid_size > &)
Definition: GridSearch.h:34
EvalResult operator()(const Tuple &grid, Functor functor, EvalResult bestValue, std::array< size_t, grid_size > &bestIndices)
Definition: GridSearch.h:48