LineSearcher.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //////////////////////////////////////////////////////////////////////
  2. //
  3. // LineSearcher.h: interface of the LineSearcher class.
  4. //
  5. // Written by: Matthias Wacker
  6. //
  7. //////////////////////////////////////////////////////////////////////
  8. #ifndef _LINE_SEARCHER_H_
  9. #define _LINE_SEARCHER_H_
  10. #include "core/optimization/blackbox/CostFunction.h"
  11. #include "core/optimization/blackbox/OptLogBase.h"
  12. #include "optimization/Opt_Namespace.h"
  13. #include "optimization/InequalityConstraints.h"
  14. #include "optimization/EqualityConstraints.h"
  15. /*!
  16. Abstract base class of all line search optimizer.
  17. */
  18. class LineSearcher
  19. {
  20. public:
  21. typedef optimization::matrix_type matrix_type;
  22. /*!
  23. default constructor
  24. */
  25. LineSearcher();
  26. /*!
  27. constructor
  28. */
  29. LineSearcher(CostFunction *costFunc, OptLogBase *loger);
  30. /*!
  31. Copy constructor
  32. \param opt .. optimizer to copy
  33. */
  34. LineSearcher( const LineSearcher &lin);
  35. /*!
  36. operator =
  37. */
  38. LineSearcher & operator=(const LineSearcher &lin);
  39. /*!
  40. Destructor.
  41. */
  42. virtual ~LineSearcher();
  43. /*!
  44. search maximum?
  45. */
  46. inline void setMaximize(bool maximize){m_maximize = maximize;};
  47. /*!
  48. set x0
  49. */
  50. bool setX0(const matrix_type & x0);
  51. /*!
  52. set a direction
  53. */
  54. bool setH0(const matrix_type & H0);
  55. /*!
  56. optimize
  57. returns a double..
  58. */
  59. virtual double optimize() = 0;
  60. /*!
  61. set Constraints for penalty terms
  62. \returns true in case of success
  63. */
  64. bool setConstraints(InequalityConstraints *ineq,EqualityConstraints *eq);
  65. /*!
  66. evaluate penalized 1d function
  67. */
  68. double evaluateSub(double lambda);
  69. /*!
  70. penalty parameter
  71. */
  72. bool setPP(double pp);
  73. /*!
  74. set vebose to true to get more information
  75. */
  76. inline void setVerbose(bool verb){m_verbose = verb;};
  77. protected:
  78. /*!
  79. maximization?
  80. */
  81. bool m_maximize;
  82. /*!
  83. the costfunction
  84. */
  85. CostFunction *m_pFunc;
  86. /*!
  87. number of Inequality Constraints
  88. */
  89. unsigned int m_numIneq;
  90. /*!
  91. Inequality Constraints
  92. */
  93. InequalityConstraints *m_pIneq;
  94. /*!
  95. number of Equality Constraints
  96. */
  97. unsigned int m_numEq;
  98. /*!
  99. Equality Constraints
  100. */
  101. EqualityConstraints *m_pEq;
  102. /*
  103. penalty parameter
  104. */
  105. double m_PP;
  106. /*!
  107. Point to a loger
  108. */
  109. OptLogBase *m_pLoger;
  110. /*!
  111. verbose?
  112. */
  113. bool m_verbose;
  114. };
  115. #endif