12 #ifndef MLPACK_CORE_OPTIMIZERS_CMAES_RANDOM_SELECTION_HPP 13 #define MLPACK_CORE_OPTIMIZERS_CMAES_RANDOM_SELECTION_HPP 18 namespace optimization {
49 template<
typename DecomposableFunctionType>
50 double Select(DecomposableFunctionType&
function,
51 const size_t batchSize,
52 const arma::mat& iterate)
55 const size_t numFunctions =
function.NumFunctions();
58 for (
size_t f = 0; f < std::floor(numFunctions * fraction); f += batchSize)
61 const size_t effectiveBatchSize = std::min(batchSize,
62 numFunctions - selection);
64 objective +=
function.Evaluate(iterate, selection, effectiveBatchSize);
The core includes that mlpack expects; standard C++ includes and Armadillo.
double & Fraction()
Modify the dataset fraction.
int RandInt(const int hiExclusive)
Generates a uniform random integer.
double Select(DecomposableFunctionType &function, const size_t batchSize, const arma::mat &iterate)
Randomly select dataset points to calculate the objective function.
double Fraction() const
Get the dataset fraction.
RandomSelection(const double fraction=0.3)
Constructor for the random selection strategy.