primatologist-gpl  5.0.5
aims::WolfeLineSearch< O > Class Template Reference

Once an ascent direction is given, this class performs a line search that respects wolfe conditions. More...

#include <primatologist/optimization/wolfe_decl.h>

Collaboration diagram for aims::WolfeLineSearch< O >:

Public Types

typedef O Objective
 
typedef math::Matrix Matrix
 
typedef math::Vector Vector
 

Public Member Functions

 WolfeLineSearch (const Objective &f=Objective(), const Vector &x=Vector(), const Vector &p=Vector())
 
 WolfeLineSearch (const WolfeLineSearch< O > &other)
 
 ~WolfeLineSearch ()
 
WolfeLineSearch< O > & operator= (const WolfeLineSearch< O > &other)
 
void setC1 (float c1=1E-4)
 
void setC2 (float c2=0.9)
 
void setStrongWolfe (bool strong=false)
 
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())
 
void setSearchDirection (const Vector &p=Vector())
 
float c1 () const
 
float c2 () const
 
bool strongWolfe () const
 
bool maximize () const
 
int maxIterations () const
 
int verbose () const
 
const ObjectiveobjectiveFunction () const
 
const Vectorposition () const
 
const VectorsearchDirection () const
 
Vector execute ()
 

Protected Member Functions

bool wolfe1 (float a) const
 Armijo (= Wolfe 1st) condition. More...
 
bool wolfe2w (float a) const
 weak 2nd Wolfe condition More...
 
bool wolfe2s (float a) const
 strong 2nd Wolfe condition More...
 
bool wolfe2 (float a) const
 select condition based on _strong More...
 
bool checkDirection ()
 Compute f(x) and <p, g(x)>. More...
 

Protected Attributes

float _c1
 Wolfe c1. More...
 
float _c2
 Wolfe c2. More...
 
Vector _x
 position More...
 
Vector _p
 ascentDirection More...
 
Objective _f
 objectiveFunction More...
 
bool _strong
 strongWolfe More...
 
int _verbose
 verbosity level More...
 
bool _maximize
 maximize or minimize More...
 
int _max_it
 maximum number of iterations More...
 
float _previous_value
 f(x) More...
 
float _current_value
 f(x + a.p) More...
 
float _previous_scalarprod
 <p, g(x)> More...
 

Detailed Description

template<typename O>
class aims::WolfeLineSearch< O >

Once an ascent direction is given, this class performs a line search that respects wolfe conditions.

Wolfe conditions depend on two parameters 0 < c1 < c2 < 1 and hold if: 1) f( x + a.p ) >= f(x) + c1.a.p * g( x ) , 2a) p * g( x + a.p ) >= c2.p * g( x ) , where x is the previous parameter value of the objective function, p is the provided search direction, f returns the value of the objective function, g returns its gradient and a is the step length optimzed by this line search. For strong wolfe condition, inequality 2a is replaced by inequality 2b: 2b) |p * g( x + a.p )| <= c2.|p * g( x )| .

Template Parameters
ModelAn objective function class that implements value( Vector ) and derivative( Vector )

Definition at line 38 of file wolfe_decl.h.

Member Typedef Documentation

◆ Matrix

template<typename O>
typedef math::Matrix aims::WolfeLineSearch< O >::Matrix

Definition at line 45 of file wolfe_decl.h.

◆ Objective

template<typename O>
typedef O aims::WolfeLineSearch< O >::Objective

Definition at line 44 of file wolfe_decl.h.

◆ Vector

template<typename O>
typedef math::Vector aims::WolfeLineSearch< O >::Vector

Definition at line 46 of file wolfe_decl.h.

Constructor & Destructor Documentation

◆ WolfeLineSearch() [1/2]

template<typename O >
aims::WolfeLineSearch< O >::WolfeLineSearch ( const Objective f = Objective(),
const Vector x = Vector(),
const Vector p = Vector() 
)
Warning
the Objective function needs to be copiable and thus needs a copy constructor and an assignment operator

Definition at line 27 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::setC1(), aims::WolfeLineSearch< O >::setC2(), aims::WolfeLineSearch< O >::setMaximize(), aims::WolfeLineSearch< O >::setMaxIterations(), aims::WolfeLineSearch< O >::setStrongWolfe(), and aims::WolfeLineSearch< O >::setVerbose().

