ModelPredictiveController
ModelPredictiveController[sspec,cost,cons]
computes the model predictive controller for the system specification sspec that minimizes the cost function cost and satisfies the constraints cons.
ModelPredictiveController[…,"prop"]
returns the value of the property "prop".
Details and Options
 Model predictive control is also known as MPC.
 A model predictive controller is computed by minimizing a cost function of state and control input over a finite horizon while allowing for constraints on both inputs and states. These constraints are often important to guarantee that the controller can be implemented safely.
 The resulting controller has a simple piecewise affine form , where is the feedback control input and is the state of the system. These can easily be deployed in microcontrollers and used for fast processes.
 A regulator aims to maintain the system at an equilibrium position despite disturbances pushing it away. Typical examples include maintaining an inverted pendulum in its upright position or maintaining an aircraft in level flight.
 The MPC regulator is specified as the feedback that minimizes the cost subject to the system dynamics in sspec and constraints cons. The cost becomes small when both state and feedback control input become small.

1norm, weighted integral absolute error (IAE) squared 2norm, weighted integral squared error (ISE) or weighted "energy" norm, weighted peak value  The cost is specified in the cost Association with the following keys:

η "Horizon" integer time horizon q "StateWeight" matrix cost on states r "InputWeight" matrix cost on inputs p "StateInputWeight" matrix cost on crosscoupled states and inputs m "Norm" 1, 2 or  A tracker aims to track reference signals despite disturbances . Typical examples include a cruise control system for a car or path tracking for a robot.
 The MPC tracker is specified as the feedback that minimizes a cost subject to the system dynamics in sspec and constraints cons. The cost becomes small when both predicted error and the incremental feedback control input become small.

1norm, weighted integral absolute error (IAE) squared 2norm, weighted integral squared error (ISE) or weighted "energy" norm, weighted peak value  The terms in the cost function expressions are the following:

η "Horizon" integer time horizon q_{e} "ErrorWeight" matrix cost on errors "InputIncrementWeight" matrix cost on input increments p_{eΔ} "ErrorInputIncrementWeight" matrix cost on cross coupled errors and input increments m "Norm" 1, 2 or  The constraints cons for both the regulator and tracker problems are formulated in terms of the state variables x, input variables u and output variables y. These can be defined using StateSpaceModel[{a,b,c,d},x,u,y,…].
 Constraints that hold for a particular time instant where :

xmin<=x_{i}[k]<=xmax constraint on the value at time Δxmin<=x_{i}[k_{2}]x_{i}[k_{1}]<=Δxmax constraint on the increment from time to time  Constraints that hold for all time instants k where :

xmin<=x_{i}<=xmax constraint on the value for all k min<=α_{1}.x_{1}+…+α_{n}.x_{n}+β<=max constraint on a linear combination for all k xminxxmax constraint on all the values for all k  The weight matrices , and can be specified as follows:

q constant weights {q,…,q,q} {{q},q_{η}} varying end weight {q,…,q,q_{η}} {q_{0},q_{1},…,q_{η}} varying weights {q_{0},q_{1},…,q_{η}}  ModelPredictiveController works for discretetime linear systems that can be specified using StateSpaceModel[…,SamplingPeriodτ].
 The system specification sspec can have the following forms:

StateSpaceModel[…] linear control input and linear state AffineStateSpaceModel[…] linear control input and nonlinear state NonlinearStateSpaceModel[…] nonlinear control input and nonlinear state SystemModel[…] general system model <… > detailed system specification given as an Association  The detailed system specification can have the following keys:

"InputModel" sys any one of the models "FeedbackInputs" All the feedback inputs u_{f} "TrackedOutputs" None the tracked outputs y_{ref}  The feedback inputs can have the following forms:

{num_{1},…,num_{n}} numbered inputs num_{i} used by StateSpaceModel, AffineStateSpaceModel and NonlinearStateSpaceModel {name_{1},…,name_{n}} named inputs name_{i} used by SystemModel All uses all inputs  ModelPredictiveController returns a SystemsModelControllerData object cd that can be used to extract additional properties using the form cd["prop"].
 ModelPredictiveController[…,"prop"] can be used to directly get the value of cd["prop"].
 Closedloop system properties:

