Change MPC Formulation to Exploit Sparsity #3681
AhmadAmine998
started this conversation in
General
Replies: 2 comments 1 reply
-
Hello, thank you for your suggestion! It sounds nice for me. |
Beta Was this translation helpful? Give feedback.
0 replies
-
It seems the proposed formulation makes a great improvement in computation time in the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
The current Model Predctive Control algorithm is formulated as a QP with substitution. Given that the system is described by the following dynamics
the current implementation uses equation (1) to substitute the initial state iteratively to get each of the states along the trajectory as a function of the control inputs up to time$k$ and the initial state.
While this formulation results in a QP problem where only the control inputs are the decision variables, it results in a dense, lower triangular matrix that can suffer from numerical instability especially for a large horizon$N$ .
The numerical instability results from the powers of A up to$N$ , which can result in matrices of zero if the system is stable (i.e $\forall_i |\lambda_i| < 1$ ) and $N$ is large enough (depends on precision).
I suggest that the current formulation be replace with a QP formulation without replacement, where the decision variables of the optimization are now the states along the trajectory$x_1 \dots x_N$ as well as the control inputs $u_0 \dots u_{N-1}$ . This formulation results in the following matrix equation:
This can result in a new QP that can be rewritten as a function of the new decision variable
as
by using the following matrices
For reference on the above image, please refer to "Predictive Control for Linear and Hybrid Systems", pages 218-219 (242-243 in the PDF version)
This formulation is used by OSQP Eigen in their MPC example. This new formulation is more numerically stable as it bypasses matrix powers. Additionally, using sparse matrices to construct the$G_0$ and $\bar{H}$ and passing those to OSQP should result in faster solutions as OSQP can exploit the sparsity.
Beta Was this translation helpful? Give feedback.
All reactions