primatologist-gpl 6.0.4
wolfe_decl.h
Go to the documentation of this file.
1/* Copyright (C) 2000-2013 CEA
2 *
3 * This software and supporting documentation were developed by
4 * bioPICSEL
5 * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6 * 18, route du Panorama
7 * 92265 Fontenay-aux-Roses
8 * France
9 */
10
11#ifndef PRIMATOLOGIST_OPTIMIZATION_WOLFE_DECL_H
12#define PRIMATOLOGIST_OPTIMIZATION_WOLFE_DECL_H
13
14#include <primatologist/math/matrix.h> // aims::math::Matrix
15#include <cartobase/config/verbose.h> // carto::verbose
16
17namespace aims {
18
19 //==========================================================================
20 // WOLFE LINE SEARCH
21 //==========================================================================
37 template <typename O>
39 {
40 public:
41 //------------------------------------------------------------------------
42 // TYPEDEFS
43 //------------------------------------------------------------------------
44 typedef O Objective;
47
48 //------------------------------------------------------------------------
49 // CONSTRUCTOR / DESTRUCTOR / COPY
50 //------------------------------------------------------------------------
53 WolfeLineSearch( const Objective & f = Objective(),
54 const Vector & x = Vector(),
55 const Vector & p = Vector() );
56 WolfeLineSearch( const WolfeLineSearch<O> & other );
59
60 //------------------------------------------------------------------------
61 // SET PARAMETERS
62 //------------------------------------------------------------------------
63 // Intrinsic parameters
64 void setC1( float c1 = 1E-4 );
65 void setC2( float c2 = 0.9 );
66 void setStrongWolfe( bool strong = false );
67 void setMaximize( bool maximize = false );
68 void setMaxIterations( int n = - 1 );
69 void setVerbose( int v = carto::verbose );
70 // Search parameters
73 void setObjectiveFunction( const Objective & f );
74 void setPosition( const Vector & x = Vector() );
75 void setSearchDirection( const Vector & p = Vector() );
76
77 //------------------------------------------------------------------------
78 // GET PARAMETERS
79 //------------------------------------------------------------------------
80 // Intrinsic parameters
81 float c1() const;
82 float c2() const;
83 bool strongWolfe() const;
84 bool maximize() const;
85 int maxIterations() const;
86 int verbose() const;
87 // Search parameters
88 const Objective & objectiveFunction() const;
89 const Vector & position() const;
90 const Vector & searchDirection() const;
91
92 //------------------------------------------------------------------------
93 // EXECUTE
94 //------------------------------------------------------------------------
96
97 protected:
98 //------------------------------------------------------------------------
99 // PARAMETERS
100 //------------------------------------------------------------------------
101 float _c1;
102 float _c2;
106 bool _strong;
110 //------------------------------------------------------------------------
111 // LINE SEARCH
112 //------------------------------------------------------------------------
113 bool wolfe1( float a ) const;
114 bool wolfe2w( float a ) const;
115 bool wolfe2s( float a ) const;
116 bool wolfe2( float a ) const;
119 bool checkDirection();
123 };
124
125} // namespace aims
126
127#endif // PRIMATOLOGIST_OPTIMIZATION_WOLFE_DECL_H
WolfeLineSearch(const Objective &f=Objective(), const Vector &x=Vector(), const Vector &p=Vector())
Definition wolfe_d.h:27
void setMaxIterations(int n=- 1)
Definition wolfe_d.h:136
math::Matrix Matrix
Definition wolfe_decl.h:45
WolfeLineSearch< O > & operator=(const WolfeLineSearch< O > &other)
Definition wolfe_d.h:64
bool strongWolfe() const
Definition wolfe_d.h:179
float _c1
Wolfe c1.
Definition wolfe_decl.h:101
Objective _f
objectiveFunction
Definition wolfe_decl.h:105
bool wolfe1(float a) const
Armijo (= Wolfe 1st) condition.
Definition wolfe_d.h:328
bool maximize() const
Definition wolfe_d.h:191
void setSearchDirection(const Vector &p=Vector())
Definition wolfe_d.h:106
float _c2
Wolfe c2.
Definition wolfe_decl.h:102
void setObjectiveFunction(const Objective &f)
Definition wolfe_d.h:112
void setMaximize(bool maximize=false)
Definition wolfe_d.h:130
bool wolfe2w(float a) const
weak 2nd Wolfe condition
Definition wolfe_d.h:338
float _previous_value
f(x)
Definition wolfe_decl.h:120
bool checkDirection()
Compute f(x) and <p, g(x)>.
Definition wolfe_d.h:317
Vector _x
position
Definition wolfe_decl.h:103
const Objective & objectiveFunction() const
Definition wolfe_d.h:173
void setStrongWolfe(bool strong=false)
Definition wolfe_d.h:118
void setPosition(const Vector &x=Vector())
Definition wolfe_d.h:100
float _previous_scalarprod
<p, g(x)>
Definition wolfe_decl.h:122
int maxIterations() const
Definition wolfe_d.h:197
void setC1(float c1=1E-4)
Definition wolfe_d.h:88
bool _maximize
maximize or minimize
Definition wolfe_decl.h:108
float c2() const
Definition wolfe_d.h:152
int _max_it
maximum number of iterations
Definition wolfe_decl.h:109
int verbose() const
Definition wolfe_d.h:185
bool wolfe2s(float a) const
strong 2nd Wolfe condition
Definition wolfe_d.h:349
void setC2(float c2=0.9)
Definition wolfe_d.h:94
math::Vector Vector
Definition wolfe_decl.h:46
int _verbose
verbosity level
Definition wolfe_decl.h:107
float c1() const
Definition wolfe_d.h:146
void setVerbose(int v=carto::verbose)
Definition wolfe_d.h:124
bool _strong
strongWolfe
Definition wolfe_decl.h:106
const Vector & searchDirection() const
Definition wolfe_d.h:166
const Vector & position() const
Definition wolfe_d.h:159
Vector _p
ascentDirection
Definition wolfe_decl.h:104
bool wolfe2(float a) const
select condition based on _strong
Definition wolfe_d.h:357
float _current_value
f(x + a.p)
Definition wolfe_decl.h:121
MatrixBase< float > Vector
Definition matrix.h:29
MatrixBase< float > Matrix
Definition matrix.h:27