shark::AbstractLineSearchOptimizer< SearchPointType > Class Template Referenceabstract

Basis class for line search methods. More...

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

+ Inheritance diagram for shark::AbstractLineSearchOptimizer< SearchPointType >:

Public Types

typedef AbstractSingleObjectiveOptimizer< SearchPointType >::ObjectiveFunctionType ObjectiveFunctionType
 
- Public Types inherited from shark::AbstractSingleObjectiveOptimizer< SearchPointType >
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< PointType, ResultT, SolutionTypeT >
enum  Feature {
  REQUIRES_VALUE = 1 , REQUIRES_FIRST_DERIVATIVE = 2 , REQUIRES_SECOND_DERIVATIVE = 4 , CAN_SOLVE_CONSTRAINED = 8 ,
  REQUIRES_CLOSEST_FEASIBLE = 16
}
 Models features that the optimizer requires from the objective function. More...
 
typedef PointType SearchPointType
 
typedef ResultT ResultType
 
typedef SolutionTypeT SolutionType
 
typedef AbstractObjectiveFunction< PointType, ResultTypeObjectiveFunctionType
 
typedef TypedFlags< FeatureFeatures
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Public Member Functions

 AbstractLineSearchOptimizer ()
 
void init (ObjectiveFunctionType const &objectiveFunction, SearchPointType const &startingPoint)
 
void step (ObjectiveFunctionType const &objectiveFunction)
 
void read (InArchive &archive)
 Read the component from the supplied archive.
 
void write (OutArchive &archive) const
 Write the component to the supplied archive.
 
LineSearch< SearchPointType > const & lineSearch () const
 
LineSearch< SearchPointType > & lineSearch ()
 
SearchPointType const & derivative () const
 Returns the derivative at the current point. Can be used for stopping criteria.
 
- Public Member Functions inherited from shark::AbstractSingleObjectiveOptimizer< SearchPointType >
std::size_t numInitPoints () const
 By default most single objective optimizers only require a single point.
 
virtual void init (ObjectiveFunctionType const &function, std::vector< SearchPointType > const &initPoints)
 Initialize the optimizer for the supplied objective function using a set of initialisation points.
 
virtual void init (ObjectiveFunctionType const &function, SearchPointType const &startingPoint)=0
 initializes the optimizer using a predefined starting point
 
virtual const SolutionTypesolution () const
 returns the current solution of the optimizer
 
- Public Member Functions inherited from shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >
const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool requiresValue () const
 
bool requiresFirstDerivative () const
 
bool requiresSecondDerivative () const
 
bool canSolveConstrained () const
 
bool requiresClosestFeasible () const
 
virtual ~AbstractOptimizer ()
 
virtual void init (ObjectiveFunctionType const &function)
 Initialize the optimizer for the supplied objective function.
 
virtual void init (ObjectiveFunctionType const &function, std::vector< SearchPointType > const &initPoints)=0
 Initialize the optimizer for the supplied objective function using a set of initialisation points.
 
virtual void step (ObjectiveFunctionType const &function)=0
 Carry out one step of the optimizer for the supplied objective function.
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 
virtual std::string name () const
 returns the name of the object
 
- Public Member Functions inherited from shark::ISerializable
virtual ~ISerializable ()
 Virtual d'tor.
 
void load (InArchive &archive, unsigned int version)
 Versioned loading of components, calls read(...).
 
void save (OutArchive &archive, unsigned int version) const
 Versioned storing of components, calls write(...).
 
 BOOST_SERIALIZATION_SPLIT_MEMBER ()
 

Protected Member Functions

virtual void initModel ()=0
 Initializes the internal model.
 
virtual void computeSearchDirection (ObjectiveFunctionType const &objectiveFunction)=0
 Updates the Model and computes the next search direction.
 
- Protected Member Functions inherited from shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >
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.
 

Protected Attributes

LineSearch< SearchPointTypem_linesearch
 used line search method.
 
std::size_t m_dimension
 number of parameters
 
double m_initialStepLength
 Initial step length to begin with the line search.
 
SearchPointType m_derivative
 gradient of m_best.point
 
SearchPointType m_searchDirection
 search direction of next step
 
SearchPointType m_lastPoint
 previous point
 
SearchPointType m_lastDerivative
 gradient of the previous point
 
double m_lastValue
 value of the previous point
 
- Protected Attributes inherited from shark::AbstractSingleObjectiveOptimizer< SearchPointType >
SolutionType m_best
 Current solution of the optimizer.
 
- Protected Attributes inherited from shark::AbstractOptimizer< PointType, ResultT, SolutionTypeT >
Features m_features
 

Detailed Description

template<class SearchPointType>
class shark::AbstractLineSearchOptimizer< SearchPointType >

Basis class for line search methods.

Line Search optimizer find an iterative optimum by starting from some point, choosing a search direction and than performing a line search in that direction. To choose the search direction a local model of the function is often used. This class is a base class for all line search method which implement the general behaviour of line search methods. Derived classes only need to implement initModel() and computeSearchDirection() to initializee and update the model and find a new line search direction. The remaining functionality is implemented by the optimizer.

