full_selection.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_OPTIMIZERS_CMAES_FULL_SELECTION_HPP
13 #define MLPACK_CORE_OPTIMIZERS_CMAES_FULL_SELECTION_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace optimization {
19 
20 /*
21  * Select the full dataset for use in the Evaluation step.
22  */
24 {
25  public:
34  template<typename DecomposableFunctionType>
35  double Select(DecomposableFunctionType& function,
36  const size_t batchSize,
37  const arma::mat& iterate)
38  {
39  // Find the number of functions to use.
40  const size_t numFunctions = function.NumFunctions();
41 
42  double objective = 0;
43  for (size_t f = 0; f < numFunctions; f += batchSize)
44  {
45  const size_t effectiveBatchSize = std::min(batchSize, numFunctions - f);
46  objective += function.Evaluate(iterate, f, effectiveBatchSize);
47  }
48 
49  return objective;
50  }
51 };
52 
53 } // namespace optimization
54 } // namespace mlpack
55 
56 #endif
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Select(DecomposableFunctionType &function, const size_t batchSize, const arma::mat &iterate)
Select the full dataset to calculate the objective function.