◆ WolfeLineSearch() [2/2]

template<typename O >
aims::WolfeLineSearch< O >::WolfeLineSearch ( const WolfeLineSearch< O > &  other)

Definition at line 43 of file wolfe_d.h.

◆ ~WolfeLineSearch()

template<typename O >
aims::WolfeLineSearch< O >::~WolfeLineSearch ( )

Definition at line 59 of file wolfe_d.h.

Member Function Documentation

◆ c1()

template<typename O >
float aims::WolfeLineSearch< O >::c1 ( ) const

Definition at line 146 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_c1.

Referenced by aims::WolfeLineSearch< O >::setC1().

◆ c2()

template<typename O >
float aims::WolfeLineSearch< O >::c2 ( ) const

Definition at line 152 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_c2.

Referenced by aims::WolfeLineSearch< O >::setC2().

◆ checkDirection()

template<typename O >
bool aims::WolfeLineSearch< O >::checkDirection ( )
protected

◆ execute()

◆ maximize()

◆ maxIterations()

template<typename O >
int aims::WolfeLineSearch< O >::maxIterations ( ) const

Definition at line 197 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_max_it.

Referenced by aims::WolfeLineSearch< O >::execute().

◆ objectiveFunction()

◆ operator=()

◆ position()

template<typename O >
const WolfeLineSearch< O >::Vector & aims::WolfeLineSearch< O >::position ( ) const

Definition at line 159 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_x.

◆ searchDirection()

template<typename O >
const WolfeLineSearch< O >::Vector & aims::WolfeLineSearch< O >::searchDirection ( ) const

Definition at line 166 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_p.

◆ setC1()

template<typename O >
void aims::WolfeLineSearch< O >::setC1 ( float  c1 = 1E-4)

◆ setC2()

template<typename O >
void aims::WolfeLineSearch< O >::setC2 ( float  c2 = 0.9)

◆ setMaximize()

template<typename O >
void aims::WolfeLineSearch< O >::setMaximize ( bool  maximize = false)

◆ setMaxIterations()

template<typename O >
void aims::WolfeLineSearch< O >::setMaxIterations ( int  n = - 1)

◆ setObjectiveFunction()

template<typename O >
void aims::WolfeLineSearch< O >::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 112 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_f.

◆ setPosition()

template<typename O >
void aims::WolfeLineSearch< O >::setPosition ( const Vector x = Vector())

Definition at line 100 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_x.

◆ setSearchDirection()

template<typename O >
void aims::WolfeLineSearch< O >::setSearchDirection ( const Vector p = Vector())

Definition at line 106 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_p.

◆ setStrongWolfe()

template<typename O >
void aims::WolfeLineSearch< O >::setStrongWolfe ( bool  strong = false)

◆ setVerbose()

template<typename O >
void aims::WolfeLineSearch< O >::setVerbose ( int  v = carto::verbose)

◆ strongWolfe()

template<typename O >
bool aims::WolfeLineSearch< O >::strongWolfe ( ) const

Definition at line 179 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_strong.

◆ verbose()

template<typename O >
int aims::WolfeLineSearch< O >::verbose ( ) const

Definition at line 185 of file wolfe_d.h.

References aims::WolfeLineSearch< O >::_verbose.

Referenced by aims::WolfeLineSearch< O >::execute().

◆ wolfe1()

◆ wolfe2()

template<typename O >
bool aims::WolfeLineSearch< O >::wolfe2 ( float  a) const
protected

◆ wolfe2s()

◆ wolfe2w()

Member Data Documentation

◆ _c1

◆ _c2

◆ _current_value

template<typename O>
float aims::WolfeLineSearch< O >::_current_value
protected

◆ _f

◆ _max_it

template<typename O>
int aims::WolfeLineSearch< O >::_max_it
protected

◆ _maximize

template<typename O>
bool aims::WolfeLineSearch< O >::_maximize
protected

◆ _p

◆ _previous_scalarprod

◆ _previous_value

◆ _strong

◆ _verbose

template<typename O>
int aims::WolfeLineSearch< O >::_verbose
protected

◆ _x


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