MatrixIterativeOptimizer.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. //////////////////////////////////////////////////////////////////////
  2. //
  3. // AxA3dNUMMatrixIterativeOptimizer.h: interface for MatrixItertiveMethods class
  4. //
  5. // Written by: Matthias Wacker
  6. //
  7. //
  8. //////////////////////////////////////////////////////////////////////
  9. #ifndef _MATRIX_ITERATIVE_OPTIMIZER_H_
  10. #define _MATRIX_ITERATIVE_OPTIMIZER_H_
  11. #include "optimization/DerivativeBasedOptimizer.h"
  12. #include "optimization/GoldenCutLineSearcher.h"
  13. //#include "optimization/BrentLineSearcher.h"
  14. #include "optimization/ArmijoLineSearcher.h"
  15. namespace OPTIMIZATION
  16. {
  17. /*!
  18. abstract base class of all matrix iterative based optimizers.
  19. Methods like the newton iterative method or BFGS inherit from this class
  20. */
  21. class MatrixIterativeOptimizer : public DerivativeBasedOptimizer
  22. {
  23. public:
  24. typedef DerivativeBasedOptimizer SuperClass;
  25. typedef SuperClass::matrix_type matrix_type;
  26. /*!
  27. Constructor.
  28. \param numOfParameters : Number of parameters to optimize
  29. \param objectiveFunction : CostFunction*
  30. \param loger : OptLogBase * to existing log class
  31. */
  32. MatrixIterativeOptimizer(OptLogBase *loger);
  33. /*!
  34. Copy constructor
  35. \param opt .. optimizer to copy
  36. */
  37. MatrixIterativeOptimizer( const MatrixIterativeOptimizer &opt);
  38. /*!
  39. operator =
  40. */
  41. MatrixIterativeOptimizer & operator=(const MatrixIterativeOptimizer &opt);
  42. /*!
  43. Destructor.
  44. */
  45. virtual ~MatrixIterativeOptimizer();
  46. /*!
  47. \brief Set the initial step size
  48. The initial stepsize is used to give the optimizer an initial value for the order of
  49. magnitude to start with.
  50. (e.g. step 100000 in x direction or 0.01 ?)
  51. \param stepSize with the step size for the i-th dimension in the (i,0)-th position.
  52. */
  53. void setStepSize(const matrix_type & stepSize);
  54. /*!
  55. \brief to set options for the internal line searcher, get the access
  56. */
  57. ArmijoLineSearcher * getLineSearcher(){return &m_lin;};
  58. /*!
  59. initialize
  60. */
  61. void init();
  62. /*!
  63. optimize
  64. */
  65. int optimize();
  66. protected:
  67. /*!
  68. \brief update the Iteration Matrix
  69. */
  70. virtual void updateIterationMatrix() = 0;
  71. /*!
  72. the iteration matrix
  73. */
  74. matrix_type m_IterationMatrix;
  75. /*!
  76. \brief compute the descent direction
  77. */
  78. void computeDescentDirection();
  79. /*!
  80. the descent direction
  81. */
  82. matrix_type m_hk;
  83. /*!
  84. \brief compute the steplength
  85. */
  86. void ComputeStepLength();
  87. /*!
  88. \brief reset the matrix
  89. */
  90. void resetMatrix();
  91. /*!
  92. the steplength
  93. */
  94. double m_lambdak;
  95. /*!
  96. 1-dim search to optimize the steplength
  97. */
  98. //GoldenCutLineSearcher m_lin;
  99. //BrentLineSearcher m_lin;
  100. ArmijoLineSearcher m_lin;
  101. /*!
  102. step size vector
  103. */
  104. matrix_type m_stepSize;
  105. /*
  106. needed for updates
  107. */
  108. matrix_type m_oldParams;
  109. /*
  110. needed for updates
  111. */
  112. matrix_type m_oldGradient;
  113. //double m_lin_Lower;
  114. //double m_lin_Upper;
  115. //double m_lin_Eps;
  116. };//class
  117. }//namespace
  118. #endif