 # NMPC with different timestep than simulation

Hello,

I am using Acados through the Matlab interface.

I am currently working on a NMPC controller for wind turbines for my Masters thesis.
In this case it is coupled with a PID controller.
The NMPC does trajectory optimization and the PID compensates noise in an inner loop.
There are measurements at some constant timestep dt_1. Therefore the NMPC shoud work with this timestep dt_1 too.
The simulation and with it the PID are working with a smaller timestep dt_2.
Let’s say dt_1 = 10*dt_2.

The current setup is a loop in which the ‘ocp’ is called every 10 simulation steps and the ‘sim’ every step.
To get a smoother behaviour, I interpolate the input linearly for every minor step until the next NMPC step in which the OCP is solved again.
Now there is a small mismatch between the predicted states and the simulated ones because the real behaviour is nonlinear.

To solve this issue, I see two options:

1. Mimic the linearization of the inputs (ie first order hold) inside the OCP.
In a previous version, programmed in Matlab, I did this during the computation of the cost functional.
The simulation done in each iteration of the OCP uses these linearly interpolated intermediate steps.

2. Change to a multistep NMPC. Meaning calculating multiple simulation steps per NMPC step.
This would mean making the OCP bigger as there are 10 times as many stages. (Think 500 instead of 50) I don’t know if this may cause problems in the future when it should run in real time.

My questions are now:

a) Is it possible to incorporate a custom integrator in the OCP and is it advisable? (ie. call the ‘sim’ inside the ‘ocp’)
b) Is there an option for first order hold?
c) Is there an option for such a multistep NMPC or do I just design the OCP for 10 times as many stages and call it every 10th step?

Christian

Hi Christian,

that sounds great! Did you consider using a nonuniform grid for the shooting nodes?
Like having 10 steps of length dt_1, and 50 of length dt_2?
Is that what you mean with “multistep NMPC”?
For setting up a nonuniform grid in Matlab, have a look at this example:

Best,
Jonathan