generalized_rosenbrock_function.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_OPTIMIZERS_PROBLEMS_GENERALIZED_ROSENBROCK_FUNCTION_HPP
14 #define MLPACK_CORE_OPTIMIZERS_PROBLEMS_GENERALIZED_ROSENBROCK_FUNCTION_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace optimization {
20 namespace test {
21 
49 {
50  public:
51  /*
52  * Initialize the GeneralizedRosenbrockFunction.
53  *
54  * @param n Number of dimensions for the function.
55  */
56  GeneralizedRosenbrockFunction(const size_t n);
57 
62  void Shuffle();
63 
65  size_t NumFunctions() const { return n - 1; }
66 
68  const arma::mat& GetInitialPoint() const { return initialPoint;}
69 
70  /*
71  * Evaluate a function for a particular batch-size.
72  *
73  * @param coordinates The function coordinates.
74  * @param begin The first function.
75  * @param batchSize Number of points to process.
76  */
77  double Evaluate(const arma::mat& coordinates,
78  const size_t begin,
79  const size_t batchSize = 1) const;
80 
81  /*
82  * Evaluate a function with the given coordinates.
83  *
84  * @param coordinates The function coordinates.
85  */
86  double Evaluate(const arma::mat& coordinates) const;
87 
88  /*
89  * Evaluate the gradient of a function for a particular batch-size.
90  *
91  * @param coordinates The function coordinates.
92  * @param begin The first function.
93  * @param gradient The function gradient.
94  * @param batchSize Number of points to process.
95  */
96  void Gradient(const arma::mat& coordinates,
97  const size_t begin,
98  arma::mat& gradient,
99  const size_t batchSize = 1) const;
100 
101  /*
102  * Evaluate the gradient of a function for a particular batch-size.
103  *
104  * @param coordinates The function coordinates.
105  * @param begin The first function.
106  * @param gradient The function gradient.
107  */
108  void Gradient(const arma::mat& coordinates,
109  const size_t begin,
110  arma::sp_mat& gradient,
111  const size_t count) const;
112 
113  /*
114  * Evaluate the gradient of a function with the given coordinates.
115  *
116  * @param coordinates The function coordinates.
117  * @param gradient The function gradient.
118  */
119  void Gradient(const arma::mat& coordinates, arma::mat& gradient) const;
120 
121  private:
123  arma::mat initialPoint;
124 
126  size_t n;
127 
129  arma::Row<size_t> visitationOrder;
130 };
131 
132 } // namespace test
133 } // namespace optimization
134 } // namespace mlpack
135 
136 #endif // MLPACK_CORE_OPTIMIZERS_PROBLEMS_GENERALIZED_ROSENBROCK_FUNCTION_HPP
const arma::mat & GetInitialPoint() const
Get the starting point.
The Generalized Rosenbrock function in n dimensions, defined by f(x) = sum_i^{n - 1} (f(i)(x)) f_i(x)...
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Gradient(const arma::mat &coordinates, const size_t begin, arma::mat &gradient, const size_t batchSize=1) const
void Shuffle()
Shuffle the order of function visitation.
size_t NumFunctions() const
Return 1 (the number of functions).
double Evaluate(const arma::mat &coordinates, const size_t begin, const size_t batchSize=1) const