primatologist-gpl  5.0.5
aims::Newton< O, L > Class Template Reference

Newton's Method for optimization. More...

#include <primatologist/optimization/newton_decl.h>

Collaboration diagram for aims::Newton< O, L >:

Public Types

typedef O Objective
 
typedef L< O > LineSearch
 
typedef math::Matrix Matrix
 
typedef math::Vector Vector
 

Public Member Functions

 Newton (const Objective &f=Objective(), const Vector &x=Vector())
 
 Newton (const Newton< O, L > &other)
 
 ~Newton ()
 
Newton< O, L > & operator= (const Newton< O, L > &other)
 
void setGamma (float gamma=0.1)
 
void setStopCriterion (const std::string &crit="absdiff")
 Can take values: More...
 
void setStopValue (float epsilon=1E-5)
 
void setLineSearch (const LineSearch &l=LineSearch())
 
void setMaximize (bool maximize=false)
 
void setMaxIterations (int n=- 1)
 
void setVerbose (int v=carto::verbose)
 
void setObjectiveFunction (const Objective &f)
 
void setPosition (const Vector &x=Vector())
 
float gamma () const
 
const std::string & stopCriterion () const
 
float stopValue () const
 
LineSearchlineSearch ()
 
bool maximize () const
 
int maxIterations () const
 
int verbose () const
 
const Vectorposition () const
 
const ObjectiveobjectiveFunction () const
 
Vector execute ()
 

Protected Attributes

float _gamma
 Fixed Gamma or initial gamma for line search. More...
 
Vector _x
 position More...
 
Objective _f
 objectiveFunction More...
 
LineSearch _ls
 lineSearch More...
 
int _verbose
 verbosity level More...
 
bool _maximize
 maximize or minimize More...
 
int _max_it
 maximum number of iterations More...
 
std::string _crit
 stop criterion More...
 
float _epsilon
 stop value More...
 

Detailed Description

template<typename O, template< typename > class L = NoLineSearch>
class aims::Newton< O, L >

Newton's Method for optimization.

Template Parameters
OObjective function type. It should implement functions value(Vector), derivative(Vector) and hessian(Vector)
L[optional] Line search type. A line search method can be used to select the next position each time a search is found. This can be useful to avoid too small or too large steps.

Definition at line 31 of file newton_decl.h.

Member Typedef Documentation

◆ LineSearch

template<typename O, template< typename > class L = NoLineSearch>
typedef L<O> aims::Newton< O, L >::LineSearch

Definition at line 38 of file newton_decl.h.

◆ Matrix

template<typename O, template< typename > class L = NoLineSearch>
typedef math::Matrix aims::Newton< O, L >::Matrix

Definition at line 39 of file newton_decl.h.

◆ Objective

template<typename O, template< typename > class L = NoLineSearch>
typedef O aims::Newton< O, L >::Objective

Definition at line 37 of file newton_decl.h.

◆ Vector

template<typename O, template< typename > class L = NoLineSearch>
typedef math::Vector aims::Newton< O, L >::Vector

Definition at line 40 of file newton_decl.h.

Constructor & Destructor Documentation

◆ Newton() [1/2]

template<typename O , template< typename > class L>
aims::Newton< O, L >::Newton ( const Objective f = Objective(),
const Vector x = Vector() 
)

◆ Newton() [2/2]

template<typename O , template< typename > class L>
aims::Newton< O, L >::Newton ( const Newton< O, L > &  other)

Definition at line 36 of file newton_d.h.

◆ ~Newton()

template<typename O , template< typename > class L>
aims::Newton< O, L >::~Newton ( )

Definition at line 47 of file newton_d.h.

Member Function Documentation

◆ execute()

◆ gamma()

template<typename O , template< typename > class L>
float aims::Newton< O, L >::gamma ( ) const

◆ lineSearch()

◆ maximize()

template<typename O , template< typename > class L>
bool aims::Newton< O, L >::maximize ( ) const

◆ maxIterations()

template<typename O , template< typename > class L>
int aims::Newton< O, L >::maxIterations ( ) const

Definition at line 167 of file newton_d.h.

References aims::Newton< O, L >::_max_it.

Referenced by aims::Newton< O, L >::execute().

◆ objectiveFunction()

template<typename O , template< typename > class L>
const Newton< O, L >::Objective & aims::Newton< O, L >::objectiveFunction ( ) const

◆ operator=()

template<typename O , template< typename > class L>
Newton< O, L > & aims::Newton< O, L >::operator= ( const Newton< O, L > &  other)

◆ position()

template<typename O , template< typename > class L>
const Newton< O, L >::Vector & aims::Newton< O, L >::position ( ) const

Definition at line 180 of file newton_d.h.

References aims::Newton< O, L >::_x.

Referenced by aims::Newton< O, L >::execute().

