# Model Predictive Control (MPC) horizon and constraints

I am new to the MPC idea and I am trying to understand the key concepts but there are two things which I found confusing and I didn't find answers regarding to them.

The first one is about the optimized control signal sequence which can be computed from the cost function. If we want to predict, say five steps further, then we will have 5 control signals. After the calculation is done, we will apply only the first signal from the sequence to our system, and them remaining four will be "wasted" (I read that it can be used as an initial guess for the next optimization but thats not my point here). My first question is why don't we just predict one step further, and instead of optimizing five signals, we restrict our optimization to just one, which makes the computation faster?

The second question is about constraints. Lets say that I have some restriction on my input signal, say $0 < u < 5$. With some math, we can include these constraints to the optimization task but it takes more time to solve. Why don't we just do an unconstrainted optimization and after our input signals are ready we apply our contraints on them? Obviously this can not be done for state contraints, but i am interested about input constraints.

Thanks for your answers in advance.

## 2 Answers

Both questions come down to stability. However the a long finite horizon does still not guarantee stability, so often a base policy is assumed afterwards, which is not computationally expensive and can be calculated for an infinite horizon.

For example if you have a mass (of 1 kg) on a fiction less finite surface to which you can apply a force $u$ (in Newtons), so the system can be simply modeled as,

$$\begin{bmatrix} \dot{x} \\ \ddot{x} \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} x \\ \dot{x} \end{bmatrix} + \begin{bmatrix} 0 \\ 1 \end{bmatrix} u. \tag{1}$$

There are also constraints to this system. Namely,

$$\left\{\begin{matrix} -1<u<\frac12 \\ -0.1<x<1.1\end{matrix}\right. \tag{2}$$

Usually for MPC a discrete model is considered. Using a sampling time of 1 second and zero order hold for $u$, then the given continues time model can be converted into the following discrete time model,

$$\begin{bmatrix} x_{k+1} \\ \dot{x}_{k+1} \end{bmatrix} = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x_{k} \\ \dot{x}_{k} \end{bmatrix} + \begin{bmatrix} 0.5 \\ 1 \end{bmatrix} u_{k}. \tag{3}$$

We want to use MPC to find a sequence $\mathbb{u}=\{u_0,u_1,\cdots,u_{N-1}\}$ which minimizes,

$$\min_\mathbb{u}\sum_{k=0}^N x_{k}^2, \tag{4}$$

subjected to $(2)$ and $(3)$. So $x_k$ should be steered towards zero.

The initial condition is given to be $x_0=1$ and $\dot{x}_0 = 0$. If the horizon would be taken to be one, so $N=1$, then solving $(4)$ would yield $u_0=-1$. The state of the system after this input would be $x_1=0.5$ and $\dot{x}_1=-1$. But for the next time step it is not possible to apply a suitable control input, which satisfies the first half of $(2)$ such that the position constraint from $(2)$ will still be met the next time step. Namely applying $u_1=0.5$ would still yield $x_2 = -0.25$ and $\dot{x}_2=-0.5$.

So you need a longer horizon in order to find a $u$ which guarantees that $(2)$ will always be satisfied. When initially neglecting the input constraint and solving $(4)$ for $u_k$ and then saturating the applied input afterwards nullifies the entire remainder of the calculated inputs/states. So nothing can be said based on this applied input about whether system would ever violate $(2)$. For this system this might never be the case, but if you would for example have time dependent inequality constraints then this system might become unstable when neglecting the constraint on $u$ when solving $(4)$.

To your first question: That is because you optimize with those next steps in mind. Intuitively, you don't have to apply a "ridiculous amount" of input if you know that you are also fine if you keep on applying a "normal amount" of input for a while. You apply only the first control, but the rest is part of the calculation.

To your second question: You calculate specific inputs, if you cut them off after the calculation, then why would your controller still work?