### When to Use Adaptive MPC

MPC control predicts future behavior using a linear-time-invariant (LTI) dynamic model. In practice, such predictions are never exact, and a key tuning objective is to make MPC insensitive to prediction errors. In many applications, this approach is sufficient for robust controller performance.

If the plant is strongly nonlinear or its characteristics vary dramatically with time, LTI prediction accuracy might degrade so much that MPC performance becomes unacceptable. Adaptive MPC can address this degradation by adapting the prediction model for changing operating conditions. As implemented in the Model Predictive Control Toolbox™ software, adaptive MPC uses a fixed model structure, but allows the models parameters to evolve with time. Ideally, whenever the controller requires a prediction (at the beginning of each control interval) it uses a model appropriate for the current conditions.

After you design an MPC controller for the average or most likely operating conditions of your control system, you can implement an adaptive MPC controller based on that design. For information about designing that initial controller, see Controller Creation.

At each control interval, the adaptive MPC controller updates the plant model and nominal conditions. Once updated, the 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.

An alternative option for controlling a nonlinear or time-varying plant is to use gain-scheduled MPC control. See Gain-Scheduled MPC.

### Plant Model

The plant model used as the basis for adaptive MPC must be an LTI discrete-time, state-space model. See Basic Models or Linearization Basics (Simulink Control Design) for information about creating and modifying such systems. The plant model structure is as follows:

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

Here, the matrices A, Bu, Bv, Bd, C, Dv, and Dd are the parameters that can vary with time. The other variables in the expression are:

• k — Time index (current control interval).

• xnx plant model states.

• unu manipulated inputs (MVs). These are the one or more inputs that are adjusted by the MPC controller.

• vnv measured disturbance inputs.

• dnd unmeasured disturbance inputs.

• yny plant outputs, including nym measured and nyu unmeasured outputs. The total number of outputs, ny = nym + nyu. Also, nym ≥ 1 (there is at least one measured output).

• Sample time (`Ts`) is a constant and identical to the MPC control interval.

• Time delay (if any) is absorbed as discrete states (see, for example, the Control System Toolbox™ `absorbDelay` function).

• nx, nu, ny, nd, nym, and nyu are all constants.

• Adaptive MPC prohibits direct feed-through from any manipulated variable to any plant output. Thus, Du = 0 in the above model.

• The input and output signal configuration remains constant.

For more details about creation of plant models for MPC control, see Linear Plant Specification.

### Nominal Operating Point

A traditional MPC controller includes a nominal operating point at which the plant model applies, such as the condition at which you linearize a nonlinear model to obtain the LTI approximation. The `Model.Nominal` property of the controller contains this information.

In adaptive MPC, as time evolves you should update the nominal operating point to be consistent with the updated plant model.

You can write the plant model in terms of deviations from the nominal conditions:

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

Here, the matrices A, B, C, and D are the parameter matrices to be updated. ut is the combined plant input variable, comprising the u, v, and d variables defined above. The nominal conditions to be updated are:

• $\overline{x}$nx nominal states

• $\overline{\Delta x}$nx nominal state increments

• ${\overline{u}}_{t}$nut nominal inputs

• $\overline{y}$ny nominal outputs

### State Estimation

By default, MPC uses a static Kalman filter (KF) to update its controller states, which include the nxp plant model states, nd (≥ 0) disturbance model states, and nn (≥ 0) measurement noise model states. This KF requires two gain matrices, L and M. By default, the MPC controller calculates them during initialization. They depend upon the plant, disturbance, and noise model parameters, and assumptions regarding the stochastic noise signals driving the disturbance and noise models. For more details about state estimation in traditional MPC, see Controller State Estimation.

Adaptive MPC uses a Kalman filter and adjusts the gains, L and M, at each control interval to maintain consistency with the updated plant model. The result is a linear-time-varying Kalman filter (LTVKF):

`$\begin{array}{c}{L}_{k}=\left({A}_{k}{P}_{k|k-1}{C}_{m,k}^{T}+N\right){\left({C}_{m,k}{P}_{k|k-1}{C}_{m,k}^{T}+R\right)}^{-1}\\ {M}_{k}={P}_{k|k-1}{C}_{m,k}^{T}{\left({C}_{m,k}{P}_{k|k-1}{C}_{m,k}^{T}+R\right)}^{-1}\\ {P}_{k+1|k}={A}_{k}{P}_{k|k-1}{A}_{k}^{T}-\left({A}_{k}{P}_{k|k-1}{C}_{m,k}^{T}+N\right){L}_{k}^{T}+Q.\end{array}$`

Here, Q, R, and N are constant covariance matrices defined as in MPC state estimation. Ak and Cm,k are state-space parameter matrices for the entire controller state, defined as for traditional MPC but with the portions affected by the plant model updated to time k. The value Pk|k–1 is the state estimate error covariance matrix at time k based on information available at time k–1. Finally, Lk and Mk are the updated KF gain matrices. For details on the KF formulation used in traditional MPC, see Controller State Estimation. By default, the initial condition, P0|–1, is the static KF solution prior to any model updates.

The KF gain and the state error covariance matrix depend upon the model parameters and the assumptions leading to the constant Q, R, and N matrices. If the plant model is constant, the expressions for Lk and Mk converge to the equivalent static KF solution used in traditional MPC.

The equations for the controller state evolution at time k are identical to the KF formulation of traditional MPC described in Controller State Estimation, but with the estimator gains and state space matrices updated to time k.

You have the option to update the controller state using a procedure external to the MPC controller, and then supply the updated state to MPC at each control instant, k. In this case, the MPC controller skips all KF and LTVKF calculations.