◆ setGamma()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setGamma ( float  gamma = 0.1)

Definition at line 72 of file newton_d.h.

References aims::Newton< O, L >::_gamma, and aims::Newton< O, L >::gamma().

Referenced by aims::Newton< O, L >::Newton().

◆ setLineSearch()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setLineSearch ( const LineSearch l = LineSearch())
Warning
the LineSearch object needs to be copiable and thus needs a copy constructor and an assignment operator

Definition at line 90 of file newton_d.h.

References aims::Newton< O, L >::_ls, aims::Newton< O, L >::lineSearch(), aims::Newton< O, L >::maximize(), aims::Newton< O, L >::objectiveFunction(), and aims::Newton< O, L >::verbose().

Referenced by aims::Newton< O, L >::Newton().

◆ setMaximize()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setMaximize ( bool  maximize = false)

◆ setMaxIterations()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setMaxIterations ( int  n = - 1)

Definition at line 106 of file newton_d.h.

References aims::Newton< O, L >::_max_it.

Referenced by aims::Newton< O, L >::Newton().

◆ setObjectiveFunction()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setObjectiveFunction ( const Objective f)
Warning
the Objective function needs to be copiable and thus needs a copy constructor and an assignment operator

Definition at line 119 of file newton_d.h.

References aims::Newton< O, L >::_f, and aims::Newton< O, L >::lineSearch().

◆ setPosition()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setPosition ( const Vector x = Vector())

Definition at line 126 of file newton_d.h.

References aims::Newton< O, L >::_x.

◆ setStopCriterion()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setStopCriterion ( const std::string &  crit = "absdiff")

Can take values:

  • absdiff
  • gain

Definition at line 78 of file newton_d.h.

References aims::Newton< O, L >::_crit.

Referenced by aims::Newton< O, L >::Newton().

◆ setStopValue()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setStopValue ( float  epsilon = 1E-5)

Definition at line 84 of file newton_d.h.

References aims::Newton< O, L >::_epsilon.

Referenced by aims::Newton< O, L >::Newton().

◆ setVerbose()

template<typename O , template< typename > class L>
void aims::Newton< O, L >::setVerbose ( int  v = carto::verbose)

◆ stopCriterion()

template<typename O , template< typename > class L>
const std::string & aims::Newton< O, L >::stopCriterion ( ) const

Definition at line 142 of file newton_d.h.

References aims::Newton< O, L >::_crit.

Referenced by aims::Newton< O, L >::execute().

◆ stopValue()

template<typename O , template< typename > class L>
float aims::Newton< O, L >::stopValue ( ) const

Definition at line 148 of file newton_d.h.

References aims::Newton< O, L >::_epsilon.

Referenced by aims::Newton< O, L >::execute().

◆ verbose()

template<typename O , template< typename > class L>
int aims::Newton< O, L >::verbose ( ) const

Member Data Documentation

◆ _crit

template<typename O, template< typename > class L = NoLineSearch>
std::string aims::Newton< O, L >::_crit
protected

stop criterion

Definition at line 106 of file newton_decl.h.

Referenced by aims::Newton< O, L >::setStopCriterion(), and aims::Newton< O, L >::stopCriterion().

◆ _epsilon

template<typename O, template< typename > class L = NoLineSearch>
float aims::Newton< O, L >::_epsilon
protected

stop value

Definition at line 107 of file newton_decl.h.

Referenced by aims::Newton< O, L >::setStopValue(), and aims::Newton< O, L >::stopValue().

◆ _f

template<typename O, template< typename > class L = NoLineSearch>
Objective aims::Newton< O, L >::_f
protected

◆ _gamma

template<typename O, template< typename > class L = NoLineSearch>
float aims::Newton< O, L >::_gamma
protected

Fixed Gamma or initial gamma for line search.

Definition at line 99 of file newton_decl.h.

Referenced by aims::Newton< O, L >::gamma(), aims::Newton< O, L >::operator=(), and aims::Newton< O, L >::setGamma().

◆ _ls

template<typename O, template< typename > class L = NoLineSearch>
LineSearch aims::Newton< O, L >::_ls
protected

◆ _max_it

template<typename O, template< typename > class L = NoLineSearch>
int aims::Newton< O, L >::_max_it
protected

maximum number of iterations

Definition at line 105 of file newton_decl.h.

Referenced by aims::Newton< O, L >::maxIterations(), aims::Newton< O, L >::operator=(), and aims::Newton< O, L >::setMaxIterations().

◆ _maximize

template<typename O, template< typename > class L = NoLineSearch>
bool aims::Newton< O, L >::_maximize
protected

◆ _verbose

template<typename O, template< typename > class L = NoLineSearch>
int aims::Newton< O, L >::_verbose
protected

◆ _x

template<typename O, template< typename > class L = NoLineSearch>
Vector aims::Newton< O, L >::_x
protected

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