SYNOPSIS

Public Member Functions

L_BFGS (FunctionType &function, const size_t numBasis=5, const size_t maxIterations=0, const double armijoConstant=1e-4, const double wolfe=0.9, const double minGradientNorm=1e-10, const size_t maxLineSearchTrials=50, const double minStep=1e-20, const double maxStep=1e20)

Initialize the L-BFGS object. double ArmijoConstant () const

Get the Armijo condition constant. double & ArmijoConstant ()

Modify the Armijo condition constant. const FunctionType & Function () const

Return the function that is being optimized. FunctionType & Function ()

Modify the function that is being optimized. size_t MaxIterations () const

Get the maximum number of iterations. size_t & MaxIterations ()

Modify the maximum number of iterations. size_t MaxLineSearchTrials () const

Get the maximum number of line search trials. size_t & MaxLineSearchTrials ()

Modify the maximum number of line search trials. double MaxStep () const

Return the maximum line search step size. double & MaxStep ()

Modify the maximum line search step size. double MinGradientNorm () const

Get the minimum gradient norm. double & MinGradientNorm ()

Modify the minimum gradient norm. const std::pair< arma::mat,

double > & MinPointIterate () const "

Return the point where the lowest function value has been found. double MinStep () const

Return the minimum line search step size. double & MinStep ()

Modify the minimum line search step size. size_t NumBasis () const

Get the memory size. size_t & NumBasis ()

Modify the memory size. double Optimize (arma::mat &iterate)

Use L-BFGS to optimize the given function, starting at the given iterate point and finding the minimum. double Optimize (arma::mat &iterate, const size_t maxIterations)

Use L-BFGS to optimize (minimize) the given function, starting at the given iterate point, and performing no more than the given maximum number of iterations (the class variable maxIterations is ignored for this run, but not modified). std::string ToString () const

double Wolfe () const

Get the Wolfe parameter. double & Wolfe ()

Modify the Wolfe parameter.

Private Member Functions

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 Evaluate (const arma::mat &iterate)

Evaluate the function at the given iterate point and store the result if it is a new minimum. bool GradientNormTooSmall (const arma::mat &gradient)

Check to make sure that the norm of the gradient is not smaller than 1e-5. 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 the Wolfe conditions. void SearchDirection (const arma::mat &gradient, const size_t iterationNum, const double scalingFactor, arma::mat &searchDirection)

Find the L-BFGS search direction. 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 differences between the gradient and the old gradient, respectively.

Private Attributes

double armijoConstant

Parameter for determining the Armijo condition. FunctionType & function

Internal reference to the function we are optimizing. size_t maxIterations

Maximum number of iterations. size_t maxLineSearchTrials

Maximum number of trials for the line search. double maxStep

Maximum step of the line search. double minGradientNorm

Minimum gradient norm required to continue the optimization. std::pair< arma::mat, double > minPointIterate

Best point found so far. double minStep

Minimum step of the line search. arma::mat newIterateTmp

Position of the new iterate. size_t numBasis

Size of memory for this L-BFGS optimizer. arma::cube s

Stores all the s matrices in memory. double wolfe

Parameter for detecting the Wolfe condition. arma::cube y

Stores all the y matrices in memory.

Detailed Description

template<typename FunctionType>class mlpack::optimization::L_BFGS< FunctionType >

The generic L-BFGS optimizer, which uses a back-tracking line search algorithm to minimize a function.

The parameters for the algorithm (number of memory points, maximum step size, and so forth) are all configurable via either the constructor or standalone modifier functions. A function which can be optimized by this class must implement the following methods:

  • a default constructor

  • double Evaluate(const arma::mat& coordinates);

  • void Gradient(const arma::mat& coordinates, arma::mat& gradient);

  • arma::mat& GetInitialPoint();

Definition at line 44 of file lbfgs.hpp.

Constructor & Destructor Documentation

