primatologist-gpl  5.1.2
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

Definition at line 146 of file wolfe_d.h.

◆ c2()

template<typename O >
float aims::WolfeLineSearch< O >::c2

Definition at line 152 of file wolfe_d.h.

◆ checkDirection()

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

Compute f(x) and <p, g(x)>.

Check that the search direction has the right orientation.

Definition at line 317 of file wolfe_d.h.

References at(), and aims::math::transpose().

◆ execute()

template<typename O >
WolfeLineSearch< O >::Vector aims::WolfeLineSearch< O >::execute

Definition at line 208 of file wolfe_d.h.

◆ maximize()

template<typename O >
bool aims::WolfeLineSearch< O >::maximize

Definition at line 191 of file wolfe_d.h.

◆ maxIterations()

template<typename O >
int aims::WolfeLineSearch< O >::maxIterations

Definition at line 197 of file wolfe_d.h.

◆ objectiveFunction()

template<typename O >
const WolfeLineSearch< O >::Objective & aims::WolfeLineSearch< O >::objectiveFunction

Definition at line 173 of file wolfe_d.h.

◆ operator=()

◆ position()

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

Definition at line 159 of file wolfe_d.h.

◆ searchDirection()

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

Definition at line 166 of file wolfe_d.h.

◆ setC1()

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

Definition at line 88 of file wolfe_d.h.

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

◆ setC2()

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

Definition at line 94 of file wolfe_d.h.

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

◆ setMaximize()

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

Definition at line 130 of file wolfe_d.h.

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

◆ setMaxIterations()

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

Definition at line 136 of file wolfe_d.h.

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

◆ 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.

◆ setPosition()

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

Definition at line 100 of file wolfe_d.h.

◆ setSearchDirection()

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

Definition at line 106 of file wolfe_d.h.

◆ setStrongWolfe()

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

Definition at line 118 of file wolfe_d.h.

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

◆ setVerbose()

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

Definition at line 124 of file wolfe_d.h.

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

◆ strongWolfe()

template<typename O >
bool aims::WolfeLineSearch< O >::strongWolfe

Definition at line 179 of file wolfe_d.h.

◆ verbose()

template<typename O >
int aims::WolfeLineSearch< O >::verbose

Definition at line 185 of file wolfe_d.h.

◆ wolfe1()

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

Armijo (= Wolfe 1st) condition.

Definition at line 328 of file wolfe_d.h.

◆ wolfe2()

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

select condition based on _strong

Definition at line 357 of file wolfe_d.h.

◆ wolfe2s()

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

strong 2nd Wolfe condition

Definition at line 349 of file wolfe_d.h.

References at(), and aims::math::transpose().

◆ wolfe2w()

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

weak 2nd Wolfe condition

Definition at line 338 of file wolfe_d.h.

References at(), and aims::math::transpose().

Member Data Documentation

◆ _c1

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

Wolfe c1.

Definition at line 101 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _c2

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

Wolfe c2.

Definition at line 102 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _current_value

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

f(x + a.p)

Definition at line 121 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _f

template<typename O >
Objective aims::WolfeLineSearch< O >::_f
protected

objectiveFunction

Definition at line 105 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _max_it

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

maximum number of iterations

Definition at line 109 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _maximize

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

maximize or minimize

Definition at line 108 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _p

template<typename O >
Vector aims::WolfeLineSearch< O >::_p
protected

ascentDirection

Definition at line 104 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _previous_scalarprod

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

<p, g(x)>

Definition at line 122 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _previous_value

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

f(x)

Definition at line 120 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _strong

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

strongWolfe

Definition at line 106 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _verbose

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

verbosity level

Definition at line 107 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().

◆ _x

template<typename O >
Vector aims::WolfeLineSearch< O >::_x
protected

position

Definition at line 103 of file wolfe_decl.h.

Referenced by aims::WolfeLineSearch< O >::operator=().


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