15 #ifndef __MLPACK_CORE_OPTIMIZERS_LBFGS_LBFGS_HPP 16 #define __MLPACK_CORE_OPTIMIZERS_LBFGS_LBFGS_HPP 21 namespace optimization {
35 template<
typename FunctionType>
59 L_BFGS(FunctionType&
function,
63 const double wolfe = 0.9,
65 const double factr = 1e-15,
106 const FunctionType&
Function()
const {
return function; }
157 FunctionType&
function;
194 double Evaluate(
const arma::mat& iterate);
204 const arma::mat& gradient);
230 const arma::mat& searchDirection);
241 const size_t iterationNum,
242 const double scalingFactor,
243 arma::mat& searchDirection);
257 const arma::mat& iterate,
258 const arma::mat& oldIterate,
259 const arma::mat& gradient,
260 const arma::mat& oldGradient);
266 #include "lbfgs_impl.hpp" 268 #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.
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.
L_BFGS(FunctionType &function, const size_t numBasis=10, const size_t maxIterations=0, 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.
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.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
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.
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.