DimWrapperCostFunction.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //////////////////////////////////////////////////////////////////////
  2. //
  3. // DimWrapperCostFunction.h:
  4. // Defines a wrapper around a cost function. Given a parameter matrix (parameter initalizations) and a selection matrix a flexible optimization of different, individual parameters becomes possible.
  5. // Written By: Matthias Wacker, Esther Platzer
  6. //
  7. //////////////////////////////////////////////////////////////////////
  8. #ifndef _DIMWRAP_COST_FUNCTION_H_
  9. #define _DIMWRAP_COST_FUNCTION_H_
  10. //#include "Optimizable.h"
  11. #include "optimization/CostFunction.h"
  12. #include "optimization/Opt_Namespace.h"
  13. namespace opt=optimization;
  14. class DimWrapperCostFunction : public CostFunction
  15. {
  16. public:
  17. typedef CostFunction SuperClass;
  18. /*!
  19. DefaultConstructor
  20. */
  21. DimWrapperCostFunction();
  22. /*!
  23. * Useful constructor
  24. *
  25. * @param orig pointer to the original cost function with paramDim dim_orig
  26. * @param selectionVecotor (dim_orig x 1) selection vector with nonzero values
  27. * for the ones that should be used in new costfunction
  28. * @param fixedValues vector to be able to specify fixed values for the unused paramters
  29. *
  30. * the parameters of this costfunction will be mapped to the original ones. Offset will be
  31. * added to the paramter vector. evaluate() will return the result of the original function
  32. *
  33. * x_orig = m_selMatTransposed * x_this + fixedValues
  34. * */
  35. DimWrapperCostFunction(CostFunction *orig, const opt::matrix_type &selectionVector, const opt::matrix_type &fixedValues);
  36. /*!
  37. * copy constructor
  38. *
  39. * */
  40. DimWrapperCostFunction(const DimWrapperCostFunction & costFunc);
  41. /*!
  42. Destructor.
  43. */
  44. virtual ~DimWrapperCostFunction();
  45. /*!
  46. =operator
  47. */
  48. DimWrapperCostFunction &operator=(const DimWrapperCostFunction &costFunc);
  49. /*!
  50. *
  51. * @param selectionVecotor (dim_orig x 1) selection vector with nonzero values
  52. * for the ones that should be used in new costfunction
  53. * @param fixedValues vector to be able to specify fixed values for the unused paramters
  54. * */
  55. void changeSelection(const opt::matrix_type & selectionVector, const opt::matrix_type &fixedValues);
  56. /*!
  57. Initialization for the cost function
  58. */
  59. virtual void init();
  60. /*!
  61. *
  62. * */
  63. virtual double evaluate(const opt::matrix_type &parameter);
  64. /**
  65. * Returns the current full parameter vector (no dimension reduction for inactive params)
  66. * @param x the current parameter vector containing just active parameters
  67. * @return the full parameter vector with current active params
  68. */
  69. virtual opt::matrix_type getFullParamsFromSubParams(const opt::matrix_type &x);
  70. /*!
  71. set an x0 for 1dim line search
  72. */
  73. //virtual bool setX0(const opt::matrix_type &x0);
  74. /*!
  75. set an h0 for 1dim line search
  76. */
  77. //virtual bool setH0(const opt::matrix_type &H0);
  78. /*!
  79. evaluate 1dimension sub function fsub(lambda) = f(x0 + lambda * h0)
  80. */
  81. //virtual double evaluateSub(double lambda);
  82. private:
  83. /*!
  84. * the original costfunciton
  85. *
  86. *
  87. * */
  88. CostFunction *m_pOrigCostFunc;
  89. /*!
  90. * this is the mapping matrix
  91. *
  92. * x_orig = m_selMatTransposed * x + offset
  93. *
  94. * */
  95. opt::matrix_type m_selMatTransposed;
  96. /*!
  97. * fixed values
  98. *
  99. * */
  100. opt::matrix_type m_fixedValues;
  101. // //! x_0
  102. //opt::matrix_type m_x_0;
  103. // //! direction h_0
  104. //opt::matrix_type m_h_0;
  105. };
  106. #endif