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?

Thanks in advance,

Christian

Hi Christian,

that sounds great! :raised_hands:

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

Thank you for your help.
I didn’t know about nonuniform grids for shooting nodes and I think it is what I need.

After implementing this in my OCP, the optimized input oscillates in the first few steps of the OCP.
I use the old input to warmstart the next iteration, but the oscillation causes quite a big mismatch between the optimized input between the steps.
The measured disturbance does not change between the steps, so the optimized input trajectories should be mostly the same for the first steps.
Any idea on what i need to tweak to get the desired smooth input?

It kind of sounds like you want to have rate constraints on the inputs, for that, check out this post: