Key Features

  • App for interactive design of MPC controllers
  • Runtime adjustment of weights and constraints
  • Adaptive and gain-scheduled MPCs for controlling systems with nonlinear dynamics
  • Explicit MPC and approximate solution for guaranteed worst-case execution time
  • Economic MPC with arbitrary nonlinear cost function and constraints​​
  • Computationally efficient quadratic programming (QP) solver, and support for third-party solvers
  • Support for C-code generation (with Simulink Coder™) and IEC 61131-3 Structured Text generation (with Simulink PLC Coder™)

MPC Controller block (red) for designing and simulating model predictive controllers directly in Simulink.


Designing and Simulating Model Predictive Controllers

Model predictive controllers can be used to optimize closed-loop system performance of MIMO plants subject to input and output constraints. Because they base their actions on an internal plant model, model predictive controllers can forecast future process behavior and compute the optimal control actions accordingly. The ability to model process interactions often enables model predictive controllers to outperform multiple PID control loops, which require individual tuning and other techniques to reduce loop coupling.

Model Predictive Control Toolbox™ provides functions, an app, and Simulink® blocks for designing and simulating model predictive controllers in MATLAB® and Simulink.

You can iteratively improve your controller design by defining an internal plant model, adjusting controller parameters such as weights and constraints, and simulating closed-loop system response to evaluate controller performance.

Use Model Predictive Control Toolbox to design and simulate model predictive controllers.

Defining Internal Plant Models

When designing a model predictive controller in Simulink, you can use Simulink Control Design™ to extract a linearized form of the Simulink model and automatically import it into the controller as the internal plant model.

Alternatively, you can use linear time-invariant (LTI) systems from Control System Toolbox™, such as a transfer function or a state-space model, to specify the internal plant model. Model Predictive Control Toolbox also lets you directly import models created from measured input-output data using System Identification Toolbox™.


Designing Controllers

Once you have defined the internal plant model, you can complete the design of your model predictive controller by specifying the following controller parameters:

  • Control interval (sample time)
  • Prediction and control horizons
  • Scale factors for plant inputs and outputs
  • Hard and soft constraints on manipulated variables, manipulated variable rates, and output variables
  • Weights on manipulated variables, manipulated variable rates, and output variables
  • Models that characterize measurement noise and unmeasured input and output disturbances

For stable, continuous-time internal plant models, the toolbox proposes controller sample time automatically. The toolbox supports time-varying constraints and weights, constraints on linear combinations of manipulated variables and output variables, terminal constraints and weights, and constraints in the form of linear off-diagonal weights. The toolbox also supports constraint softening.


Running Closed-Loop Simulations

You can use functions or the MPC Designer app to run closed-loop simulations of your model predictive controller against linear plant models. The app lets you set up multiple simulation scenarios. For each scenario, you can specify controller set points and disturbances by choosing from several common signal profiles. Examples are step, ramp, sine wave, and random signal.

To assess robustness under model mismatch, you can simulate a controller against a linear plant model that is different from the internal plant model used by the controller. You can also simulate multiple controller designs against the same plant model to see how different weight and constraint settings affect controller performance. With this toolbox, you also have the ability to disable constraints to evaluate characteristics of the closed-loop dynamics, such as stability and damping. Using Simulink blocks provided with Model Predictive Control Toolbox, you can run closed-loop simulations of your model predictive controller against a nonlinear Simulink model. You can configure the blocks to accept run-time constraint and weight signals that are generated by other Simulink blocks.

Simulink model for running closed-loop simulations of a model predictive controller and a nonlinear plant model, with controller constraints calculated by other Simulink blocks.


Advising on Constraints and Weights, and Customizing QP Solver and State Estimation

Model Predictive Control Toolbox provides tools to advise you how to specify controller constraints and weights. The toolbox also lets you use a custom QP solver and the models and gains used in state estimation.


Analyzing Constraints and Weights for Potential Run-Time Failures

The toolbox provides a diagnostic function for detecting potential stability and robustness issues with your model predictive controller, such as:

  • Model predictive controller or closed-loop system is unstable.
  • QP optimization problem is ill-defined with an invalid Hessian matrix.
  • Zero steady-state offset cannot be achieved.
  • Hard and soft constraint settings may lead to infeasible optimization problems at run time.

You can use this diagnostic tool to adjust controller weights and constraints during controller design to avoid run-time failures.

