////////////////////////////////////////////////////////////////////// // // BrentLineSearcher.h: interface of the BrentLineSearcher class. // // Written by: Matthias Wacker // ////////////////////////////////////////////////////////////////////// #ifndef _BRENT_LINE_SEARCHER_H #define _BRENT_LINE_SEARCHER_H #include #include "LineSearcher.h" namespace OPTIMIZATION { /*! class for the brent line search HowToUse: * use setX0() to set the offset * use setH0() to set the search direction * use setEps() to set the abort criterion * use setBounds() to set a different search bound for lambda than [0,10] * call init() * call optimize() (returns lambda) */ class BrentLineSearcher : public LineSearcher { public: typedef LineSearcher SuperClass; typedef SuperClass::matrix_type matrix_type; /*! default constructor */ BrentLineSearcher(); /*! constructor */ BrentLineSearcher(CostFunction *costFunc, OptLogBase *loger); /*! Copy constructor \param opt .. optimizer to copy */ BrentLineSearcher( const BrentLineSearcher &lin); /*! operator = */ BrentLineSearcher & operator=(const BrentLineSearcher &lin); /*! Destructor. */ virtual ~BrentLineSearcher(); /*! set the bound parameters */ bool setBounds(double a, double c); /*! set the abort threshold */ bool setEps(double eps); /*! optimize returns a double.. */ double optimize(); protected: /*! approximation of the golden cut ratio */ const double m_CGOLD; // = 0.38196601125010515179541316563436; /*! small number trying to achieve fractional accuracy for a minimum at 0 */ const double m_ZEPS; /*! the bounds */ double m_a, m_b, m_c; /*! the abort criteria */ double m_eps; }; //class }//namespace #endif