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,
61 const double wolfe = 0.9,
63 const double factr = 1e-15,
104 const FunctionType&
Function()
const {
return function; }
155 FunctionType&
function;
192 double Evaluate(
const arma::mat& iterate);
202 const arma::mat& gradient);
228 const arma::mat& searchDirection);
239 const size_t iterationNum,
240 const double scalingFactor,
241 arma::mat& searchDirection);
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
Minimum relative function value decrease to continue the optimization.
double ArmijoConstant() const
Get the Armijo condition constant.
void SearchDirection(const arma::mat &gradient, const size_t iterationNum, const double scalingFactor, arma::mat &searchDirection)
Find the L-BFGS search direction.
Linear algebra utility functions, generally performed on matrices or vectors.
double Factr() const
Get the factr value.
size_t & MaxIterations()
Modify the maximum number of iterations.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Wolfe() const
Get the Wolfe parameter.
size_t maxLineSearchTrials
Maximum number of trials for the line search.
arma::cube y
Stores all the y matrices in memory.
size_t & NumBasis()
Modify the memory size.
size_t MaxIterations() const
Get the maximum number of iterations.
bool GradientNormTooSmall(const arma::mat &gradient)
Check to make sure that the norm of the gradient is not smaller than 1e-5.
double & ArmijoConstant()
Modify the Armijo condition constant.
double ChooseScalingFactor(const size_t iterationNum, const arma::mat &gradient)
Calculate the scaling factor, gamma, which is used to scale the Hessian approximation matrix...
double minGradientNorm
Minimum gradient norm required to continue the optimization.
double maxStep
Maximum step of the line search.
double minStep
Minimum step of the line search.
double & MinGradientNorm()
Modify the minimum gradient norm.
double armijoConstant
Parameter for determining the Armijo condition.
double & MaxStep()
Modify the maximum line search step size.
size_t & MaxLineSearchTrials()
Modify the maximum number of line search trials.
bool LineSearch(double &functionValue, arma::mat &iterate, arma::mat &gradient, const arma::mat &searchDirection)
Perform a back-tracking line search along the search direction to calculate a step size satisfying th...
FunctionType & Function()
Modify the function that is being optimized.
double & Wolfe()
Modify the Wolfe parameter.
const FunctionType & Function() const
Return the function that is being optimized.
arma::mat newIterateTmp
Position of the new iterate.
arma::cube s
Stores all the s matrices in memory.
double & MinStep()
Modify the minimum line search step size.
size_t maxIterations
Maximum number of iterations.
size_t NumBasis() const
Get the memory size.
size_t MaxLineSearchTrials() const
Get the maximum number of line search trials.
const std::pair< arma::mat, double > & MinPointIterate() const
Return the point where the lowest function value has been found.
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.
double Evaluate(const arma::mat &iterate)
Evaluate the function at the given iterate point and store the result if it is a new minimum...
std::pair< arma::mat, double > minPointIterate
Best point found so far.
double Optimize(arma::mat &iterate)
Use L-BFGS to optimize the given function, starting at the given iterate point and finding the minimu...
The generic L-BFGS optimizer, which uses a back-tracking line search algorithm to minimize a function...
double wolfe
Parameter for detecting the Wolfe condition.
double MinStep() const
Return the minimum line search step size.
double & Factr()
Modify the factr value.
double MaxStep() const
Return the maximum line search step size.
double MinGradientNorm() const
Get the minimum gradient norm.
void UpdateBasisSet(const size_t iterationNum, const arma::mat &iterate, const arma::mat &oldIterate, const arma::mat &gradient, const arma::mat &oldGradient)
Update the y and s matrices, which store the differences between the iterate and old iterate and the ...
size_t numBasis
Size of memory for this L-BFGS optimizer.