shark::LBFGS Class Reference

Limited-Memory Broyden, Fletcher, Goldfarb, Shannon algorithm for unconstrained optimization. More...

#include <shark/Algorithms/GradientDescent/LBFGS.h>

+ Inheritance diagram for shark::LBFGS:

Public Member Functions

 LBFGS ()
 
std::string name () const
 From INameable: return the class name. More...
 
void setHistCount (unsigned int numhist)
 Specify the amount of steps to be memorized and used to find the L-BFGS direction. More...
 
SHARK_EXPORT_SYMBOL void read (InArchive &archive)
 Read the component from the supplied archive. More...
 
SHARK_EXPORT_SYMBOL void write (OutArchive &archive) const
 Write the component to the supplied archive. More...
 
- Public Member Functions inherited from shark::AbstractLineSearchOptimizer
SHARK_EXPORT_SYMBOL AbstractLineSearchOptimizer ()
 
SHARK_EXPORT_SYMBOL void init (ObjectiveFunctionType &objectiveFunction, SearchPointType const &startingPoint)
 initializes the optimizer using a predefined starting point More...
 
SHARK_EXPORT_SYMBOL void step (ObjectiveFunctionType const &objectiveFunction)
 Carry out one step of the optimizer for the supplied objective function. More...
 
LineSearch const & lineSearch () const
 
LineSearchlineSearch ()
 
- Public Member Functions inherited from shark::AbstractSingleObjectiveOptimizer< RealVector >
virtual void init (ObjectiveFunctionType &function)
 
virtual const SolutionTypesolution () const
 returns the current solution of the optimizer More...
 
- Public Member Functions inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > >
const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool requiresValue () const
 
bool requiresFirstDerivative () const
 
bool requiresSecondDerivative () const
 
bool canSolveConstrained () const
 
bool requiresClosestFeasible () const
 
virtual ~AbstractOptimizer ()
 Empty virtual d'tor. More...
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor. More...
 
void load (InArchive &archive, unsigned int version)
 Versioned loading of components, calls read(...). More...
 
void save (OutArchive &archive, unsigned int version) const
 Versioned storing of components, calls write(...). More...
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 

Protected Member Functions

SHARK_EXPORT_SYMBOL void initModel ()
 Initializes the internal model. More...
 
SHARK_EXPORT_SYMBOL void computeSearchDirection ()
 Updates the Model and computes the next search direction. More...
 
SHARK_EXPORT_SYMBOL void updateHist (RealVector &y, RealVector &step)
 Stores another step and searchDirection, discarding the oldest on if necessary. More...
 
SHARK_EXPORT_SYMBOL void getDirection (RealVector &searchDirection)
 Get the LBFGS direction. More...
 
- Protected Member Functions inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > >
void checkFeatures (ObjectiveFunctionType const &objectiveFunction)
 Convenience function that checks whether the features of the supplied objective function match with the required features of the optimizer. More...
 

Protected Attributes

double m_updThres
 Threshold for when to update history. More...
 
unsigned int m_numHist
 Number of steps to use for LBFGS. More...
 
double m_hdiag
 
std::deque< RealVector > m_steps
 
std::deque< RealVector > m_gradientDifferences
 
- Protected Attributes inherited from shark::AbstractLineSearchOptimizer
LineSearch m_linesearch
 used line search method. More...
 
std::size_t m_dimension
 number of parameters More...
 
double m_initialStepLength
 Initial step length to begin with the line search. More...
 
RealVector m_derivative
 gradient of m_best.point More...
 
RealVector m_searchDirection
 search direction of next step More...
 
RealVector m_lastPoint
 previous point More...
 
RealVector m_lastDerivative
 gradient of the previous point More...
 
double m_lastValue
 value of the previous point More...
 
- Protected Attributes inherited from shark::AbstractSingleObjectiveOptimizer< RealVector >
SolutionType m_best
 current solution of the optimizer More...
 
- Protected Attributes inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > >
Features m_features
 

Additional Inherited Members

- Public Types inherited from shark::AbstractSingleObjectiveOptimizer< RealVector >
typedef base_type::SearchPointType SearchPointType
 
typedef base_type::SolutionType SolutionType
 
typedef base_type::ResultType ResultType
 
