ILSPlainGradient.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * @file ILSPlainGradient.h
  3. * @author Erik Rodner
  4. * @date 12/21/2011
  5. */
  6. #ifndef _NICE_ILSPlainGradient_INCLUDE
  7. #define _NICE_ILSPlainGradient_INCLUDE
  8. #include "core/vector/VectorT.h"
  9. #include "core/optimization/gradientBased/OptimizationProblemFirst.h"
  10. #include "core/optimization/gradientBased/OptimizationAlgorithmFirst.h"
  11. #include "IterativeLinearSolver.h"
  12. namespace NICE {
  13. /** @class ILSPlainGradient
  14. * Iterative linear solver using our own non-linear optimization techniques
  15. * and assuming symmetric matrices
  16. *
  17. * @author Erik Rodner
  18. */
  19. class ILSPlainGradient : public IterativeLinearSolver
  20. {
  21. protected:
  22. bool verbose;
  23. bool minResidual;
  24. OptimizationAlgorithmFirst *optimizer;
  25. public:
  26. /** simple constructor */
  27. ILSPlainGradient( bool verbose = false, int maxIterations = 1000, bool minResidual = true );
  28. /** simple destructor */
  29. virtual ~ILSPlainGradient();
  30. /**
  31. * @brief Solve the linear System A*x = b, where A is indirectly presented
  32. * by the GenericMatrix gm and A is symmetric
  33. *
  34. * @param gm GenericMatrix providing matrix-vector multiplications (symmetry required!)
  35. * @param b Vector on the right hand side of the system
  36. * @param x solution
  37. *
  38. * @return method specific status information
  39. */
  40. virtual int solveLin ( const GenericMatrix & gm, const Vector & b, Vector & x );
  41. };
  42. /**
  43. * @brief This class implements a quadratic optimization problem, trying to minimize $0.5 * \| A x - b \|^2$ (minimum residual)
  44. * or $0.5 * x^T A x - b^T x$ for symmetric A but without any additional constraints.
  45. */
  46. class ILSPlainGradientOptimizationProblem : public OptimizationProblemFirst
  47. {
  48. protected:
  49. const GenericMatrix *m_gm;
  50. Vector m_b;
  51. bool minResidual;
  52. public:
  53. /**
  54. * @brief Constructor
  55. *
  56. * @param gm input generic matrix object
  57. */
  58. ILSPlainGradientOptimizationProblem( const GenericMatrix *gm, const Vector & b, const Vector & x0, bool minResidual = true );
  59. /**
  60. * @brief Compute the objective
  61. *
  62. * @return
  63. */
  64. virtual double computeObjective();
  65. /**
  66. * @brief Compute the gradient of the problem
  67. *
  68. * @param newGradient output gradient vector
  69. */
  70. virtual void computeGradient(Vector& newGradient);
  71. };
  72. }
  73. #endif