BrentLineSearcher.h 1.7 KB

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