primatologist-gpl 6.0.4
gradient_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_GRADIENT_DECL_H
12#define PRIMATOLOGIST_OPTIMIZATION_GRADIENT_DECL_H
13
14#include <primatologist/math/matrix.h> // aims::math::Matrix
15#include <primatologist/optimization/nolinesearch.h> // aims::NoLineSearch
16#include <cartobase/config/verbose.h> // carto::verbose
17
18namespace aims {
19
20
21 //==========================================================================
22 // GRADIEN DESCENT
23 //==========================================================================
24 template <typename O, template <typename> class L = NoLineSearch >
26 {
27 public:
28 //------------------------------------------------------------------------
29 // TYPEDEFS
30 //------------------------------------------------------------------------
31 typedef O Objective;
32 typedef L<O> LineSearch;
35
36 //------------------------------------------------------------------------
37 // CONSTRUCTOR / DESTRUCTOR / COPY
38 //------------------------------------------------------------------------
41 GradientDescent( const Objective & f = Objective(),
42 const Vector & x = Vector() );
46
47 //------------------------------------------------------------------------
48 // SET PARAMETERS
49 //------------------------------------------------------------------------
50 // Intrinsic parameters
51 void setGamma( float gamma = 0.1 );
55 void setStopCriterion( const std::string & crit = "absdiff" );
56 void setStopValue( float epsilon = 1E-5 );
59 void setLineSearch( const LineSearch & l = LineSearch() );
60 void setMaximize( bool maximize = false );
61 void setMaxIterations( int n = - 1 );
62 void setVerbose( int v = carto::verbose );
63 // Search parameters
66 void setObjectiveFunction( const Objective & f );
67 void setPosition( const Vector & x = Vector() );
68
69 //------------------------------------------------------------------------
70 // GET PARAMETERS
71 //------------------------------------------------------------------------
72 // Intrinsic parameters
73 float gamma() const;
74 const std::string & stopCriterion() const;
75 float stopValue() const;
77 bool maximize() const;
78 int maxIterations() const;
79 int verbose() const;
80 // Search parameters
81 const Vector & position() const;
82 const Objective & objectiveFunction() const;
83
84 //------------------------------------------------------------------------
85 // EXECUTE
86 //------------------------------------------------------------------------
88
89 protected:
90 //------------------------------------------------------------------------
91 // PARAMETERS
92 //------------------------------------------------------------------------
93 float _gamma;
98 bool _maximize;
99 int _max_it;
100 std::string _crit;
101 float _epsilon;
102 };
103
104} // namespace aims
105
106#endif // PRIMATOLOGIST_OPTIMIZATION_GRADIENT_DECL_H
LineSearch & lineSearch()
Definition gradient_d.h:156
const Vector & position() const
Definition gradient_d.h:181
void setVerbose(int v=carto::verbose)
Definition gradient_d.h:113
LineSearch _ls
lineSearch
float stopValue() const
Definition gradient_d.h:149
void setObjectiveFunction(const Objective &f)
Definition gradient_d.h:120
int maxIterations() const
Definition gradient_d.h:168
void setMaxIterations(int n=- 1)
Definition gradient_d.h:107
float _epsilon
stop value
void setStopValue(float epsilon=1E-5)
Definition gradient_d.h:85
std::string _crit
stop criterion
GradientDescent< O, L > & operator=(const GradientDescent< O, L > &other)
Definition gradient_d.h:53
int _verbose
verbosity level
void setLineSearch(const LineSearch &l=LineSearch())
Definition gradient_d.h:91
void setMaximize(bool maximize=false)
Definition gradient_d.h:100
const std::string & stopCriterion() const
Definition gradient_d.h:143
void setGamma(float gamma=0.1)
Definition gradient_d.h:73
bool maximize() const
Definition gradient_d.h:162
Objective _f
objectiveFunction
void setPosition(const Vector &x=Vector())
Definition gradient_d.h:127
float _gamma
Fixed Gamma or initial gamma for line search.
GradientDescent(const Objective &f=Objective(), const Vector &x=Vector())
Definition gradient_d.h:23
bool _maximize
maximize or minimize
float gamma() const
Definition gradient_d.h:137
int _max_it
maximum number of iterations
void setStopCriterion(const std::string &crit="absdiff")
Can take values:
Definition gradient_d.h:79
const Objective & objectiveFunction() const
Definition gradient_d.h:188
Object used by classes that can take a line search tool as template argument but need a default objec...
MatrixBase< float > Vector
Definition matrix.h:29
MatrixBase< float > Matrix
Definition matrix.h:27