Python interface: possibility to change predicting horizon after solver is created

Hi!

I am implementing an MPC using the Python interface for acados. Originally the MPC has a horizon time tf = 1 and predicting horizon N = 20.

However, the MPC also requires shrinking the horizon if N = 20 is not feasible, so I would like to change tf and N after the AcadosOcpSolver object is created, during simulation.

I tried directly modifying the object attributes self.ocp.solver_options.tf and self.ocp.dims.N during simulation but they don’t seem to take effect.

May I ask if it is possible to modify these two or equivalent parameters online? If not possible, how can I recompile the solver object so the changes can take effect? Thanks a lot!!!

Hi,

you can use the function set_new_time_steps.

Great, thanks a lot!