13 #ifndef MLPACK_CORE_OPTIMIZERS_LBFGS_LBFGS_HPP 14 #define MLPACK_CORE_OPTIMIZERS_LBFGS_LBFGS_HPP 19 namespace optimization {
33 template<
typename FunctionType>
57 L_BFGS(FunctionType&
function,
58 const size_t numBasis = 10,
59 const size_t maxIterations = 10000,
60 const double armijoConstant = 1e-4,
61 const double wolfe = 0.9,
62 const double minGradientNorm = 1e-6,
63 const double factr = 1e-15,
64 const size_t maxLineSearchTrials = 50,
65 const double minStep = 1e-20,
66 const double maxStep = 1e20);
101 double Optimize(arma::mat& iterate,
const size_t maxIterations);
104 const FunctionType&
Function()
const {
return function; }
124 double Wolfe()
const {
return wolfe; }
134 double Factr()
const {
return factr; }
155 FunctionType&
function;
158 arma::mat newIterateTmp;
167 size_t maxIterations;
169 double armijoConstant;
173 double minGradientNorm;
177 size_t maxLineSearchTrials;
184 std::pair<arma::mat, double> minPointIterate;
192 double Evaluate(
const arma::mat& iterate);
201 double ChooseScalingFactor(
const size_t iterationNum,
202 const arma::mat& gradient);
210 bool GradientNormTooSmall(
const arma::mat& gradient);
225 bool LineSearch(
double& functionValue,
228 const arma::mat& searchDirection);
238 void SearchDirection(
const arma::mat& gradient,
239 const size_t iterationNum,
240 const double scalingFactor,
241 arma::mat& searchDirection);
254 void UpdateBasisSet(
const size_t iterationNum,
255 const arma::mat& iterate,
256 const arma::mat& oldIterate,
257 const arma::mat& gradient,
258 const arma::mat& oldGradient);
264 #include "lbfgs_impl.hpp" 266 #endif // MLPACK_CORE_OPTIMIZERS_LBFGS_LBFGS_HPP double Factr() const
Get the factr value.
double MaxStep() const
Return the maximum line search step size.
Linear algebra utility functions, generally performed on matrices or vectors.
double MinStep() const
Return the minimum line search step size.
const FunctionType & Function() const
Return the function that is being optimized.
L_BFGS(FunctionType &function, const size_t numBasis=10, const size_t maxIterations=10000, const double armijoConstant=1e-4, const double wolfe=0.9, const double minGradientNorm=1e-6, const double factr=1e-15, const size_t maxLineSearchTrials=50, const double minStep=1e-20, const double maxStep=1e20)
Initialize the L-BFGS object.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double & MinStep()
Modify the minimum line search step size.
double Optimize(arma::mat &iterate)
Use L-BFGS to optimize the given function, starting at the given iterate point and finding the minimu...
double Wolfe() const
Get the Wolfe parameter.
size_t & MaxIterations()
Modify the maximum number of iterations.
size_t & MaxLineSearchTrials()
Modify the maximum number of line search trials.
double & MaxStep()
Modify the maximum line search step size.
double & ArmijoConstant()
Modify the Armijo condition constant.
double & Factr()
Modify the factr value.
const std::pair< arma::mat, double > & MinPointIterate() const
Return the point where the lowest function value has been found.
FunctionType & Function()
Modify the function that is being optimized.
size_t & NumBasis()
Modify the memory size.
double MinGradientNorm() const
Get the minimum gradient norm.
double & Wolfe()
Modify the Wolfe parameter.
double & MinGradientNorm()
Modify the minimum gradient norm.
size_t MaxIterations() const
Get the maximum number of iterations.
size_t NumBasis() const
Get the memory size.
The generic L-BFGS optimizer, which uses a back-tracking line search algorithm to minimize a function...
size_t MaxLineSearchTrials() const
Get the maximum number of line search trials.
double ArmijoConstant() const
Get the Armijo condition constant.