////////////////////////////////////////////////////////////////////// // // CostFunction_ndim_2ndOrder.h: interface of a test CostFunction class. // // Written By: Matthias Wacker // // f(x) = 0.5 * x^T * A * x + b^T * x + c // ////////////////////////////////////////////////////////////////////// #ifndef _COSTFUNCTION_NDIM_2NDORDER_H_ #define _COSTFUNCTION_NDIM_2NDORDER_H_ #include "core/optimization/blackbox/CostFunction.h" namespace OPTIMIZATION { class CostFunction_ndim_2ndOrder : public CostFunction { public: typedef CostFunction SuperClass; typedef SuperClass::matrix_type matrix_type; /*! default constructor */ CostFunction_ndim_2ndOrder(); /*! Constructor. \param dim of parameter space */ CostFunction_ndim_2ndOrder(unsigned int dim); /*! Copy constructor \param func the function to copy */ CostFunction_ndim_2ndOrder(const CostFunction_ndim_2ndOrder &func); /*! = operator */ CostFunction_ndim_2ndOrder &operator=(const CostFunction_ndim_2ndOrder & func); /*! Destructor. */ ~CostFunction_ndim_2ndOrder(); /*! initializations */ void init(); /*! set A, b, and c \param A \param b \param c \return 0 in case of success. */ int setAbc(const matrix_type & A,const matrix_type &b, double c); /*! evaluate the costfunction \param parameter to evaluate at */ double evaluate(const matrix_type & parameter); /*! get the analytic Gradient */ const matrix_type getAnalyticGradient(const matrix_type ¶meter); protected: /*! the matrix A of f(x) = 0.5 * x^T * A * x + b^T * x + c */ matrix_type m_A; /*! the vector b^T of f(x) = 0.5 * x^T * A * x + b^T * x + c */ matrix_type m_bt; /* the value c of f(x) = 0.5 * x^T * A * x + b^T * x + c */ double m_c; }; //class }//namespace #endif