test_func_fw.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_OPTIMIZERS_FW_TEST_FUNC_FW_HPP
15 #define MLPACK_CORE_OPTIMIZERS_FW_TEST_FUNC_FW_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace optimization {
21 
28 {
29  public:
31  {/* Nothing to do. */}
32 
38  double Evaluate(const arma::mat& coords)
39  {
40  double f = std::pow(coords[0] - 0.1, 2);
41  f += std::pow(coords[1] - 0.2, 2);
42  f += std::pow(coords[2] - 0.3, 2);
43  return f;
44  }
45 
52  void Gradient(const arma::mat& coords, arma::mat& gradient)
53  {
54  gradient.set_size(3, 1);
55  gradient[0] = coords[0] - 0.1;
56  gradient[1] = coords[1] - 0.2;
57  gradient[2] = coords[2] - 0.3;
58  }
59 };
60 
61 } // namespace optimization
62 } // namespace mlpack
63 
64 #endif
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
Simple test function for classic Frank Wolfe Algorithm:
void Gradient(const arma::mat &coords, arma::mat &gradient)
Gradient of the function.
double Evaluate(const arma::mat &coords)
Evaluation of the function.