# Is there any rule of thumb when it comes to selecting control/predict horizon for MPC?

I have a simple question:

Is there any rule of thumb when it comes to selecting control/predict horizon for MPC?

Normaly I set control and predict horizon equals, but I have heard that's not good practice.

I'm developing my own adaptive(subspace identification) constrained MPC with GNU Octave and it works very good! But still I need some method where I can auto select the horizon of predict and control.

I know the model of the system and I can find the damping, time constant, poles and eigen frequency. Can I use them to compute the horizons?

If you wonder what algorithm I'm using, I'm using Observer Kalman Filter Identification to compute the impulse response from an arbitrary input and output, then Eigensystem Realization Algorithm to turn the impulse response into a discrete state space model. I have tried N4SID, MOESP, ARX but they are too advanced and requried more tuning and data to get a good model.

System Identification Algorithms: https://github.com/DanielMartensson/Mataveid

Constrained Model Predictive Control: https://github.com/DanielMartensson/Matavecontrol

I would say that there is no simple rule. Long enough to capture the important behavior.

I've never heard anyone saying it is bad practice to use same control and prediction horizon. Why complicate matters with two design choices.

• If you add a real rollout policy like LQR then you can technically have an infinite horizon. I believe without this you also do not have a stability proof. But you do need to show that this policy does not violate any of the constraints. Commented Dec 26, 2018 at 22:10
• A standard approach is to add a terminal penalty derived from the infinite horizon costs (i.e. the solution to the Riccati equation). This at least guarantees stability in a non-trivial set around the origin, and although not guaranteeing stability generally it is definitely a sound way to make the MPC controller closer to the inifinite horizon solution and give non-constrained response identical to the LQ response. This serves as the basis for most guaranteed stability approaches. Commented Dec 27, 2018 at 8:49

In most of the cases, the prediction and control horizons are defined by methods based trial and error. They are not the best values but as far as they work, people are happy.

If you are looking for a more structured method, that is simple. Just optimize the horizons $$N_c$$ and $$N_p$$. Use evolutionary algorithms such as GA. Have a look at the following publication:

Mohammadi, Arash, et al. "Optimizing model predictive control horizons using genetic algorithm for motion cueing algorithm." Expert Systems with Applications 92 (2018): 73-81.

Available here and here.

In respond to should you use $$N_c=N_p$$. It depends. For my case, as $$N_p$$ is very long, increase in control horizon slows down the computation. If the prediction horizon is short enough, there is not problem with that. Also, is future reference signal variable and predictable? If yes, feel free to use a long $$N_c$$ but if your future reference signal is constant, maybe $$N_c=3$$ is enough.