MultiphaseOcp in combination with "Shrinking Horizon" MPC

Hi everyone,

basically i look forward to use an “shrinking Horizon MPC”, i.e. i always want to optimize from the measured state over to whole trajectory until the terminal state, but in combination with MultiphaseOcp.

There the main challenge is how to deal with already terminated phases after phase transition, since from there on i only care about the future.

I want to use acados, but i wanted to ask, if its possible, to change the grid:
N_list = [N_horizon_phase1, N_horizon_phase2, N_horizon_phase3]
to e.g.
N_list = [N_horizon_phase2, N_horizon_phase3]
after already building the solver.

Or at least, if it is possible to pre build the solvers for the different phases, and to use them in MPC in dependency of the phase.

Thanks in Advance :slight_smile:

Hi all,

I am facing a similar, yet more general issue: How to do real-time iterations in a multi-phase setting? Let’s assume two phases where transition from one phase to another happens at a particular date (in global time): In a standard MPC with forward moving horizon of fixed sample length, the phase transition would come closer and closer in time, i.e. each time the horizon shifts forward, phase transition happens one time step earlier within the horizon. At some point in time, there would probably remain just a single phase within the horizon. Is it possible to setup a efficient/fast RTI scheme for such a scenario, or can you think of workarounds to do so?

Best regards,
Philipp

Hi both,

happy to hear you are interested in the multi-phase OCPs (MOCPs) in acados for MPC!
The multi-phase approaches that were heavily researched, tested by us and presented in our multi-phase paper do not require changing the horizon qualitatively when employing the solver in an MPC loop.
However, of course there are cases where this is necessary as you motivated.
I did not implement such a case myself yet and I don’t think that there is a general solution as it very much depends on the qualitative change and the differences of the phases.

One possibility is to create different solvers, as @acadosUser suggeststed, and switch between them in the MPC loop maybe even smartly transferring iterates for initialization.

In general, there is no acados example that does MPC with a varying horizon length.
One major limitation is that the solver needs to be created once with the appropriate structure and in particular the dimensions can not change afterwards.
It is possible to change the cost function weights, parameter values, constraint limits and time steps. Where changing time_steps is not implemented for MOCP in the high-level interfaces of acados yet, but that could be added, relatively easily.
Updating those values allows one to “trivialize” certain parts of the horizon, i.e. to drop a state transition by changing the dynamics at a stage to x_{k+1} = x_k, setting the cost to zero and removing constraints by setting the corresponding bounds.
Such “trivial” stages still cause some overhead in the solver.
However, in many cases it will be computationally cheaper to do so, compared to switching to another solver.
Moreover, typically the frequency of the controller is constant in the context of MPC, so if within the sampling time the full problem can be solved, or an approximate step towards the solution can be performed, such as an RTI iteration, also problems where some parts are trivialized can be solved in the sampling time (approximately).

Depending on what kind of formulations you have and how the phases are changing a combination of those approaches (i.e. trivializing and multiple solvers) might be beneficial or even required.

Best,
Jonathan

1 Like

Hi Jonathan,

thank you very much for your quick answer! That clarified a lot for me!

1 Like