Block entries in common::math::SolveLinearMPC kernel matrix_k
The block entries in kernel matrix matrix_k in common::math::SolveLinearMPC seem to be erroneously pre-multiplied by an additional matrix_a term . The lower-triangular kernel matrix matrix_k is defined according to the following code:
std::vector<Matrix> matrix_a_power(horizon);
matrix_a_power[0] = matrix_a;
for (unsigned int i = 1; i < matrix_a_power.size(); ++i) {
matrix_a_power[i] = matrix_a * matrix_a_power[i - 1];
}
Matrix matrix_k =
Matrix::Zero(matrix_b.rows() * horizon, matrix_b.cols() * horizon);
for (unsigned int r = 0; r < horizon; ++r) {
for (unsigned int c = 0; c <= r; ++c) {
matrix_k.block(r * matrix_b.rows(), c * matrix_b.cols(), matrix_b.rows(),
matrix_b.cols()) = matrix_a_power[r - c] * matrix_b;
}
}
This implies
The diagonal matrix_k is thus filled with matrix_a * matrix_b. However, this diagonal should really consist of just matrix_b, and all the other entries offset accordingly. In otherwords, initially we should write
matrix_a_power[0] = Matrix::Identity(matrix_a.rows(), matrix_a.rows());
Please let me know if this is a correct assessment. I argue this is the case, as block operations in matrix_m1 and matrix_m on stacked transition state/control vectors should be contemporaneous:
matrix_m.block(0, 0, matrix_a.rows(), 1) =
matrix_a * matrix_initial_state + matrix_c;
@berthu Sorry that we could not get back to you on your request. Is this a question you still need an answer to?
Closing this issue as we have not heard back in a while. Feel free to reopen if you have additional questions. Thanks!