You are on page 1of 1

Yutao - 2017-03-08 Hi all,Similar questions were asked in this forum but there was no

explict answers. I'd like to ask again: is there a way to set different prediction and control horizons
in the Code Generation tool of ACADO?In the paper by Rien "Autogenerating Microsecond
Solvers for Nonlinear MPC: a Tutorial Using ACADO Integrators", such an idea is described using
continous output and implicit integrators. However, the explanation there is too rough. I don't how
to implement it at all.Thanks,Yutao

Rien Quirynen - 2017-03-10 Hey Yutao,In the paper that you refer, the integrators with
continuous output were used to prototype a new algorithm in MATLAB so the use of continuous
output like that is indeed not directly supported by the ACADO code generation tool as explained
in the paper.This said, it would be possible to change the discretization grid in the control horizon
in one of two ways:1) you can use a nonequidistant grid, by defining a certain integration step size
and letting the solver take a different number of steps in each shooting interval as described in this
book chapter:
https://www.researchgate.net/publication/300331825_Multiple_Shooting_in_a_Microsecond

In the actual code, you do this by providing a vector of length equal to the number of shooting
intervals and this vector specifies how many integration steps you want taken in each interval. In
C++ code, this would look as follows:

Vector numSteps(4);
numSteps(0) = 1; // 1
numSteps(1) = 2; // 3
numSteps(2) = 3; // 6
numSteps(3) = 4; // 10

// SET UP THE MPC - OPTIMAL CONTROL PROBLEM:


// ----------------------------------------------------------
OCP ocp( 0.0, 1.0, numSteps ); // stepsize: 0.1

But you can do exactly the same from MATLAB as well (you just provide a vector as the
third argument again)!2) alternatively, more as a hack, you can exploit the use of online data to
scale the dynamics differently in each shooting interval which will create the same effect of having
a nonequidistant grid. However, unlike the first option above, this will still result in the same
number of integration steps being taken in each shooting interval regardless of the scaling factor
(which has advantages and disadvantages of course). Using online data, you could also try to
implement the behavior of a local controller by the way in order to have the local controller operate
in the (long) prediction horizon.This said, a prediction horizon is typically used to reduce the
amount of optimization variables and therefore the computational effort. But since this is not
exploited in the ACADO code generation tool, you should probably not try to do this from a
computational standpoint (unless in the case of the paper cited above on the use of a
nonequidistant control grid).I hope this could help you further, Rien

You might also like