styblinski_tang_function.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_OPTIMIZERS_PROBLEMS_STYBLINSKI_TANG_FUNCTION_HPP
13 #define MLPACK_CORE_OPTIMIZERS_PROBLEMS_STYBLINSKI_TANG_FUNCTION_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace optimization {
19 namespace test {
20 
45 {
46  public:
47  /*
48  * Initialize the StyblinskiTangFunction.
49  *
50  * @param n Number of dimensions for the function.
51  */
52  StyblinskiTangFunction(const size_t n);
53 
58  void Shuffle();
59 
61  size_t NumFunctions() const { return n; }
62 
64  arma::mat GetInitialPoint() const { return initialPoint; }
65 
66  /*
67  * Evaluate a function for a particular batch-size.
68  *
69  * @param coordinates The function coordinates.
70  * @param begin The first function.
71  * @param batchSize Number of points to process.
72  */
73  double Evaluate(const arma::mat& coordinates,
74  const size_t begin,
75  const size_t batchSize) const;
76 
77  /*
78  * Evaluate a function with the given coordinates.
79  *
80  * @param coordinates The function coordinates.
81  */
82  double Evaluate(const arma::mat& coordinates) const;
83 
84  /*
85  * Evaluate the gradient of a function for a particular batch-size.
86  *
87  * @param coordinates The function coordinates.
88  * @param begin The first function.
89  * @param gradient The function gradient.
90  * @param batchSize Number of points to process.
91  */
92  void Gradient(const arma::mat& coordinates,
93  const size_t begin,
94  arma::mat& gradient,
95  const size_t batchSize) const;
96 
97  /*
98  * Evaluate the gradient of a function with the given coordinates.
99  *
100  * @param coordinates The function coordinates.
101  * @param gradient The function gradient.
102  */
103  void Gradient(const arma::mat& coordinates, arma::mat& gradient);
104  private:
106  size_t n;
107 
109  arma::Row<size_t> visitationOrder;
110 
112  arma::mat initialPoint;
113 };
114 
115 } // namespace test
116 } // namespace optimization
117 } // namespace mlpack
118 
119 #endif // MLPACK_CORE_OPTIMIZERS_PROBLEMS_STYBLINSKI_TANG_FUNCTION_HPP
void Gradient(const arma::mat &coordinates, const size_t begin, arma::mat &gradient, const size_t batchSize) const
size_t NumFunctions() const
Return 1 (the number of functions).
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
The Styblinski-Tang function, defined by.
void Shuffle()
Shuffle the order of function visitation.
arma::mat GetInitialPoint() const
Get the starting point.
double Evaluate(const arma::mat &coordinates, const size_t begin, const size_t batchSize) const