As in traditional linear MPC, nonlinear MPC calculates control actions at each control interval using a combination of model-based prediction and constrained optimization. The key differences are:
The prediction model can be nonlinear and include time-varying parameters.
The equality and inequality constraints can be nonlinear.
The scalar cost function to be minimized can be a nonquadratic (linear or nonlinear) function of the decision variables.
Using nonlinear MPC, you can:
Simulate closed-loop control of nonlinear plants under nonlinear costs and constraints.
Plan optimal trajectories by solving an open-loop constrained nonlinear optimization problem.
By default, nonlinear MPC controllers solve a nonlinear programming problem using the
fmincon function with the SQP algorithm, which requires Optimization Toolbox™ software. If you do not have Optimization Toolbox software, you can specify your own custom nonlinear solver. For more information
on configuring the
fmincon solver and specifying a custom solver, see
Configure Optimization Solver for Nonlinear MPC. For more information about
using the FORCESPRO NLP solver with nonlinear MPC controllers, see Implement MPC Controllers Using Embotech FORCESPRO Solvers.
The MPC Designer app does not support the design of nonlinear MPC controllers.
Generic Nonlinear MPC
To implement generic nonlinear MPC, create an
nlmpc object, and
State and output functions that define your prediction model. For more information, see Specify Prediction Model for Nonlinear MPC.
A custom cost function that can replace or augment the standard MPC cost function. For more information, see Specify Cost Function for Nonlinear MPC.
Standard bounds on inputs, outputs, and states.
Additional custom equality and inequality constraints, which can include linear and nonlinear combinations of inputs, outputs, and states. For more information, see Specify Constraints for Generic Nonlinear MPC.
Passivity inequality constraints, which can include linear and nonlinear combinations of inputs and states. For more information, see Specify Constraints for Generic Nonlinear MPC and the
Passivityproperty of the
nlmpcobject. For examples about passivity, see Control Quadruple-Tank Using Passivity-Based Nonlinear MPC and Control Robot Manipulator Using Passivity-Based Nonlinear MPC.
You can simulate generic nonlinear MPC controllers:
In Simulink® using the Nonlinear MPC Controller block
At the command line using
Multistage Nonlinear MPC
A multistage MPC problem is an MPC problem in which cost and constraint functions are stage-based. Specifically, a multistage MPC controller with a prediction horizon of length p has p+1 stages, where the first stage corresponds to the current time and the last (terminal) stage corresponds to the last prediction step.
For a multistage MPC controller, each stage has its own decision variables and parameters, as well as its own nonlinear cost and constraints. More importantly, cost and constraint functions at a specific stage are functions only of the decision variables and parameters at that stage. Other than make it easier to write Jacobian functions, this feature allows for a much more efficient data structure, which in turn significantly reduces computation times compared to the same problem solved using a generic NLMPC controller. The fact that slack variables are stage-based allows for more design flexibility, and disabling the use of manipulated variable rates as decision variables yields an even leaner problem formulation.
For these reason, if your nonlinear MPC problem has cost and constraint functions that do not involve cross-stage terms, and if you do not need to enforce passivity, use multistage nonlinear MPC controller in your design.
To implement a multistage nonlinear MPC controller, first create an
object, and then specify:
State functions that define your prediction model. For discrete-time models, make sure
Model.IsContinuousTimeis set to
Cost and constraint functions at the desired stages. You must specify the cost function for at least one stage.
Hard upper and lower bounds on states, manipulated variables, and manipulated variable rates, if needed.
When designing your controller, consider the following points.
Anonymous functions are not supported for
Specifying Jacobians when they are available is the best practice, otherwise the solver must compute them numerically at each step. You can use
generateJacobianFunctionto automatically generate a MATLAB® function that calculates the Jacobians.
Unlike in generic nonlinear MPC, plant outputs, weights, ECR values, and scale factors are not present in an
nlmpcMultistageobject. You can implement them directly in your cost and constraint functions.
The control horizon is also omitted in
nlmpcMultistageobjects. To implement block moves, set
RateMaxto zero at desired prediction steps.
You can simulate multistage nonlinear MPC controllers:
In Simulink using the Multistage Nonlinear MPC Controller block
At the MATLAB command line using
Code generation from a nonlinear multistage controller is supported in both MATLAB (using
mpcmoveCodeGeneration) and Simulink.
For examples on how to create and use a multistage MPC controller, see Create and Simulate Multistage Nonlinear MPC Controller, Simulate Multistage Nonlinear MPC Controller Using Initial Guesses, and Truck and Trailer Automatic Parking Using Multistage Nonlinear MPC.
- Trajectory Optimization and Control of Flying Robot Using Nonlinear MPC
- Control of Quadrotor Using Nonlinear Model Predictive Control
- Nonlinear Model Predictive Control of an Exothermic Chemical Reactor
- Swing-Up Control of a Pendulum Using Nonlinear Model Predictive Control
- Control Quadruple-Tank Using Passivity-Based Nonlinear MPC
- Plan and Execute Task- and Joint-Space Trajectories Using KINOVA Gen3 Manipulator (Robotics System Toolbox)
- Landing a Vehicle Using Multistage Nonlinear MPC
- Truck and Trailer Automatic Parking Using Multistage Nonlinear MPC