primatologist-gpl 6.0.4
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.
 
bool wolfe2w (float a) const
 weak 2nd Wolfe condition
 
bool wolfe2s (float a) const
 strong 2nd Wolfe condition
 
bool wolfe2 (float a) const
 select condition based on _strong
 
bool checkDirection ()
 Compute f(x) and <p, g(x)>.
 

Protected Attributes

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

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 _f, _p, _x, setC1(), setC2(), setMaximize(), setMaxIterations(), setStrongWolfe(), and setVerbose().

Referenced by operator=(), and WolfeLineSearch().

◆ WolfeLineSearch() [2/2]

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

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

Referenced by setC1().

◆ c2()

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

Definition at line 152 of file wolfe_d.h.

References _c2.

Referenced by setC2().

◆ 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 _p, _previous_scalarprod, _previous_value, _x, maximize(), objectiveFunction(), and aims::math::transpose().

Referenced by execute().

◆ execute()

◆ maximize()

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

Definition at line 191 of file wolfe_d.h.

References _maximize.

Referenced by checkDirection(), execute(), setMaximize(), wolfe1(), and wolfe2w().

◆ maxIterations()

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

Definition at line 197 of file wolfe_d.h.

References _max_it.

Referenced by execute().

◆ objectiveFunction()

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

Definition at line 173 of file wolfe_d.h.

References _f.

Referenced by checkDirection(), execute(), wolfe2s(), and wolfe2w().

◆ operator=()

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

◆ position()

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

Definition at line 159 of file wolfe_d.h.

References _x.

◆ searchDirection()

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

Definition at line 166 of file wolfe_d.h.

References _p.

◆ setC1()

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

Definition at line 88 of file wolfe_d.h.

References _c1, and c1().

Referenced by WolfeLineSearch().

◆ setC2()

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

Definition at line 94 of file wolfe_d.h.

References _c2, and c2().

Referenced by WolfeLineSearch().

◆ setMaximize()

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

Definition at line 130 of file wolfe_d.h.

References _maximize, and maximize().

Referenced by WolfeLineSearch().

◆ setMaxIterations()

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

Definition at line 136 of file wolfe_d.h.

References _max_it.

Referenced by 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.

References _f.

◆ setPosition()

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

Definition at line 100 of file wolfe_d.h.

References _x.

◆ setSearchDirection()

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

Definition at line 106 of file wolfe_d.h.

References _p.

◆ setStrongWolfe()

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

Definition at line 118 of file wolfe_d.h.

References _strong.

Referenced by WolfeLineSearch().

◆ setVerbose()

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

Definition at line 124 of file wolfe_d.h.

References _verbose.

Referenced by WolfeLineSearch().

◆ strongWolfe()

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

Definition at line 179 of file wolfe_d.h.

References _strong.

◆ verbose()

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

Definition at line 185 of file wolfe_d.h.

References _verbose.

Referenced by execute().

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

References _c1, _current_value, _previous_scalarprod, _previous_value, and maximize().

Referenced by execute().

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

References _strong, wolfe2s(), and wolfe2w().

Referenced by execute().

◆ 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 _c2, _p, _previous_scalarprod, _x, objectiveFunction(), and aims::math::transpose().

Referenced by wolfe2().

◆ 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 _c2, _p, _previous_scalarprod, _x, maximize(), objectiveFunction(), and aims::math::transpose().

Referenced by wolfe2().

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 c1(), operator=(), setC1(), wolfe1(), and WolfeLineSearch().

◆ _c2

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

Wolfe c2.

Definition at line 102 of file wolfe_decl.h.

Referenced by c2(), operator=(), setC2(), wolfe2s(), wolfe2w(), and WolfeLineSearch().

◆ _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 execute(), operator=(), wolfe1(), and WolfeLineSearch().

◆ _f

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

objectiveFunction

Definition at line 105 of file wolfe_decl.h.

Referenced by objectiveFunction(), operator=(), setObjectiveFunction(), WolfeLineSearch(), and WolfeLineSearch().

◆ _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 maxIterations(), operator=(), setMaxIterations(), and WolfeLineSearch().

◆ _maximize

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

maximize or minimize

Definition at line 108 of file wolfe_decl.h.

Referenced by maximize(), operator=(), setMaximize(), and WolfeLineSearch().

◆ _p

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

◆ _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 checkDirection(), operator=(), wolfe1(), wolfe2s(), wolfe2w(), and WolfeLineSearch().

◆ _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 checkDirection(), execute(), operator=(), wolfe1(), and WolfeLineSearch().

◆ _strong

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

strongWolfe

Definition at line 106 of file wolfe_decl.h.

Referenced by operator=(), setStrongWolfe(), strongWolfe(), wolfe2(), and WolfeLineSearch().

◆ _verbose

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

verbosity level

Definition at line 107 of file wolfe_decl.h.

Referenced by operator=(), setVerbose(), verbose(), and WolfeLineSearch().

◆ _x

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

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