![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
HCB with MPC
Dependencies: mbed Eigen FastPWM
quadprog.h@25:f83396e3d25c, 2019-10-14 (annotated)
- Committer:
- jsoh91
- Date:
- Mon Oct 14 10:08:13 2019 +0000
- Revision:
- 25:f83396e3d25c
withMPC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jsoh91 | 25:f83396e3d25c | 1 | /* |
jsoh91 | 25:f83396e3d25c | 2 | File $Id: QuadProg++.hh 232 2007-06-21 12:29:00Z digasper $ |
jsoh91 | 25:f83396e3d25c | 3 | |
jsoh91 | 25:f83396e3d25c | 4 | The quadprog_solve() function implements the algorithm of Goldfarb and Idnani |
jsoh91 | 25:f83396e3d25c | 5 | for the solution of a (convex) Quadratic Programming problem |
jsoh91 | 25:f83396e3d25c | 6 | by means of an active-set dual method. |
jsoh91 | 25:f83396e3d25c | 7 | |
jsoh91 | 25:f83396e3d25c | 8 | The problem is in the form: |
jsoh91 | 25:f83396e3d25c | 9 | |
jsoh91 | 25:f83396e3d25c | 10 | min 0.5 * x G x + g0 x |
jsoh91 | 25:f83396e3d25c | 11 | s.t. |
jsoh91 | 25:f83396e3d25c | 12 | CE^T x + ce0 = 0 |
jsoh91 | 25:f83396e3d25c | 13 | CI^T x + ci0 >= 0 |
jsoh91 | 25:f83396e3d25c | 14 | |
jsoh91 | 25:f83396e3d25c | 15 | The matrix and vectors dimensions are as follows: |
jsoh91 | 25:f83396e3d25c | 16 | G: n * n |
jsoh91 | 25:f83396e3d25c | 17 | g0: n |
jsoh91 | 25:f83396e3d25c | 18 | |
jsoh91 | 25:f83396e3d25c | 19 | CE: n * p |
jsoh91 | 25:f83396e3d25c | 20 | ce0: p |
jsoh91 | 25:f83396e3d25c | 21 | |
jsoh91 | 25:f83396e3d25c | 22 | CI: n * m |
jsoh91 | 25:f83396e3d25c | 23 | ci0: m |
jsoh91 | 25:f83396e3d25c | 24 | |
jsoh91 | 25:f83396e3d25c | 25 | x: n |
jsoh91 | 25:f83396e3d25c | 26 | |
jsoh91 | 25:f83396e3d25c | 27 | The function will return the cost of the solution written in the x vector or |
jsoh91 | 25:f83396e3d25c | 28 | std::numeric_limits::infinity() if the problem is infeasible. In the latter case |
jsoh91 | 25:f83396e3d25c | 29 | the value of the x vector is not correct. |
jsoh91 | 25:f83396e3d25c | 30 | |
jsoh91 | 25:f83396e3d25c | 31 | References: D. Goldfarb, A. Idnani. A numerically stable dual method for solving |
jsoh91 | 25:f83396e3d25c | 32 | strictly convex quadratic programs. Mathematical Programming 27 (1983) pp. 1-33. |
jsoh91 | 25:f83396e3d25c | 33 | |
jsoh91 | 25:f83396e3d25c | 34 | Notes: |
jsoh91 | 25:f83396e3d25c | 35 | 1. pay attention in setting up the vectors ce0 and ci0. |
jsoh91 | 25:f83396e3d25c | 36 | If the constraints of your problem are specified in the form |
jsoh91 | 25:f83396e3d25c | 37 | A^T x = b and C^T x >= d, then you should set ce0 = -b and ci0 = -d. |
jsoh91 | 25:f83396e3d25c | 38 | 2. The matrices have column dimension equal to MATRIX_DIM, |
jsoh91 | 25:f83396e3d25c | 39 | a constant set to 20 in this file (by means of a #define macro). |
jsoh91 | 25:f83396e3d25c | 40 | If the matrices are bigger than 20 x 20 the limit could be |
jsoh91 | 25:f83396e3d25c | 41 | increased by means of a -DMATRIX_DIM=n on the compiler command line. |
jsoh91 | 25:f83396e3d25c | 42 | 3. The matrix G is modified within the function since it is used to compute |
jsoh91 | 25:f83396e3d25c | 43 | the G = L^T L cholesky factorization for further computations inside the function. |
jsoh91 | 25:f83396e3d25c | 44 | If you need the original matrix G you should make a copy of it and pass the copy |
jsoh91 | 25:f83396e3d25c | 45 | to the function. |
jsoh91 | 25:f83396e3d25c | 46 | |
jsoh91 | 25:f83396e3d25c | 47 | Author: Luca Di Gaspero |
jsoh91 | 25:f83396e3d25c | 48 | DIEGM - University of Udine, Italy |
jsoh91 | 25:f83396e3d25c | 49 | luca.digaspero@uniud.it |
jsoh91 | 25:f83396e3d25c | 50 | http://www.diegm.uniud.it/digaspero/ |
jsoh91 | 25:f83396e3d25c | 51 | |
jsoh91 | 25:f83396e3d25c | 52 | The author will be grateful if the researchers using this software will |
jsoh91 | 25:f83396e3d25c | 53 | acknowledge the contribution of this function in their research papers. |
jsoh91 | 25:f83396e3d25c | 54 | |
jsoh91 | 25:f83396e3d25c | 55 | Copyright (c) 2007-2016 Luca Di Gaspero |
jsoh91 | 25:f83396e3d25c | 56 | |
jsoh91 | 25:f83396e3d25c | 57 | This software may be modified and distributed under the terms |
jsoh91 | 25:f83396e3d25c | 58 | of the MIT license. See the LICENSE file for details. |
jsoh91 | 25:f83396e3d25c | 59 | */ |
jsoh91 | 25:f83396e3d25c | 60 | |
jsoh91 | 25:f83396e3d25c | 61 | |
jsoh91 | 25:f83396e3d25c | 62 | #ifndef _QUADPROGPP |
jsoh91 | 25:f83396e3d25c | 63 | #define _QUADPROGPP |
jsoh91 | 25:f83396e3d25c | 64 | |
jsoh91 | 25:f83396e3d25c | 65 | #include "Array.h" |
jsoh91 | 25:f83396e3d25c | 66 | |
jsoh91 | 25:f83396e3d25c | 67 | namespace quadprogpp { |
jsoh91 | 25:f83396e3d25c | 68 | |
jsoh91 | 25:f83396e3d25c | 69 | double solve_quadprog(Matrix<double>& G, Vector<double>& g0, |
jsoh91 | 25:f83396e3d25c | 70 | const Matrix<double>& CE, const Vector<double>& ce0, |
jsoh91 | 25:f83396e3d25c | 71 | const Matrix<double>& CI, const Vector<double>& ci0, |
jsoh91 | 25:f83396e3d25c | 72 | Vector<double>& x); |
jsoh91 | 25:f83396e3d25c | 73 | |
jsoh91 | 25:f83396e3d25c | 74 | } // namespace quadprogpp |
jsoh91 | 25:f83396e3d25c | 75 | |
jsoh91 | 25:f83396e3d25c | 76 | #endif // #define _QUADPROGPP |