OptimizationAlgorithmSecond.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * NICE-Core - efficient algebra and computer vision methods
  3. * - liboptimization - An optimization/template for new NICE libraries
  4. * See file License for license information.
  5. */
  6. /*****************************************************************************/
  7. #ifndef _OPTIMIZATIONALGORITHMSECOND_OPTIMIZATION_H
  8. #define _OPTIMIZATIONALGORITHMSECOND_OPTIMIZATION_H
  9. #include <iostream>
  10. #include <core/basics/NonCopyable.h>
  11. #include <core/optimization/gradientBased/OptimizationProblemSecond.h>
  12. namespace NICE {
  13. /**
  14. * \defgroup optimization_algorithms Optimization Algorithms
  15. *
  16. * This module contains the optimization algorithms that
  17. * can be used to solve a user defined
  18. * \link optimization_problems optimization problem \endlink.
  19. *
  20. * The actual optimization problem, i.e. the objective function and their
  21. * derivatives need to be specified by the user of this library
  22. * by implementing a subclass of \c NICE::OptimizationProblemSecond
  23. * or \c NICE::OptimizationProblemFirst, respectively.
  24. * "First" refers to "first order", meaning that only
  25. * the gradient of the objective function is used. Accordingly,
  26. * "Second" refers to "second order": gradient and Hessian.
  27. *
  28. * Second order algorithms
  29. * (subclasses of \c NICE::OptimizationAlgorithmSecond)
  30. * are generally more efficient than first order algorithms
  31. * (subclasses of \c NICE::OptimizationAlgorithmFirst),
  32. * but require the Hessian matrix,
  33. * which can be more difficult to implement than the gradient,
  34. * and is sometimes very time consuming to compute.
  35. *
  36. * \note There are some optimization algorithms which use only the gradient
  37. * directly and compute an approximation of the Hessian themselves.
  38. * Currently, there is no such algorithm in this library.
  39. * If you want to implement one, make it a subclass of
  40. * \c NICE::OptimizationAlgorithmFirst
  41. * as it only needs to be supplied with the gradient.
  42. *
  43. * \note \c NICE::OptimizationAlgorithmFirst is a subclass of
  44. * \c NICE::OptimizationAlgorithmSecond, as first order algorithms
  45. * also work with \c NICE::OptimizationProblemSecond, which provides
  46. * the required gradient.
  47. */
  48. /**
  49. * Base class for second order optimization algorithms.
  50. *
  51. * \ingroup optimization_algorithms
  52. */
  53. class OptimizationAlgorithmSecond : private NonCopyable {
  54. public:
  55. virtual ~OptimizationAlgorithmSecond();
  56. inline void optimize(OptimizationProblemSecond& problem) {
  57. problem.init();
  58. doOptimize(problem);
  59. }
  60. protected:
  61. virtual void doOptimize(OptimizationProblemSecond& problem) = 0;
  62. };
  63. }; // namespace NICE
  64. #endif /* _OPTIMIZATIONALGORITHM_OPTIMIZATION_H */