primatologist-gpl  5.1.2
nolinesearch.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_NOLINESEARCH_H
12 #define PRIMATOLOGIST_OPTIMIZATION_NOLINESEARCH_H
13 
15 #include <cartobase/config/verbose.h>
16 
17 namespace aims {
18 
19  //==========================================================================
20  // NO LINE SEARCH UTILITY
21  //==========================================================================
24  template <typename O>
26  {
27  public:
28  //------------------------------------------------------------------------
29  // TYPEDEFS
30  //------------------------------------------------------------------------
31  typedef O Objective;
34 
35  //------------------------------------------------------------------------
36  // CONSTRUCTOR / DESTRUCTOR / COPY
37  //------------------------------------------------------------------------
38  NoLineSearch( const Objective & f = Objective() ):
39  _f(f), _x(), _p()
40  {}
41  NoLineSearch( const NoLineSearch<O> & other ):
42  _f(other._f), _x(other._x), _p(other._p)
43  {}
45  {}
47  {
48  if( this != & other )
49  {
50  _f = other._f;
51  _x = other._x;
52  _p = other._p;
53  _maximize = other._maximize;
54  _verbose = other._verbose;
55  }
56  return *this;
57  }
58 
59  //------------------------------------------------------------------------
60  // SET PARAMETERS
61  //------------------------------------------------------------------------
62  void setObjectiveFunction( const Objective & f ) { _f = f; }
63  void setPosition( const Vector & x = Vector() ) { _x = x; }
64  void setSearchDirection( const Vector & p = Vector() ) { _p = p; }
65  void setMaximize( bool maximize = false ) { _maximize = maximize; }
66  void setVerbose( int v = carto::verbose ) { _verbose = v; }
67 
68  //------------------------------------------------------------------------
69  // GET PARAMETERS
70  //------------------------------------------------------------------------
71  const Objective & objectiveFunction() const { return _f; }
72  const Vector & position() const { return _x; }
73  const Vector & searchDirection() const { return _p; }
74  bool maximize() const { return _maximize(); }
75  int verbose() const { return _verbose; }
76 
77  //------------------------------------------------------------------------
78  // EXECUTE
79  //------------------------------------------------------------------------
80  Vector execute() { return _x + _p; }
81 
82  protected:
86  bool _maximize;
87  int _verbose;
88  };
89 
90 
91 } // namespace aims
92 
93 #endif // PRIMATOLOGIST_OPTIMIZATION_NOLINESEARCH_H
Object used by classes that can take a line search tool as template argument but need a default objec...
Definition: nolinesearch.h:26
int verbose() const
Definition: nolinesearch.h:75
bool maximize() const
Definition: nolinesearch.h:74
math::Matrix Matrix
Definition: nolinesearch.h:32
const Vector & position() const
Definition: nolinesearch.h:72
const Vector & searchDirection() const
Definition: nolinesearch.h:73
void setPosition(const Vector &x=Vector())
Definition: nolinesearch.h:63
void setMaximize(bool maximize=false)
Definition: nolinesearch.h:65
const Objective & objectiveFunction() const
Definition: nolinesearch.h:71
math::Vector Vector
Definition: nolinesearch.h:33
void setSearchDirection(const Vector &p=Vector())
Definition: nolinesearch.h:64
NoLineSearch(const Objective &f=Objective())
Definition: nolinesearch.h:38
NoLineSearch(const NoLineSearch< O > &other)
Definition: nolinesearch.h:41
void setVerbose(int v=carto::verbose)
Definition: nolinesearch.h:66
NoLineSearch & operator=(const NoLineSearch< O > &other)
Definition: nolinesearch.h:46
void setObjectiveFunction(const Objective &f)
Definition: nolinesearch.h:62
Matrix class implementing matrix operations.
Definition: matrix.h:50