"ClosedLoopPoles" poles of the linearized "ClosedLoopSystem" "ClosedLoopSystem" system csys {"ClosedLoopSystem", cspec} detailed control over the form of the closedloop system "ControllerModel" model cm "FeedbackGains" gain matrix κ or its equivalent "FeedbackGainsModel" model gm "FeedbackRegions" regions from which the feedback is feasible "QuasiClosedLoopSystem" closedloop assembled with "QuasiFeedbackGains" "QuasiFeedbackGains" feedback gains that depend only on initial values "QuasiFeedbackGainsModel" systems model of "QuasiFeedbackGains" "OptimalCost" optimal value of  Infinite horizon problem properties:

"MaximalLQRInvariantRegion" maximal region with LQR feedback gains "MaximalStabilizableRegion" maximal region that can be steered into "MinimalFiniteHorizon" minimal horizon at which states in enter  Basic design properties:

"Design" type of controller design "DesignModel" model used for the design "DesignModelSamplingMethod" sampling method used to obtain "DesignModel" "DesignModelSamplingPeriod" sampling period of "DesignModel" "Horizon" horizon η "Norm" 1, squared 2, or ∞norm  Input model properties:

"FeedbackInputs" inputs u_{f} of sys used for feedback "InputModel" input model sys "InputsCount" number of inputs u of sys "OpenLoopPoles" poles of "DesignModel" "OutputsCount" number of outputs y of sys "SamplingPeriod" sampling period of sys "StatesCount" number of states x of sys "TrackedOutputs" outputs y_{t} of sys that are tracked
Examples
open allclose allBasic Examples (2)
Solve the infinite horizon regulator problem for a system with states {x_{1},x_{2}} and control input u:
And the state and input constraints:
Compute the resulting MPC controller:
The regions with feasible feedback:
The simulation of the closedloop system from different initial points in the feasible region:
Solve the finite horizon regulator problem for a system with states {x_{1},x_{2}} and control input u:
And the state and input constraints:
Compute the resulting MPC controller:
The response of the closedloop system to an input sequence:
The response of the quasi closedloop system to an input sequence:
Scope (43)
Basic Uses (5)
Solve the regulator problem for a discretetime system with states {x_{1},x_{2}} and control input u:
Constrain the states and the control input :
The response of the closedloop system:
The closedloop system from above:
It consists of the input model, feedback gains and comparator:
Simulate the closedloop system from a nonzero initial condition:
Start from a different initial condition:
A multipleinput system with inputs {u_{1},u_{2}}:
The controller is a DiscreteInputOutputModel:
It is essentially a series of piecewise functions:
And has the two states as inputs:
A system with sampling period of 0.1:
Plot the response at the sampling instants:
Plot it as a function of time:
The controller data object from above:
Compute the controller effort by first obtaining the controller model and closedloop system:
Norm (4)
Compute a controller that minimizes a 1normed cost:
The controller is a DiscreteInputOutputModel:
It is a series of piecewise functions:
Compute a controller that minimizes a normed cost:
The controller is a DiscreteInputOutputModel:
It is a series of piecewise functions:
Compute a controller that minimizes a squared 2normed cost:
The controller is a DiscreteInputOutputModel:
It is a series of piecewise functions:
Compute a controller that minimizes a squared 2normed cost for an infinite horizon:
The controller is a NonlinearStateSpaceModel:
And is a piecewise function of the states of the input model:
Tracking (4)
Solve the tracking problem for a discretetime system with states {x_{1},x_{2}} and control input u:
Compute the tracking controller:
The closedloop system from above:
Its response to a nonconstant steplike reference signal:
The response does not exceed the upper limit of 5:
The response to a sinusoidal reference:
Compare the responses with different norms:
The controllers for the different norms:
The responses of the 1 and norm are the same because it is a single input and single output system:
The error norms of the 2 and 1norm responses:
Compare the norms for a multipleoutput system:
The cost specifications for the different norms:
The difference between the responses of the 1 and norm costs:
Plant Models (8)
The controller for a system specified as a StateSpaceModel:
A system specified as an AffineStateSpaceModel:
It is computed based on a linear approximation:
The feedback gains are the same:
A nonlinear system with nonzero operating points:
It is computed based on a linear approximation:
The nonzero operating points cause the gains to be different:
A controller for a system specified as a NonlinearStateSpaceModel:
A system specified as a continuoustime SystemModel:
The complete system specification includes the sampling as well:
The constraints specified in terms of formal variables:
The constraints can also sometimes be specified using the variable labels:
The feedback gains are the same:
A system with feedback and exogenous inputs:
The complete system specification:
The cost includes only the feedback input cost:
The constraints include only constraints on the feedback input:
The feedback gains model has the two states {x_{1},x_{2}} as inputs and u_{1} as output:
A system with multiple outputs:
The complete system specification to track only the first output:
The cost includes only the error of the tracked output:
Only the first output is tracked:
A SystemModel with multiple inputs:
The feedback input specified using the variable names:
It is the first input of the linearized StateSpaceModel:
Constraints (5)
Properties (17)
The list of available properties can be computed from the controller data object:
A specific property can be computed directly:
A list of properties can also be computed:
It is a series of piecewise functions:
Which are affine in the states:
It can be used to compute the feedback gains model:
Obtain the feedback gains model directly:
It can be used to compute the controller model:
It is a sum of three piecewise functions:
They are the optimal costs at each instant:
Sort them from the smallest to the largest instant:
The optimal cost at each instant is piecewise quadratic:
The optimal cost for a 1norm problem:
The optimal cost at each instant is piecewise linear:
The optimal cost for an norm problem:
The optimal cost at each instant is piecewise linear:
The optimal cost for an horizon problem:
The regions of interest in an horizon problem:
The "MaximalLQRInvariantRegion" is contained within "MaximalStabilizableRegion":
"MaximalStabilizableRegion" is essentially the same as "FeedbackRegions":
"FeedbackRegions" is composed of multiple convex subregions:
"MaximalStabilizableRegion" is a single convex region:
The closedloop poles of an horizon problem is a piecewise function:
The closedloop poles of a finite horizon problem is a series of piecewise functions:
That depend only on the initial state of the system:
The quasi feedback gains model:
It is computed from the quasi feedback gains:
It is computed from the quasi feedback gains model:
Obtain all the properties as an Association:
Or a Dataset:
Applications (2)
Design a controller to automate the administration of anesthesia in a patient: »
A model of the pharmacokinetic (PK) characteristics:
A model of the pharmacodynamic (PD) characteristics:
A model of the relationship between the Bispectral Index (BIS) and using the Hill equation:
A plot showing the nonlinear characteristics of the Hill equation:
The compartmental model with as input and as output:
A discretetime approximation of the model:
Set up the cost to track the output:
Compute for fully awake and moderately but not deeply hypnotic BIS values:
Specify the constraint to prevent the patient from going into a deep hypnotic state:
Compute to achieve a BIS value of , which puts the patient in a moderate hypnotic state:
The plot of the automated process:
Design a controller to improve an isothermal continuous stirredtank reactor process: »
A model of the system with states and inputs :
Compute a discretetime approximation of the model:
The response of the openloop system:
The response of the closedloop system:
Properties & Relations (3)
LQRegulatorGains is a special case of the squared 2norm, infinite horizon problem:
ModelPredictiveController with no constraints gives essentially the same result:
LQRegulatorGains does not take constraints into consideration:
ModelPredictiveController takes state and control constraints into consideration:
Consequently, LQRegulatorGains has only one set of feedback gains:
While the feedback gains of ModelPredictiveController are a piecewise function:
It also computes the region where the feedback is feasible:
Compute the bounds of the feasible region:
Simulate the LQR closedloop system from , which is outside the feasible region:
The control constraint is violated:
The closedloop system's response with the MPC controller from an unfeasible initial value :
The responses of the LQR and MPC closedloop systems from a feasible initial value :
The controller response shows that the LQR controller again violates the control constraints:
An MPC controller is computed by solving multiple multiparametric optimization problems:
A function to compute the quadratic cost:
A function to assemble the constraints:
A function to assemble the variables:
Solve the optimization problems for the various instances:
ModelPredictiveController gives essentially the same result:
Text
Wolfram Research (2022), ModelPredictiveController, Wolfram Language function, https://reference.wolfram.com/language/ref/ModelPredictiveController.html.
CMS
Wolfram Language. 2022. "ModelPredictiveController." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ModelPredictiveController.html.
APA
Wolfram Language. (2022). ModelPredictiveController. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ModelPredictiveController.html