BrentLineSearcher.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //////////////////////////////////////////////////////////////////////
  2. //
  3. // BrentLineSearcher.h: interface of the BrentLineSearcher class.
  4. //
  5. // Written by: Matthias Wacker
  6. //
  7. //////////////////////////////////////////////////////////////////////
  8. #ifndef _BRENT_LINE_SEARCHER_H
  9. #define _BRENT_LINE_SEARCHER_H
  10. #include <cmath>
  11. #include "LineSearcher.h"
  12. namespace OPTIMIZATION
  13. {
  14. /*!
  15. class for the brent line search
  16. HowToUse:
  17. * use setX0() to set the offset
  18. * use setH0() to set the search direction
  19. * use setEps() to set the abort criterion
  20. * use setBounds() to set a different search bound for lambda than [0,10]
  21. * call init()
  22. * call optimize() (returns lambda)
  23. */
  24. class BrentLineSearcher : public LineSearcher
  25. {
  26. public:
  27. typedef LineSearcher SuperClass;
  28. typedef SuperClass::matrix_type matrix_type;
  29. /*!
  30. default constructor
  31. */
  32. BrentLineSearcher();
  33. /*!
  34. constructor
  35. */
  36. BrentLineSearcher(CostFunction *costFunc, OptLogBase *loger);
  37. /*!
  38. Copy constructor
  39. \param opt .. optimizer to copy
  40. */
  41. BrentLineSearcher( const BrentLineSearcher &lin);
  42. /*!
  43. operator =
  44. */
  45. BrentLineSearcher & operator=(const BrentLineSearcher &lin);
  46. /*!
  47. Destructor.
  48. */
  49. virtual ~BrentLineSearcher();
  50. /*!
  51. set the bound parameters
  52. */
  53. bool setBounds(double a, double c);
  54. /*!
  55. set the abort threshold
  56. */
  57. bool setEps(double eps);
  58. /*!
  59. optimize
  60. returns a double..
  61. */
  62. double optimize();
  63. protected:
  64. /*!
  65. approximation of the golden cut ratio
  66. */
  67. const double m_CGOLD; // = 0.38196601125010515179541316563436;
  68. /*!
  69. small number trying to achieve fractional accuracy for a minimum at 0
  70. */
  71. const double m_ZEPS;
  72. /*!
  73. the bounds
  74. */
  75. double m_a, m_b, m_c;
  76. /*!
  77. the abort criteria
  78. */
  79. double m_eps;
  80. }; //class
  81. }//namespace
  82. #endif