template<typename FunctionType> \fBmlpack::optimization::L_BFGS\fP< FunctionType >::\fBL_BFGS\fP (FunctionType &function, const size_tnumBasis = \fC5\fP, const size_tmaxIterations = \fC0\fP, const doublearmijoConstant = \fC1e-4\fP, const doublewolfe = \fC0.9\fP, const doubleminGradientNorm = \fC1e-10\fP, const size_tmaxLineSearchTrials = \fC50\fP, const doubleminStep = \fC1e-20\fP, const doublemaxStep = \fC1e20\fP)

Initialize the L-BFGS object. Store a reference to the function we will be optimizing and set the size of the memory for the algorithm. There are many parameters that can be set for the optimization, but default values are given for each of them.

Parameters:

function Instance of function to be optimized.

numBasis Number of memory points to be stored (default 5).

maxIterations Maximum number of iterations for the optimization (default 0 -- may run indefinitely).

armijoConstant Controls the accuracy of the line search routine for determining the Armijo condition.

wolfe Parameter for detecting the Wolfe condition.

minGradientNorm Minimum gradient norm required to continue the optimization.

maxLineSearchTrials The maximum number of trials for the line search (before giving up).

minStep The minimum step of the line search.

maxStep The maximum step of the line search.

Member Function Documentation

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::ArmijoConstant () const\fC [inline]\fP

Get the Armijo condition constant.

Definition at line 128 of file lbfgs.hpp.

template<typename FunctionType> double& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::ArmijoConstant ()\fC [inline]\fP

Modify the Armijo condition constant.

Definition at line 130 of file lbfgs.hpp.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::ChooseScalingFactor (const size_titerationNum, const arma::mat &gradient)\fC [private]\fP

Calculate the scaling factor, gamma, which is used to scale the Hessian approximation matrix. See method M3 in Section 4 of Liu and Nocedal (1989).

Returns:

The calculated scaling factor.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::Evaluate (const arma::mat &iterate)\fC [private]\fP

Evaluate the function at the given iterate point and store the result if it is a new minimum.

Returns:

The value of the function.

template<typename FunctionType> const FunctionType& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::Function () const\fC [inline]\fP

Return the function that is being optimized.

Definition at line 113 of file lbfgs.hpp.

template<typename FunctionType> FunctionType& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::Function ()\fC [inline]\fP

Modify the function that is being optimized.

Definition at line 115 of file lbfgs.hpp.

template<typename FunctionType> bool \fBmlpack::optimization::L_BFGS\fP< FunctionType >::GradientNormTooSmall (const arma::mat &gradient)\fC [private]\fP

Check to make sure that the norm of the gradient is not smaller than 1e-5. Currently that value is not configurable.

Returns:

(norm < minGradientNorm).

template<typename FunctionType> bool \fBmlpack::optimization::L_BFGS\fP< FunctionType >::LineSearch (double &functionValue, arma::mat &iterate, arma::mat &gradient, const arma::mat &searchDirection)\fC [private]\fP

Perform a back-tracking line search along the search direction to calculate a step size satisfying the Wolfe conditions. The parameter iterate will be modified if the method is successful.

Parameters:

functionValue Value of the function at the initial point

iterate The initial point to begin the line search from

gradient The gradient at the initial point

searchDirection A vector specifying the search direction

stepSize Variable the calculated step size will be stored in

Returns:

false if no step size is suitable, true otherwise.

template<typename FunctionType> size_t \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MaxIterations () const\fC [inline]\fP

Get the maximum number of iterations.

Definition at line 123 of file lbfgs.hpp.

template<typename FunctionType> size_t& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MaxIterations ()\fC [inline]\fP

Modify the maximum number of iterations.

Definition at line 125 of file lbfgs.hpp.

template<typename FunctionType> size_t \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MaxLineSearchTrials () const\fC [inline]\fP

Get the maximum number of line search trials.

Definition at line 143 of file lbfgs.hpp.

template<typename FunctionType> size_t& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MaxLineSearchTrials ()\fC [inline]\fP

