QuadProg++.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. The quadprog_solve() function implements the algorithm of Goldfarb and Idnani
  3. for the solution of a (convex) Quadratic Programming problem
  4. by means of an active-set dual method.
  5. The problem is in the form:
  6. min 0.5 * x G x + g0 x
  7. s.t.
  8. CE^T x + ce0 = 0
  9. CI^T x + ci0 >= 0
  10. The matrix and vectors dimensions are as follows:
  11. G: n * n
  12. g0: n
  13. CE: n * p
  14. ce0: p
  15. CI: n * m
  16. ci0: m
  17. x: n
  18. The function will return the cost of the solution written in the x vector or
  19. std::numeric_limits::infinity() if the problem is infeasible. In the latter case
  20. the value of the x vector is not correct.
  21. References: D. Goldfarb, A. Idnani. A numerically stable dual method for solving
  22. strictly convex quadratic programs. Mathematical Programming 27 (1983) pp. 1-33.
  23. Notes:
  24. 1. pay attention in setting up the vectors ce0 and ci0.
  25. If the constraints of your problem are specified in the form
  26. A^T x = b and C^T x >= d, then you should set ce0 = -b and ci0 = -d.
  27. 2. The matrix G is modified within the function since it is used to compute
  28. the G = L^T L cholesky factorization for further computations inside the function.
  29. If you need the original matrix G you should make a copy of it and pass the copy
  30. to the function.
  31. Author: Luca Di Gaspero
  32. DIEGM - University of Udine, Italy
  33. l.digaspero@uniud.it
  34. http://www.diegm.uniud.it/digaspero/
  35. The author will be grateful if the researchers using this software will
  36. acknowledge the contribution of this function in their research papers.
  37. LICENSE
  38. This file is part of QuadProg++: a C++ library implementing
  39. the algorithm of Goldfarb and Idnani for the solution of a (convex)
  40. Quadratic Programming problem by means of an active-set dual method.
  41. Copyright (C) 2007-2009 Luca Di Gaspero.
  42. Copyright (C) 2009 Eric Moyer.
  43. QuadProg++ is free software: you can redistribute it and/or modify
  44. it under the terms of the GNU Lesser General Public License as published by
  45. the Free Software Foundation, either version 3 of the License, or
  46. (at your option) any later version.
  47. QuadProg++ is distributed in the hope that it will be useful,
  48. but WITHOUT ANY WARRANTY; without even the implied warranty of
  49. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  50. GNU Lesser General Public License for more details.
  51. You should have received a copy of the GNU Lesser General Public License
  52. along with QuadProg++. If not, see <http://www.gnu.org/licenses/>.
  53. */
  54. #ifndef _QUADPROGPP
  55. #define _QUADPROGPP
  56. #include "vislearning/optimization/quadprog/Array.h"
  57. namespace QuadProgPP{
  58. double solve_quadprog(Matrix<double>& G, Vector<double>& g0,
  59. const Matrix<double>& CE, const Vector<double>& ce0,
  60. const Matrix<double>& CI, const Vector<double>& ci0,
  61. Vector<double>& x);
  62. }
  63. #endif // #define _QUADPROGPP