Results of diagnostic tests for potential model predictive controller run-time failures.


Using a Custom QP Solver

The QP solver supplied with the toolbox is optimized for performance and robustness. It achieves convergence even when the optimization problem is ill-conditioned. You can also use it to create a custom model predictive controller formulation.

The toolbox also provides you with the flexibility to use a custom QP solver of your choice for simulation and code generation.


Using Custom State Estimation

The toolbox provides built-in state estimators for estimating controller states from measured outputs. If you have state measurements or prefer to use values estimated with a custom algorithm, the toolbox provides you with an option to do so.


Adjusting Run-Time Controller Performance

Model Predictive Control Toolbox supports monitoring run-time controller performance and adjusting run-time weights and constraints.


Monitoring Run-Time Controller Performance

Model predictive controllers formulate and solve a QP optimization problem at each computation step. The toolbox lets you monitor optimization status at run time. You can access the optimization status signal to detect rare occasions when an optimization may fail to converge and then decide if a backup control strategy should be used.

The MPC Controller block also lets you access the optimal cost and control sequence at each computation step. You can use these signals to analyze controller performance and develop custom control strategies. For example, you can use optimal cost information for switching between two model predictive controllers whose outputs are restricted to discrete values.

Simulink model that uses the optimal cost signal to switch between two model predictive controllers whose outputs are restricted to discrete values. You can compare the reference signal (top right, red) and plant output (top right, blue) to evaluate controller performance. You can plot the manipulated variable—the controller output (bottom right, green)—to see when the control strategy switches between controllers.


Adjusting Weights and Constraints at Run Time

The toolbox lets you adjust the run-time weights and constraints of your model predictive controller to optimize its performance at run time without redesigning or reimplementing it. To perform run-time controller tuning in Simulink, you would configure the MPC Controller block to accept the appropriate weights. You can also perform run-time controller tuning in MATLAB.

Model Predictive Control Toolbox provides access to the following run-time tuning parameters:

  • Weights on plant outputs
  • Weights on manipulated variables
  • Weights on manipulated variable rates
  • Weight on overall constraint softening

To adjust constraints at run time, you would configure the MPC Controller block to accept the appropriate signals. The block provides you with the ability to change the following constraints at run time:

  • Minimum and maximum values for manipulated variables
  • Minimum and maximum values for output variables
  • Custom constraints on linear combinations of manipulated and output variables

Simulink model for run-time tuning of model predictive controller parameters. Model Predictive Control Toolbox enables run-time tuning by changing weights on plant outputs, weights on manipulated variables, manipulated variable rates, and the weight on overall constraint softening.


Controlling Plants with Changing Dynamics Using Adaptive or Gain-Scheduled Model Predictive Controllers

Model Predictive Control Toolbox provides two options for controlling plants with changing dynamics. You can design an adaptive model predictive controller or implement a gain-scheduled model predictive controller.


Designing Adaptive Model Predictive Controllers

With Model Predictive Control Toolbox, you are able to design, simulate, and deploy adaptive MPC controllers for your plant. You can use an adaptive MPC controller to control a nonlinear plant across a wide operating range through run-time changes to an internal linear plant model. The toolbox provides a function and a Simulink block for simulating and implementing adaptive MPC controllers in MATLAB and Simulink, respectively. The toolbox also provides a built-in linear time-varying (LTV) Kalman filter with asymptotic stability guarantee for state estimation in adaptive model predictive controllers.

You can continuously estimate a linear plant model at run time with the online parameter estimation capabilities of System Identification Toolbox. You can then use the estimated model for run-time updates to an internal plant model in an adaptive MPC controller. This approach lets you design controllers that can adapt to changes in plant dynamics as these changes happen.

If you can predict how the plant and nominal conditions vary in the future, you can specify an internal plant model that changes over the prediction horizon. Such an LTV model is useful when controlling periodic systems or nonlinear systems that are linearized around a time-varying nominal trajectory.

Adaptive MPC Controller block (red) for controlling nonlinear models over a wide operating range through run-time changes to an internal plant model. Use System Identification Toolbox blocks to estimate a linear plant model at run time.


Implementing Gain-Scheduled Model Predictive Controllers

