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 model predictive controllers (MPCs). 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. To control a nonlinear plant, you can implement adaptive and gain-scheduled MPCs. For applications with fast sample rates, you can generate an explicit model predictive controller from a regular controller or implement an approximate solution.
For rapid prototyping and embedded system implementation, the toolbox supports C code and IEC 61131-3 Structured Text generation.
MPC Design in MATLAB
Use command-line functions to design MPC controllers. Define an internal plant model, adjust weights, constraints, and other controller parameters, and simulate closed-loop system response to evaluate controller performance.
MPC Design in Simulink
Model and simulate MPC controllers in Simulink using 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 compute nominal values for plant inputs and outputs using Simulink Control Design™.
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.
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 deploying MPC controllers.
Leverage reference applications that walk you through a workflow for designing and deploying MPC controllers for your automated driving systems. Reference applications also show you how different parts of your system can be modeled at various levels of fidelity.
Design a linear MPC controller by specifying an internal plant model as a linear time-invariant (LTI) system from 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™.
Design and simulate adaptive MPC controllers by using command line functions and the Adaptive MPC Controller block. Update your plant model at each compute step and provide it as an input to the controller. Use a built-in linear time-varying (LTV) Kalman filter with asymptotic stability guarantee for state estimation in adaptive model predictive controllers.
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.
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.
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.
Estimate controller states from measured outputs using the built-in state estimator. Alternatively, use the custom state estimation option when you need to provide values estimated with your custom algorithm to the controller.
Detect potential stability and robustness issues with your MPC controller using the diagnostic function provided by the toolbox. Use this diagnostic tool to adjust controller weights and constraints during controller design to avoid run-time failures.
Run-Time Parameter Tuning
Adjust the run-time 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.
Run-Time Performance Monitoring
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.
Generate an explicit MPC controller from an implicit MPC design. Simplify a generated explicit MPC controller for a reduced memory footprint.
Approximate (Suboptimal) Solution
Design, simulate, and deploy MPC controllers with guaranteed worst-case execution time using an approximate (suboptimal) solution.
Use nonlinear MPC controllers for optimal planning applications that require a nonlinear model with nonlinear costs or constraints.
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.
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.
Code Generation with MATLAB and Simulink
Design an MPC controller in Simulink and generate C code and 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 CompilerTM to deploy MPC controllers.
Generate code from provided active-set and interior-point quadratic programming (QP) solvers for efficient implementation on embedded processors. For nonlinear problems, use built-in sequential quadratic programming (SQP) solver from Optimization Toolbox for simulation and code generation. Deploy the generated code to an arbitrary number of processors.
Custom QP Solver
Use a custom quadratic programming (QP) solver of your choice for simulation and code generation.
Generate code for nonlinear MPC controllers that use default fmincon solver with the SQP algorithm
Interior-Point QP Solver
Design and implement efficient MPC controllers for applications that enforce constraints over large prediction and control horizons