MPCC icon indicating copy to clipboard operation
MPCC copied to clipboard

Possible indexation problem

Open KarasevPavel opened this issue 1 year ago • 2 comments

https://github.com/alexliniger/MPCC/blob/302e12a0546221963dc2430477e54a279532c52d/C%2B%2B/MPC/mpc.cpp#L48

I think, there is an indexation problem here in the fullsize branch, when we want to get initial_guess_[i+1] and i == N, because initial_guess_ array has only "N+1" elements in it

KarasevPavel avatar Apr 26 '23 08:04 KarasevPavel

Thanks for pointing this out, I will have a look. The only place "N+2" element is used is to generate the dynamics of the N+1 step, which is not used in the MPC formulation. But if the code is really stepping over the index length this is still bad, and I will add a fix as soon as I have time.

alexliniger avatar Apr 27 '23 07:04 alexliniger

There is a very simple solution to this problem, just use initial_guess_[std::min(i+1, N)] as done in the dev/docker-cppad brunch. I will add the fix as soon as possible to the other brunches.

alexliniger avatar Jun 29 '23 19:06 alexliniger