Modify the maximum number of line search trials.

Definition at line 145 of file lbfgs.hpp.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MaxStep () const\fC [inline]\fP

Return the maximum line search step size.

Definition at line 153 of file lbfgs.hpp.

template<typename FunctionType> double& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MaxStep ()\fC [inline]\fP

Modify the maximum line search step size.

Definition at line 155 of file lbfgs.hpp.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MinGradientNorm () const\fC [inline]\fP

Get the minimum gradient norm.

Definition at line 138 of file lbfgs.hpp.

template<typename FunctionType> double& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MinGradientNorm ()\fC [inline]\fP

Modify the minimum gradient norm.

Definition at line 140 of file lbfgs.hpp.

template<typename FunctionType> const std::pair<arma::mat, double>& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MinPointIterate () const

Return the point where the lowest function value has been found.

Returns:

arma::vec representing the point and a double with the function value at that point.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MinStep () const\fC [inline]\fP

Return the minimum line search step size.

Definition at line 148 of file lbfgs.hpp.

template<typename FunctionType> double& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::MinStep ()\fC [inline]\fP

Modify the minimum line search step size.

Definition at line 150 of file lbfgs.hpp.

template<typename FunctionType> size_t \fBmlpack::optimization::L_BFGS\fP< FunctionType >::NumBasis () const\fC [inline]\fP

Get the memory size.

Definition at line 118 of file lbfgs.hpp.

template<typename FunctionType> size_t& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::NumBasis ()\fC [inline]\fP

Modify the memory size.

Definition at line 120 of file lbfgs.hpp.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::Optimize (arma::mat &iterate)

Use L-BFGS to optimize the given function, starting at the given iterate point and finding the minimum. The maximum number of iterations is set in the constructor (or with MaxIterations()). Alternately, another overload is provided which takes a maximum number of iterations as a parameter. The given starting point will be modified to store the finishing point of the algorithm, and the final objective value is returned.

Parameters:

iterate Starting point (will be modified).

Returns:

Objective value of the final point.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::Optimize (arma::mat &iterate, const size_tmaxIterations)

Use L-BFGS to optimize (minimize) the given function, starting at the given iterate point, and performing no more than the given maximum number of iterations (the class variable maxIterations is ignored for this run, but not modified). The given starting point will be modified to store the finishing point of the algorithm, and the final objective value is returned.

Parameters:

iterate Starting point (will be modified).

maxIterations Maximum number of iterations (0 specifies no limit).

Returns:

Objective value of the final point.

template<typename FunctionType> void \fBmlpack::optimization::L_BFGS\fP< FunctionType >::SearchDirection (const arma::mat &gradient, const size_titerationNum, const doublescalingFactor, arma::mat &searchDirection)\fC [private]\fP

Find the L-BFGS search direction.

Parameters:

gradient The gradient at the current point

iteration_num The iteration number

scaling_factor Scaling factor to use (see ChooseScalingFactor_())

search_direction Vector to store search direction in

template<typename FunctionType> std::string \fBmlpack::optimization::L_BFGS\fP< FunctionType >::ToString () const

template<typename FunctionType> void \fBmlpack::optimization::L_BFGS\fP< FunctionType >::UpdateBasisSet (const size_titerationNum, const arma::mat &iterate, const arma::mat &oldIterate, const arma::mat &gradient, const arma::mat &oldGradient)\fC [private]\fP

Update the y and s matrices, which store the differences between the iterate and old iterate and the differences between the gradient and the old gradient, respectively.

Parameters:

iterationNum Iteration number

iterate Current point

oldIterate Point at last iteration

gradient Gradient at current point (iterate)

oldGradient Gradient at last iteration point (oldIterate)

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::Wolfe () const\fC [inline]\fP

Get the Wolfe parameter.

Definition at line 133 of file lbfgs.hpp.

template<typename FunctionType> double& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::Wolfe ()\fC [inline]\fP

Modify the Wolfe parameter.

Definition at line 135 of file lbfgs.hpp.