Also derived classes should specialise read() and write() methods for serialization if they have additional members as well as choose a name() for the optimizer.

Definition at line 56 of file AbstractLineSearchOptimizer.h.

Member Typedef Documentation

◆ ObjectiveFunctionType

template<class SearchPointType >
typedef AbstractSingleObjectiveOptimizer<SearchPointType>::ObjectiveFunctionType shark::AbstractLineSearchOptimizer< SearchPointType >::ObjectiveFunctionType

Definition at line 58 of file AbstractLineSearchOptimizer.h.

Constructor & Destructor Documentation

◆ AbstractLineSearchOptimizer()

template<class SearchPointType >
shark::AbstractLineSearchOptimizer< SearchPointType >::AbstractLineSearchOptimizer ( )

Member Function Documentation

◆ computeSearchDirection()

template<class SearchPointType >
virtual void shark::AbstractLineSearchOptimizer< SearchPointType >::computeSearchDirection ( ObjectiveFunctionType const &  objectiveFunction)
protectedpure virtual

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.

Implemented in shark::BFGS< SearchPointType >, shark::LBFGS< SearchPointType >, and shark::CG< SearchPointType >.

◆ derivative()

template<class SearchPointType >
SearchPointType const & shark::AbstractLineSearchOptimizer< SearchPointType >::derivative ( ) const
inline

Returns the derivative at the current point. Can be used for stopping criteria.

Definition at line 98 of file AbstractLineSearchOptimizer.h.

References shark::AbstractLineSearchOptimizer< SearchPointType >::m_derivative.

◆ init()

template<class SearchPointType >
void shark::AbstractLineSearchOptimizer< SearchPointType >::init ( ObjectiveFunctionType const &  objectiveFunction,
SearchPointType const &  startingPoint 
)

Referenced by main(), and main().

◆ initModel()

template<class SearchPointType >
virtual void shark::AbstractLineSearchOptimizer< SearchPointType >::initModel ( )
protectedpure virtual

Initializes the internal model.

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

Implemented in shark::BFGS< SearchPointType >, shark::CG< SearchPointType >, and shark::LBFGS< SearchPointType >.

◆ lineSearch() [1/2]

◆ lineSearch() [2/2]

◆ read()

template<class SearchPointType >
void shark::AbstractLineSearchOptimizer< SearchPointType >::read ( InArchive archive)
virtual

Read the component from the supplied archive.

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

Reimplemented from shark::ISerializable.

Reimplemented in shark::BFGS< SearchPointType >, shark::CG< SearchPointType >, and shark::LBFGS< SearchPointType >.

◆ step()

template<class SearchPointType >
void shark::AbstractLineSearchOptimizer< SearchPointType >::step ( ObjectiveFunctionType const &  objectiveFunction)

Referenced by main(), and main().

◆ write()

template<class SearchPointType >
void shark::AbstractLineSearchOptimizer< SearchPointType >::write ( OutArchive archive) const
virtual

Write the component to the supplied archive.

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

Reimplemented from shark::ISerializable.

Reimplemented in shark::BFGS< SearchPointType >, shark::CG< SearchPointType >, and shark::LBFGS< SearchPointType >.

Member Data Documentation

◆ m_derivative

gradient of m_best.point

Definition at line 109 of file AbstractLineSearchOptimizer.h.

Referenced by shark::AbstractLineSearchOptimizer< SearchPointType >::derivative().

◆ m_dimension

template<class SearchPointType >
std::size_t shark::AbstractLineSearchOptimizer< SearchPointType >::m_dimension
protected

number of parameters

Definition at line 106 of file AbstractLineSearchOptimizer.h.

◆ m_initialStepLength

template<class SearchPointType >
double shark::AbstractLineSearchOptimizer< SearchPointType >::m_initialStepLength
protected

Initial step length to begin with the line search.

Definition at line 107 of file AbstractLineSearchOptimizer.h.

◆ m_lastDerivative

template<class SearchPointType >
SearchPointType shark::AbstractLineSearchOptimizer< SearchPointType >::m_lastDerivative
protected

gradient of the previous point

Definition at line 114 of file AbstractLineSearchOptimizer.h.

◆ m_lastPoint

previous point

Definition at line 113 of file AbstractLineSearchOptimizer.h.

◆ m_lastValue

template<class SearchPointType >
double shark::AbstractLineSearchOptimizer< SearchPointType >::m_lastValue
protected

value of the previous point

Definition at line 115 of file AbstractLineSearchOptimizer.h.

◆ m_linesearch

◆ m_searchDirection

template<class SearchPointType >
SearchPointType shark::AbstractLineSearchOptimizer< SearchPointType >::m_searchDirection
protected

search direction of next step

Definition at line 110 of file AbstractLineSearchOptimizer.h.


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