Update parameters dependent on current state

Hi. I’m new to acados and have a vector of parameters which I need to update in each timestep dependent on the previous input and state. I saw that you can set the parameter p like:

for stage in range(N):
  p = ...
  ocp.set(stage, "p", p)

ocp.solve()

But as the optimization is only solved at the end of the code I don’t know how to make p dependent on ocp.get(stage - 1, "x")

Is there a way to do this? I tried just checking the value in the for loop but the return values no not make much sense.

Hi,

this is not possible in general.
The idea of multiple shooting is that the shooting node gaps can be closed simultaneously.
It is possible to carry out a single SQP iteration and then update the parameters as you described between two solver calls.