Member Data Documentation

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::armijoConstant\fC [private]\fP

Parameter for determining the Armijo condition.

Definition at line 176 of file lbfgs.hpp.

Referenced by mlpack::optimization::L_BFGS< AugLagrangianFunction< mlpack::optimization::LRSDPFunction > >::ArmijoConstant().

template<typename FunctionType> FunctionType& \fBmlpack::optimization::L_BFGS\fP< FunctionType >::function\fC [private]\fP

Internal reference to the function we are optimizing.

Definition at line 162 of file lbfgs.hpp.

template<typename FunctionType> size_t \fBmlpack::optimization::L_BFGS\fP< FunctionType >::maxIterations\fC [private]\fP

Maximum number of iterations.

Definition at line 174 of file lbfgs.hpp.

Referenced by mlpack::optimization::L_BFGS< AugLagrangianFunction< mlpack::optimization::LRSDPFunction > >::MaxIterations().

template<typename FunctionType> size_t \fBmlpack::optimization::L_BFGS\fP< FunctionType >::maxLineSearchTrials\fC [private]\fP

Maximum number of trials for the line search.

Definition at line 182 of file lbfgs.hpp.

Referenced by mlpack::optimization::L_BFGS< AugLagrangianFunction< mlpack::optimization::LRSDPFunction > >::MaxLineSearchTrials().

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::maxStep\fC [private]\fP

Maximum step of the line search.

Definition at line 186 of file lbfgs.hpp.

Referenced by mlpack::optimization::L_BFGS< AugLagrangianFunction< mlpack::optimization::LRSDPFunction > >::MaxStep().

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::minGradientNorm\fC [private]\fP

Minimum gradient norm required to continue the optimization.

Definition at line 180 of file lbfgs.hpp.

Referenced by mlpack::optimization::L_BFGS< AugLagrangianFunction< mlpack::optimization::LRSDPFunction > >::MinGradientNorm().

template<typename FunctionType> std::pair<arma::mat, double> \fBmlpack::optimization::L_BFGS\fP< FunctionType >::minPointIterate\fC [private]\fP

Best point found so far.

Definition at line 189 of file lbfgs.hpp.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::minStep\fC [private]\fP

Minimum step of the line search.

Definition at line 184 of file lbfgs.hpp.

Referenced by mlpack::optimization::L_BFGS< AugLagrangianFunction< mlpack::optimization::LRSDPFunction > >::MinStep().

template<typename FunctionType> arma::mat \fBmlpack::optimization::L_BFGS\fP< FunctionType >::newIterateTmp\fC [private]\fP

Position of the new iterate.

Definition at line 165 of file lbfgs.hpp.

template<typename FunctionType> size_t \fBmlpack::optimization::L_BFGS\fP< FunctionType >::numBasis\fC [private]\fP

Size of memory for this L-BFGS optimizer.

Definition at line 172 of file lbfgs.hpp.

Referenced by mlpack::optimization::L_BFGS< AugLagrangianFunction< mlpack::optimization::LRSDPFunction > >::NumBasis().

template<typename FunctionType> arma::cube \fBmlpack::optimization::L_BFGS\fP< FunctionType >::s\fC [private]\fP

Stores all the s matrices in memory.

Definition at line 167 of file lbfgs.hpp.

template<typename FunctionType> double \fBmlpack::optimization::L_BFGS\fP< FunctionType >::wolfe\fC [private]\fP

Parameter for detecting the Wolfe condition.

Definition at line 178 of file lbfgs.hpp.

Referenced by mlpack::optimization::L_BFGS< AugLagrangianFunction< mlpack::optimization::LRSDPFunction > >::Wolfe().

template<typename FunctionType> arma::cube \fBmlpack::optimization::L_BFGS\fP< FunctionType >::y\fC [private]\fP

Stores all the y matrices in memory.

Definition at line 169 of file lbfgs.hpp.

Author

Generated automatically by Doxygen for MLPACK from the source code.