Documentation

Time-Varying MPC

When to Use Time-Varying MPC

To adapt to changing operating conditions, adaptive MPC supports updating the prediction model and its associated nominal conditions at each control interval. However, the updated model and conditions remain constant over the prediction horizon. If you can predict how the plant and nominal conditions vary in the future, you can use time-varying MPC to specify a model that changes over the prediction horizon. Such a linear time-varying (LTV) model is useful when controlling periodic systems or nonlinear systems that are linearized around a time-varying nominal trajectory.

To use time-varying MPC, specify arrays for the `Plant` and `Nominal` input arguments of `mpcmoveAdaptive`. For an example of time-varying MPC, see Time-Varying MPC Control of a Time-Varying Plant.

Time-Varying Prediction Models

Consider the LTV prediction model

`$\begin{array}{c}x\left(k+1\right)=A\left(k\right)x\left(k\right)+{B}_{u}\left(k\right)u\left(k\right)+{B}_{v}\left(k\right)v\left(k\right)\\ y\left(k\right)=C\left(k\right)x\left(k\right)+{D}_{v}\left(k\right)v\left(k\right)\end{array}$`

where A, Bu, Bv, C, and D are discrete-time state-space matrices that can vary with time. The other model parameters are:

• k — Current control interval time index

• x — Plant model states

• u — Manipulated variables

• v — Measured disturbance inputs

• y — Measured and unmeasured plant outputs

Since time-varying MPC extends adaptive MPC, the plant model requirements are the same; that is, for each model in the `Plant` array:

• Sample time (`Ts`) is constant and identical to the MPC controller sample time.

• Any time delays are absorbed as discrete states.

• The input and output signal configuration remains constant.

• There is no direct feed-through from the manipulated variables to the plant outputs.

The prediction of future trajectories for p steps into the future, where p is the prediction horizon, is the same as for the adaptive MPC case:

`$\left[\begin{array}{c}y\left(1\right)\\ ⋮\\ y\left(p\right)\end{array}\right]={S}_{x}x\left(0\right)+{S}_{u1}u\left(-1\right)+{S}_{u}\left[\begin{array}{c}\Delta u\left(0\right)\\ ⋮\\ \Delta u\left(p-1\right)\end{array}\right]+{H}_{v}\left[\begin{array}{c}v\left(0\right)\\ ⋮\\ v\left(p\right)\end{array}\right]$`

However, for an LTV prediction model, the matrices Sx, Su1, Su, and Hv are:

`$\begin{array}{c}{S}_{x}=\left[\begin{array}{l}C\left(1\right)A\left(0\right)\hfill \\ C\left(2\right)A\left(1\right)A\left(0\right)\hfill \\ ⋮\hfill \\ C\left(p\right){\prod }_{i=0}^{p-1}A\left(i\right)\hfill \end{array}\right]\\ {S}_{u1}=\left[\begin{array}{l}C\left(1\right){B}_{u}\left(0\right)\hfill \\ C\left(2\right)\left[{B}_{u}\left(1\right)+A\left(1\right){B}_{u}\left(0\right)\right]\hfill \\ ⋮\hfill \\ C\left(p\right){\sum }_{k=0}^{p-1}\left[\left({\prod }_{i=k+1}^{p-1}A\left(i\right)\right){B}_{u}\left(k\right)\right]\hfill \end{array}\right]\\ {S}_{u}=\left[\begin{array}{lllll}\hfill & 0\hfill & 0\hfill & \cdots \hfill & 0\hfill \\ {S}_{u1}\hfill & C\left(2\right){B}_{u}\left(1\right)\hfill & 0\hfill & \cdots \hfill & 0\hfill \\ \hfill & ⋮\hfill & \hfill & \hfill & \hfill \\ \hfill & C\left(p\right){\sum }_{k=1}^{p-1}\left[\left({\prod }_{i=k+1}^{p-1}A\left(i\right)\right){B}_{u}\left(k\right)\right]\hfill & \cdots \hfill & \cdots \hfill & C\left(p\right){B}_{u}\left(p-1\right)\hfill \end{array}\right]\\ {H}_{v}=\left[\begin{array}{lllll}C\left(1\right){B}_{v}\left(0\right)\hfill & {D}_{v}\left(1\right)\hfill & 0\hfill & \cdots \hfill & 0\hfill \\ C\left(2\right)A\left(1\right){B}_{v}\left(0\right)\hfill & C\left(2\right){B}_{v}\left(1\right)\hfill & {D}_{v}\left(2\right)\hfill & \cdots \hfill & 0\hfill \\ ⋮\hfill & ⋮\hfill & ⋮\hfill & \hfill & ⋮\hfill \\ C\left(p\right)\left({\prod }_{i=1}^{p-1}A\left(i\right)\right){B}_{v}\left(0\right)\hfill & \cdots \hfill & \cdots \hfill & C\left(p\right){B}_{v}\left(p-1\right)\hfill & {D}_{v}\left(p\right)\hfill \end{array}\right]\end{array}$`