You can use the Multiple MPC Controllers block for controlling a nonlinear Simulink plant model over a wide range of operating conditions. With this block you can design a model predictive controller for each operating point and switch between model predictive controllers at run time. The Multiple MPC Controllers block ensures bumpless control transfer from one model predictive controller to another. You can create linear plant models for controller design at each operating point either by linearizing a Simulink model with Simulink Control Design or by specifying the plant model directly. The toolbox also provides a function for switching multiple model predictive controllers in MATLAB.

To reduce online computational effort, you can also implement gain-scheduled explicit MPC in Simulink using the Multiple Explicit MPC Controllers block.

Multiple MPC Controllers block (red) for controlling nonlinear models over a wide operating range using multiple model predictive controllers with bumpless control transfer. With this block you can design a model predictive controller for each operating point and switch between model predictive controllers at run time.

Generating Explicit Model Predictive Controllers

Model Predictive Control Toolbox enables you to design, simulate, and deploy explicit MPC controllers for your plant. By using optimal solutions precomputed offline, explicit MPC controllers require fewer computations than traditional (implicit) model predictive controllers and are, therefore, useful for applications with fast sample times. You are able to generate an explicit MPC controller from a traditional model predictive controller, as well as simplify a generated explicit MPC controller for a reduced memory footprint. The toolbox also provides a function and a Simulink block for simulating and implementing a generated explicit model predictive controller in MATLAB and Simulink, respectively.

MATLAB code (top left) for creating an explicit MPC controller. The created controller can be used with an Explicit MPC Controller block (top right, red).


Implementing Fast Model Predictive Controllers

Model Predictive Control Toolbox enables you to design, simulate, and deploy model predictive controllers with guaranteed worst-case execution time. You can use this capability to deploy model predictive controllers in applications with limited computational throughput budget.

To accomplish this, the toolbox provides an option to limit the number of iterations for solving a QP optimization problem and two choices for specifying what the algorithm will do once that maximum number of iterations is reached:

  • Use an approximate (suboptimal) solution from the last iteration of the QP solver, provided this approximate solution meets specified constraints.
  • Use manipulated variable values from the previous computation time.

The approximate solution often will provide acceptable performance, but there is no guarantee this will always be the case. Therefore, it is recommended that you simulate your controller performance with both options and choose the one with the best simulation results.

For some applications, the convergence of QP optimization can be accelerated by using a custom QP solver. The toolbox enables you to use such custom QP solvers instead of the built-in KWIK solver for both simulation and code generation.

MATLAB code (top) for creating an MPC controller that uses an approximate solution to a QP optimization problem. The approximate solution provides no significant deterioration in performance (lower left), while only using 3 or fewer iterations (lower right).


Simulating Economic Model Predictive Controllers

Model Predictive Control Toolbox supports economic MPC; that is, the ability to optimize the controller for an arbitrary cost function under arbitrary nonlinear constraints, as can be the case with electricity prices fluctuating throughout the day. This requires Optimization Toolbox™.

Model Predictive Control Toolbox lets you provide your custom nonlinear cost function and custom nonlinear constraints. When you simulate economic MPC using the specified arbitrary cost function and arbitrary constraints, the MPC controller:

  • Still uses a linear prediction model.
  • Uses the arbitrary cost function you provided instead of the built-in quadratic cost function.
  • Applies the nonlinear constraints you provide in addition to any linear constraints.
  • Computes optimal control moves by solving a nonlinear optimization problem using the SQP algorithm in the fmincon function from Optimization Toolbox.

Model Predictive Control Toolbox does not support deployment of economic MPC.


Deploying Model Predictive Controllers

Model Predictive Control Toolbox provides several ways to deploy a controller in an application. You can:

  • Design an MPC controller in Simulink with blocks provided with the toolbox and use Simulink Coder or Simulink PLC Coder to generate C code or IEC 61131-3 Structured Text, respectively, and deploy the code to a supported target system for implementation or rapid prototyping. The toolbox provides a diagnostic function for estimating data memory size used by the deployed controller at run time.
  • Design an MPC controller in MATLAB and use MATLAB Coder™ to generate C code and deploy it for real-time control.

Another way to deploy a controller in an application is to use OPC Toolbox™ to connect a controller operating in MATLAB directly to an OPC-compliant system.

Improve process performance by designing and implementing a model predictive controller. Use OPC Toolbox and System Identification Toolbox to collect the input-output data and create a plant model.

Hardware setup for rapid prototyping of a model predictive controller on PC-compatible hardware using Simulink Coder and Simulink Real-Time™.