13 #ifndef MLPACK_CORE_OPTIMIZERS_FUNCTION_ADD_EVALUATE_WITH_GRADIENT_HPP 14 #define MLPACK_CORE_OPTIMIZERS_FUNCTION_ADD_EVALUATE_WITH_GRADIENT_HPP 21 namespace optimization {
28 template<
typename FunctionType,
30 bool HasEvaluateGradient = traits::HasNonConstSignatures<
40 bool HasEvaluateWithGradient = traits::HasEvaluateWithGradient<
54 template<
typename FunctionType,
bool HasEvaluateGradient>
61 return static_cast<FunctionType*
>(
63 coordinates, gradient);
71 template<
typename FunctionType>
85 const double objective =
97 template<
typename FunctionType,
107 bool HasEvaluateWithGradient = traits::HasEvaluateWithGradient<
121 template<
typename FunctionType,
bool HasEvaluateGradient>
129 return static_cast<const FunctionType*
>(
131 coordinates, gradient);
139 template<
typename FunctionType>
151 arma::mat& gradient)
const 153 const double objective =
167 template<
typename FunctionType,
168 bool HasEvaluateGradient =
169 traits::HasEvaluate<FunctionType,
170 traits::EvaluateStaticForm>::value &&
171 traits::HasGradient<FunctionType,
173 bool HasEvaluateWithGradient =
174 traits::HasEvaluateWithGradient<FunctionType,
187 template<
typename FunctionType,
bool HasEvaluateGradient>
195 return FunctionType::EvaluateWithGradient(coordinates, gradient);
203 template<
typename FunctionType>
217 const double objective = FunctionType::Evaluate(coordinates);
218 FunctionType::Gradient(coordinates, gradient);
double(*)(const arma::mat &) EvaluateStaticForm
This is the form of a static Evaluate() method.
double(*)(const arma::mat &, arma::mat &) EvaluateWithGradientStaticForm
This is the form of a static EvaluateWithGradient() method.
The AddEvaluateWithGradient mixin class will provide an EvaluateWithGradient() method if the given Fu...
double EvaluateWithGradient(const arma::mat &coordinates, arma::mat &gradient)
Return both the evaluated objective function and its gradient, storing the gradient in the given matr...
void(*)(const arma::mat &, arma::mat &) GradientStaticForm
This is the form of a static Gradient() method.
double(FunctionType::*)(const arma::mat &) const EvaluateConstForm
This is the form of a const Evaluate() method.
The AddEvaluateWithGradientStatic mixin class will provide a static EvaluateWithGradient() method if ...
void(FunctionType::*)(const arma::mat &, arma::mat &) const GradientConstForm
This is the form of a const Gradient() method.
double(FunctionType::*)(const arma::mat &, arma::mat &) const EvaluateWithGradientConstForm
This is the form of a const EvaluateWithGradient() method.
static double EvaluateWithGradient(const arma::mat &coordinates, arma::mat &gradient)
Return both the evaluated objective function and its gradient, storing the gradient in the given matr...
The core includes that mlpack expects; standard C++ includes and Armadillo.
double(FunctionType::*)(const arma::mat &) EvaluateForm
This is the form of a non-const Evaluate() method.
double EvaluateWithGradient(traits::UnconstructableType &)
void(FunctionType::*)(const arma::mat &, arma::mat &) GradientForm
This is the form of a non-const Gradient() method.
double EvaluateWithGradient(const arma::mat &coordinates, arma::mat &gradient) const
Return both the evaluated objective function and its gradient, storing the gradient in the given matr...
static double EvaluateWithGradient(const arma::mat &coordinates, arma::mat &gradient)
The AddEvaluateWithGradient mixin class will provide an EvaluateWithGradient() const method if the gi...
This is a utility type used to provide unusable overloads from each of the mixin classes.
double EvaluateWithGradient(const arma::mat &coordinates, arma::mat &gradient) const
double EvaluateWithGradient(const arma::mat &coordinates, arma::mat &gradient)
double(FunctionType::*)(const arma::mat &, arma::mat &) EvaluateWithGradientForm
This is the form of a non-const EvaluateWithGradient() method.
Utility struct: sometimes we want to know if we have two functions available, and that at least one o...
The Function class is a wrapper class for any FunctionType that will add any possible derived methods...