typedef base_type::ObjectiveFunctionType ObjectiveFunctionType
 
- Public Types inherited from shark::AbstractOptimizer< RealVector, double, SingleObjectiveResultSet< RealVector > >
enum  Feature
 Models features that the optimizer requires from the objective function. More...
 
typedef RealVector SearchPointType
 
typedef double ResultType
 
typedef SingleObjectiveResultSet< RealVector > SolutionType
 
typedef AbstractObjectiveFunction< RealVector, ResultTypeObjectiveFunctionType
 
typedef TypedFlags< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Detailed Description

Limited-Memory Broyden, Fletcher, Goldfarb, Shannon algorithm for unconstrained optimization.

Definition at line 50 of file LBFGS.h.

Constructor & Destructor Documentation

§ LBFGS()

shark::LBFGS::LBFGS ( )
inline

Definition at line 55 of file LBFGS.h.

Member Function Documentation

§ computeSearchDirection()

SHARK_EXPORT_SYMBOL void shark::LBFGS::computeSearchDirection ( )
protectedvirtual

Updates the Model and computes the next search direction.

After a step was performed, this method is called to compute the next search direction. This usually involves updating the internal model using the new and old step information. Afterwards m_searchDirection should contain the next search direction.

Implements shark::AbstractLineSearchOptimizer.

§ getDirection()

SHARK_EXPORT_SYMBOL void shark::LBFGS::getDirection ( RealVector &  searchDirection)
protected

Get the LBFGS direction.

This approximates the inverse hessian multiplied by the gradient. This uses the rho, alpha and beta vectors. Description of these can be seen in ie. the wiki page of LBFGS.

Referenced by setHistCount().

§ initModel()

SHARK_EXPORT_SYMBOL void shark::LBFGS::initModel ( )
protectedvirtual

Initializes the internal model.

Line Search Methods use a Model to search for the next search direction. The model is initialized during init()

Implements shark::AbstractLineSearchOptimizer.

§ name()

std::string shark::LBFGS::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 58 of file LBFGS.h.

§ read()

SHARK_EXPORT_SYMBOL void shark::LBFGS::read ( InArchive archive)
virtual

Read the component from the supplied archive.

Parameters
[in,out]archiveThe archive to read from.

Reimplemented from shark::AbstractLineSearchOptimizer.

Referenced by setHistCount().

§ setHistCount()

void shark::LBFGS::setHistCount ( unsigned int  numhist)
inline

Specify the amount of steps to be memorized and used to find the L-BFGS direction.

Parameters
numhistThe amount of steps to use.

Definition at line 64 of file LBFGS.h.

References getDirection(), m_numHist, read(), SHARK_CHECK, SHARK_EXPORT_SYMBOL, shark::AbstractLineSearchOptimizer::step(), updateHist(), and write().

§ updateHist()

SHARK_EXPORT_SYMBOL void shark::LBFGS::updateHist ( RealVector &  y,
RealVector &  step 
)
protected

Stores another step and searchDirection, discarding the oldest on if necessary.

Parameters
stepLast performed step
ydifference in gradients

Referenced by setHistCount().

§ write()

SHARK_EXPORT_SYMBOL void shark::LBFGS::write ( OutArchive archive) const
virtual

Write the component to the supplied archive.

Parameters
[in,out]archiveThe archive to write to.

Reimplemented from shark::AbstractLineSearchOptimizer.

Referenced by setHistCount().

Member Data Documentation

§ m_gradientDifferences

std::deque<RealVector> shark::LBFGS::m_gradientDifferences
protected

Definition at line 99 of file LBFGS.h.

§ m_hdiag

double shark::LBFGS::m_hdiag
protected

Definition at line 92 of file LBFGS.h.

§ m_numHist

unsigned int shark::LBFGS::m_numHist
protected

Number of steps to use for LBFGS.

Definition at line 89 of file LBFGS.h.

Referenced by setHistCount().

§ m_steps

std::deque<RealVector> shark::LBFGS::m_steps
protected

Definition at line 98 of file LBFGS.h.

§ m_updThres

double shark::LBFGS::m_updThres
protected

Threshold for when to update history.

Definition at line 88 of file LBFGS.h.


The documentation for this class was generated from the following file: