MatrixIterativeOptimizer.h 2.8 KB

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