where ${\prod }_{i={k}_{1}}^{{k}_{2}}A\left(i\right)\triangleq A\left({k}_{2}\right)A\left({k}_{2}-1\right)\dots A\left({k}_{1}\right)$ if ${k}_{2}\ge {k}_{1}$, or I otherwise.

Time-Varying Nominal Conditions

Linear models are often obtained by linearizing nonlinear dynamics around time-varying nominal trajectories. For example, consider the following LTI model, obtained by linearizing a nonlinear system at the time-varying nominal offsets xoff, uoff, voff, and yoff:

`$\begin{array}{c}x\left(k+1\right)-{x}_{off}\left(k+1\right)=A\left(k\right)\left(x\left(k\right)-{x}_{off}\left(k\right)\right)+{B}_{u}\left(k\right)\left(u\left(k\right)-{u}_{off}\left(k\right)\right)\\ +{B}_{v}\left(k\right)\left(v\left(k\right)-{v}_{off}\left(k\right)\right)+\Delta {x}_{off}\left(k\right)\\ \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}y\left(k\right)-{y}_{off}\left(k\right)=C\left(k\right)\left(x\left(k\right)-{x}_{off}\left(k\right)\right)+{D}_{v}\left(k\right)\left(v\left(k\right)-{v}_{off}\left(k\right)\right)\end{array}$`

If we define

`$\begin{array}{c}\overline{{x}_{off}}\triangleq x\left(0\right),\text{ }\overline{{u}_{off}}\triangleq u\left(0\right)\\ \overline{{v}_{off}}\triangleq v\left(0\right),\text{ }\overline{{y}_{off}}\triangleq y\left(0\right)\end{array}$`

as standard nominal values that remain constant over the prediction horizon, we can transform the LTI model into the following LTV model:

`$\begin{array}{c}x\left(k+1\right)-\overline{{x}_{off}}=A\left(k\right)\left(x\left(k\right)-\overline{{x}_{off}}\right)+{B}_{u}\left(k\right)\left(u\left(k\right)-\overline{{u}_{off}}\right)+{B}_{v}\left(k\right)\left(v\left(k\right)-\overline{{v}_{off}}\right)+{\overline{B}}_{v}\left(k\right)\\ y\left(k\right)-\overline{{y}_{off}}=C\left(k\right)\left(x\left(k\right)-\overline{{x}_{off}}\right)+{D}_{v}\left(k\right)\left(v\left(k\right)-\overline{{v}_{off}}\right)+{\overline{D}}_{v}\left(k\right)\end{array}$`

where

`$\begin{array}{c}{\overline{B}}_{v}\left(k\right)\triangleq \Delta {x}_{off}\left(k\right)+{x}_{off}\left(k\right)-\overline{{x}_{off}}+A\left(k\right)\left(\overline{{x}_{off}}-{x}_{off}\left(k\right)\right)+{B}_{u}\left(k\right)\left(\overline{{u}_{off}}-{u}_{off}\left(k\right)\right)\\ +{B}_{v}\left(k\right)\left(\overline{{v}_{off}}-{v}_{off}\left(k\right)\right)\\ {\overline{D}}_{v}\left(k\right)\triangleq {y}_{off}\left(k\right)-\overline{{y}_{off}}+C\left(k\right)\left(\overline{{x}_{off}}-{x}_{off}\left(k\right)\right)+{D}_{v}\left(k\right)\left(\overline{{v}_{off}}-{v}_{off}\left(k\right)\right)\end{array}$`

If the original linearized model is already LTV, the same transformation applies.

State Estimation

As with adaptive MPC, time-varying MPC uses a time-varying Kalman filter based on A(0), B(0), C(0), and D(0) from the initial prediction step; that is, the current time at which the state is estimated. For more information, see State Estimation.