Arduino_Unconstrained_MPC_Library icon indicating copy to clipboard operation
Arduino_Unconstrained_MPC_Library copied to clipboard

Matrix size problem (3rd implementation)

Open tomcelentec opened this issue 4 years ago • 0 comments
trafficstars

In the third implementation (the numerically robust one), R_L matrix is defined with a size of {(MPC_HP_LEN*SS_Z_LEN + MPC_HU_LEN*SS_U_LEN), MPC_HP_LEN*SS_Z_LEN}. But R_L is multiplied with dU(k)_optimal during the problem formulation. As dU(k)_optimal has a size of {MPC_HU_LEN*SS_U_LEN,1}, the R_L matrix should have a size of {(MPC_HP_LEN*SS_Z_LEN + MPC_HU_LEN*SS_U_LEN), MPC_HU_LEN*SS_U_LEN}.

This size is confirmed by the fact that GammaLeft is (SQ*CTHETA) over SR :

  • SQ has a size of {MPC_HP_LEN*SS_Z_LEN, MPC_HP_LEN*SS_Z_LEN}
  • CTHETA has a size of {MPC_HP_LEN*SS_Z_LEN, MPC_HU_LEN*SS_U_LEN}
  • Thus, SQ*CTHETA has a size of {MPC_HP_LEN*SS_Z_LEN, MPC_HU_LEN*SS_U_LEN}
  • SR has a size of {MPC_HU_LEN*SS_U_LEN, MPC_HU_LEN*SS_U_LEN}
  • Therefore (SQ*CTHETA) over SR has a size of {(MPC_HP_LEN*SS_Z_LEN + MPC_HU_LEN*SS_U_LEN), MPC_HU_LEN*SS_U_LEN}
  • Q_L * R_L = GammaLeft, so the number of columns of R_L is the number of columns of GammaLeft, which is MPC_HU_LEN*SS_U_LEN and not MPC_HP_LEN*SS_Z_LEN

In your model, it does not seem to be an issue because MPC_HU_LEN*SS_U_LEN is 8 and MPC_HP_LEN*SS_Z_LEN is 14, i.e. MPC_HU_LEN*SS_U_LEN < MPC_HP_LEN*SS_Z_LEN.

Nonetheless, thank you for this amazing open source code Best regards

tomcelentec avatar Aug 25 '21 12:08 tomcelentec