Model Predictive Control Toolbox

Design and simulate model predictive controllers

Model Predictive Control Toolbox™ provides functions, an app, and Simulink® blocks for designing and simulating controllers using linear and nonlinear model predictive control (MPC). The toolbox lets you specify plant and disturbance models, horizons, constraints, and weights. By running closed-loop simulations, you can evaluate controller performance.

You can adjust the behavior of the controller by varying its weights and constraints at run time. The toolbox provides deployable optimization solvers and also enables you to use a custom solver. To control a nonlinear plant, you can implement adaptive, gain-scheduled, and nonlinear MPC controllers. For applications with fast sample rates, the toolbox lets you generate an explicit model predictive controller from a regular controller or implement an approximate solution.

For rapid prototyping and embedded system implementation, including deployment of optimization solvers, the toolbox supports C code and IEC 61131-3 Structured Text generation.

Get Started:

Designing Model Predictive Controllers

Design MPC controllers to control MIMO systems subject to input and output constraints. Run closed-loop simulations to evaluate controller performance.

MPC Designer App

Interactively design MPC controllers by defining an internal plant model and adjusting horizons, weights, and constraints. Validate controller performance using simulation scenarios. Compare responses for multiple MPC controllers.

MPC Design in Simulink

Model and simulate MPC controllers in Simulink using the MPC Controller block and other blocks provided by the toolbox. Trim and linearize a Simulink model to compute an internal linear time-invariant plant model for your MPC controller and obtain nominal values for plant inputs and outputs using Simulink Control Design™.

MPC Design in MATLAB

Use command-line functions to design MPC controllers. Define an internal plant model; adjust weights, constraints, and other controller parameters. Simulate closed-loop system response to evaluate controller performance.

Designing MPC controllers at the command line.

Automated Driving Applications

Accelerate development of your ADAS systems using prebuilt Simulink blocks. Use the reference examples to quickly design ADAS controllers. Generate code from the Simulink blocks for deploying MPC controllers in the vehicle.

Prebuilt Blocks

Use the Adaptive Cruise Control System, Lane Keeping Assist System, and Path Following Control System blocks as a starting point for your ADAS application and customize the design as needed. Generate code from the prebuilt blocks for in-vehicle deployment.

Using the prebuilt Simulink block for designing adaptive cruise control systems.

Reference Application Examples

Use reference application examples to walk through a workflow for designing and deploying MPC controllers for automated driving systems. Reference application examples also show you how different parts of your system can be modeled at various levels of fidelity.

Linear Model Predictive Controllers

Design MPC controllers for systems with linear dynamics. Design adaptive and gain-scheduled MPC controllers for plants with dynamics that change with operating conditions.

Linear MPC

Design a linear MPC controller by specifying an internal plant model as a linear time-invariant (LTI) system created with Control System Toolbox™, or by linearizing a Simulink model with Simulink Control Design. Alternatively, import a model created from measured input-output data using System Identification Toolbox™.

Specifying an internal plant model for a linear MPC design.

Adaptive MPC

Design and simulate adaptive MPC controllers by using command line functions and the Adaptive MPC Controller block. Update your plant model at run time and provide it as an input to the controller. Use a built-in linear time-varying (LTV) Kalman filter with guaranteed asymptotic stability for state estimation in adaptive model predictive controllers.

Gain-Scheduled MPC

Control nonlinear plants over a wide range of operating conditions with the Multiple MPC Controllers block. Design an MPC controller for each operating point and switch between the controllers at run time.

Using the Multiple MPC Controllers block for designing gain-scheduled MPC controllers.

MPC Parameter Specification, State Estimation, and Design Review

Iteratively improve your controller design by defining an internal plant model, adjusting controller parameters, and simulating closed-loop system response to evaluate controller performance. Review your controller for potential design issues.

Controller Parameters

After defining the internal plant model, complete the design of your MPC controller by specifying the sample time, prediction and control horizons, scale factors, input and output constraints, and weights. The toolbox also supports constraint softening and time-varying constraints and weights.

Specifying controller parameters in the MPC Designer app.

State Estimation

Estimate controller states from measured outputs using the built-in state estimator. Alternatively, use a custom algorithm for state estimation.

Custom state estimation.

Design Review

Detect potential stability and robustness issues with your MPC controller using the built-in diagnostic function. Use the diagnostic results to adjust controller weights and constraints during controller design to avoid run-time failures.

Improving controller design using recommendations from the design review report.

Run-Time Parameter Tuning and Performance Monitoring

Improve controller performance by tuning weights and constraints at run time. Analyze the run-time performance of your controllers.

Run-Time Parameter Tuning

Adjust the weights and constraints of your MPC controller to optimize its performance at run time without redesigning or reimplementing it. Perform run-time controller tuning in both MATLAB® and Simulink.

Adjusting weights and constraints at run time.

Run-Time Performance Monitoring

Access the optimization status signal to detect rare occasions when an optimization may fail to converge. Use this information to guide decisions on backup control strategies.

Detecting controller failures in real time. 

Implementing Fast Model Predictive Controllers

Design, simulate, and deploy MPC controllers in applications with limited computational resources

Explicit MPC

Generate an explicit MPC controller from an implicit MPC design for faster execution. Simplify a generated explicit MPC controller for a reduced memory footprint.

Generating an explicit MPC controller from a previously designed implicit controller.

Approximate (Suboptimal) Solution

Design, simulate, and deploy an MPC controller with guaranteed worst-case execution time using an approximate (suboptimal) solution.

Comparison of execution times of optimal and approximate (suboptimal) solutions.

Nonlinear Model Predictive Controllers

Design nonlinear MPC controllers to control plants using nonlinear prediction models, cost functions, or constraints.

Optimal Planning

Use nonlinear MPC controllers for optimal planning applications that require a nonlinear model with nonlinear costs or constraints.

Trajectory optimization and control of flying robot using nonlinear MPC.

Feedback Control

Simulate closed-loop control of nonlinear plants under nonlinear costs and constraints. By default, nonlinear MPC controllers use Optimization Toolbox™ to solve the nonlinear programming problem. You can also specify your own custom nonlinear solver.

Nonlinear model predictive control of an exothermic chemical reactor.

Economic MPC

Design economic MPC controllers to optimize the controller for an arbitrary cost function under arbitrary nonlinear constraints. You can use a linear or nonlinear prediction model, a custom nonlinear cost function, and custom nonlinear constraints.

Economic MPC control of ethylene oxide production.

Code Generation

Generate code for model predictive controllers designed in Simulink and MATLAB and deploy it for real-time control applications.

Code Generation with MATLAB and Simulink

Design an MPC controller in Simulink and generate C code or IEC 61131-3 Structured Text using Simulink Coder™ or Simulink PLC Coder™, respectively. Use MATLAB Coder™ to generate C code in MATLAB and deploy it for real-time control. Alternatively, use MATLAB Compiler™ to package and share your MPC controller as a standalone application.

Generating C code from the MPC Controller block.

Built-In Solvers

Generate code from provided active-set and interior-point quadratic programming (QP) solvers for efficient implementation on embedded processors. For nonlinear problems, use the sequential quadratic programming (SQP) solver from Optimization Toolbox for simulation and code generation. Deploy the generated code to any number of processors.

Built-in solvers.

Custom Solvers

Use Embotech FORCES PRO QP and nonlinear programming (NLP) solvers to simulate and generate code for linear and nonlinear MPC controllers. Alternatively, use custom QP and NLP solvers for simulation and code generation.

Custom QP solver for simulation and code generation.