apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Block entries in common::math::SolveLinearMPC kernel matrix_k

Open berthu opened this issue 8 years ago • 2 comments

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 equation

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 avatar Mar 14 '18 03:03 berthu

@berthu Sorry that we could not get back to you on your request. Is this a question you still need an answer to?

natashadsouza avatar Aug 27 '18 23:08 natashadsouza

Closing this issue as we have not heard back in a while. Feel free to reopen if you have additional questions. Thanks!

natashadsouza avatar May 21 '19 00:05 natashadsouza