Model predictive controller

A model predictive controller uses linear plant, disturbance, and noise models to estimate the controller state and predict future plant outputs. Using the predicted plant outputs, the controller solves a quadratic programming optimization problem to determine control moves.

For more information on the structure of model predictive controllers, see MPC Modeling.

creates a model predictive controller object based on the discrete-time prediction model
`mpcobj`

= mpc(`plant`

)`plant`

. The controller, `mpcobj`

, inherits its
control interval from `plant.Ts`

, and its time unit from
`plant.TimeUnit`

. All other controller properties are default values.
After you create the MPC controller, you can set its properties using dot
notation.

If `plant.Ts = -1`

, you must set the `Ts`

property of the controller to a positive value before designing and simulating your
controller.

creates a model predictive controller based on the specified plant model and sets the
controller sample time to `mpcobj`

= mpc(`plant`

,`ts`

)`ts`

, which corresponds to the
`Ts`

property of the controller. If `plant`

is
a:

Continuous-time model, then the controller discretizes the model for prediction using sample time

`ts`

A discrete-time model with a specified sample time, the controller resamples the plant for prediction using sample time

`ts`

A discrete-time model with an unspecified sample time (

`plant.Ts`

=`–1`

), it inherits sample time`ts`

when used for predictions

specifies the following controller properties. If any of these values are omitted or
empty, the default values apply.`mpcobj`

= mpc(`plant`

,`ts`

,`P`

,`M`

,`W`

,`MV`

,`OV`

,`DV`

)

`P`

sets the`PredictionHorizon`

property.`M`

sets the`ControlHorizon`

property.`W`

sets the`Weights`

property.`MV`

sets the`ManipulatedVariables`

property.`OV`

sets the`OutputVariables`

property.`DV`

sets the`DisturbanceVariables`

property.

creates a model predictive controller object based on the specified prediction model
set, which includes the plant, input disturbance, and measurement noise models along
with the nominal conditions at which the models were obtained. When you do not specify a
sample time, the plant model, `mpcobj`

= mpc(`model`

)`model.Plant`

, must be a discrete-time
model. This syntax sets the `Model`

property of the
controller.

creates a model predictive controller based on the specified plant model and sets the
controller sample time to `mpcobj`

= mpc(`model`

,`ts`

)`ts`

. If `model.Plant`

is a discrete-time LTI model with an unspecified sample time
(`model.Plant.Ts`

= `–1`

), it inherits sample time
`ts`

when used for predictions.

specifies additional controller properties. If any of these values are omitted or empty,
the default values apply.`mpcobj`

= mpc(`model`

,`Ts`

,`P`

,`M`

,`W`

,`MV`

,`OV`

,`DV`

)

`plant`

— Plant prediction modelLTI model | identified linear model

Plant prediction model, specified as either an LTI model or a linear System
Identification Toolbox™ model. The specified plant corresponds to the
`Model.Plant`

property of the controller.

If you do not specify a sample time when creating your controller,
`plant`

must be a discrete-time model.

For more information on MPC prediction models, see MPC Modeling.

Direct feedthrough from manipulated variables to any output in
`plant`

is not supported.

`model`

— Prediction modelstructure

Prediction model, specified as a structure with the same format as the `Model`

property of the controller. If you do not specify a sample time when creating your
controller, `model.Plant`

must be a discrete-time model.

For more information on MPC prediction models, see MPC Modeling.

`Ts`

— Controller sample timepositive scalar

Controller sample time, specified as a positive finite scalar. The controller uses a
discrete-time model with sample time `Ts`

for prediction.

`PredictionHorizon`

— Prediction horizonpositive integer

Prediction horizon steps, specified as a positive integer. The product of
`PredictionHorizon`

and `Ts`

is the prediction
time; that is, how far the controller looks into the future.

`ControlHorizon`

— Control horizon`2`

(default) | positive integer | vector of positive integersControl horizon, specified as one of the following:

Positive integer,

*m*, between`1`

and*p*, inclusive, where*p*is equal to`PredictionHorizon`

. In this case, the controller computes*m*free control moves occurring at times*k*through*k*+*m*-1, and holds the controller output constant for the remaining prediction horizon steps from*k*+*m*through*k*+*p*-1. Here,*k*is the current control interval.Vector of positive integers [

*m*_{1},*m*_{2}, …], specifying the lengths of blocking intervals. By default the controller computes*M*blocks of free moves, where*M*is the number of blocking intervals. The first free move applies to times*k*through*k*+*m*_{1}-1, the second free move applies from time*k*+*m*_{1}through*k*+*m*_{1}+*m*_{2}-1, and so on. Using block moves can improve the robustness of your controller. The sum of the values in`ControlHorizon`

must match the prediction horizon*p*. If you specify a vector whose sum is:Less than the prediction horizon, then the controller adds a blocking interval. The length of this interval is such that the sum of the interval lengths is

*p*. For example, if*p*=`10`

and you specify a control horizon of`ControlHorizon`

=`[1 2 3]`

, then the controller uses four intervals with lengths`[1 2 3 4]`

.Greater than the prediction horizon, then the intervals are truncated until the sum of the interval lengths is equal to

*p*. For example, if*p*=`10`

and you specify a control horizon of`ControlHorizon`

=`[1 2 3 6 7]`

, then the controller uses four intervals with lengths`[1 2 3 4]`

.

For more information on manipulated variable blocking, see Manipulated Variable Blocking.

`Model`

— Prediction model and nominal conditionsstructure

Prediction model and nominal conditions, specified as a structure with the following fields. For more information on the MPC prediction model, see MPC Modeling and Controller State Estimation.

`Plant`

— Plant prediction modelLTI model | identified linear model

Plant prediction model, specified as either an LTI model or a linear System Identification Toolbox model.

Direct feedthrough from manipulated variables to any output in
`plant`

is not supported.

`Disturbance`

— Model describing expected unmeasured disturbancesLTI model

Model describing expected unmeasured disturbances, specified as an LTI model.
This model is required only when the plant has unmeasured disturbances. You can
set this disturbance model directly using dot notation or using the `setindist`

function.

By default, input disturbances are expected to be integrated white noise. To model the signal, an integrator with dimensionless unity gain is added for each unmeasured input disturbance, unless the addition causes the controller to lose state observability. In that case, the disturbance is expected to be white noise, and so, a dimensionless unity gain is added to that channel instead.

`Noise`

— Model describing expected output measurement noiseLTI model

Model describing expected output measurement noise, specified as an LTI model.

By default, measurement noise is expected to be white noise with unit variance. To model the signal, a dimensionless unity gain is added for each measured channel.

`Nominal`

— Nominal operating point at which plant model is linearizedstructure

Nominal operating point at which plant model is linearized, specified as a structure with the following fields.

Field | Description | Default |
---|---|---|

`X` | Plant state at operating point, specified as a column vector
with length equal to the number of states in
| zero vector |

`U` | Plant input at operating point, including manipulated variables
and measured and unmeasured disturbances, specified as a column vector
with length equal to the number of inputs in
| zero vector |

`Y` | Plant output at operating point, including measured and
unmeasured outputs, specified as a column vector with length equal to
the number of outputs in | zero vector |

`DX` | For continuous-time models, | zero vector |

`ManipulatedVariables`

— Manipulated variable information, bounds, and scale factorsstructure array

Manipulated Variable (MV) information, bounds, and scale factors, specified as a
structure array with *N _{mv}* elements, where

`MV`

instead
of `ManipulatedVariables`

.Rates refer to the difference
Δ*u*(*k*)=*u*(*k*)-*u*(*k*-1).
Constraints and weights based on derivatives *du/dt* of
continuous-time input signals must be properly reformulated for the discrete-time
difference Δ*u*(*k*), using the approximation
*du/dt* ≅
Δ*u*(*k*)/*T*_{s}.

Each structure element has the following fields.

`Min`

— MV lower bound`-Inf`

(default) | scalar | vectorMV lower bound, specified as a scalar or vector. By default, this lower bound is unconstrained.

To use the same bound across the prediction horizon, specify a scalar value.

To vary the bound over the prediction horizon from time *k*
to time *k*+*p*-1, specify a vector of up to
*p* values. Here, *k* is the current time and
*p* is the prediction horizon. If you specify fewer than
*p* values, the final bound is used for the remaining steps of
the prediction horizon.

`Max`

— MV upper bound`Inf`

(default) | scalar | vectorMV upper bound, specified as a scalar or vector. By default, this upper bound is unconstrained.

To use the same bound across the prediction horizon, specify a scalar value.

To vary the bound over the prediction horizon from time *k*
to time *k*+*p*-1, specify a vector of up to
*p* values. Here, *k* is the current time and
*p* is the prediction horizon. If you specify fewer than
*p* values, the final bound is used for the remaining steps of
the prediction horizon.

`MinECR`

— MV lower bound softness`0`

(default) | nonnegative scalar | vectorMV lower bound softness, where a larger equal concern for relaxation (ECR) value indicates a softer constraint, specified as a nonnegative scalar or vector. By default, MV lower bounds are hard constraints.

To use the same ECR value across the prediction horizon, specify a scalar value.

To vary the ECR value over the prediction horizon from time
*k* to time *k*+*p*-1,
specify a vector of up to *p* values. Here, *k*
is the current time and *p* is the prediction horizon. If you
specify fewer than *p* values, the final ECR value is used for
the remaining steps of the prediction horizon.

`MaxECR`

— MV upper bound`0`

(default) | nonnegative scalar | vectorMV upper bound softness, where a larger equal concern for relaxation (ECR) value indicates a softer constraint, specified as a nonnegative scalar or vector. By default, MV upper bounds are hard constraints.

To use the same ECR value across the prediction horizon, specify a scalar value.

To vary the ECR value over the prediction horizon from time
*k* to time *k*+*p*-1,
specify a vector of up to *p* values. Here, *k*
is the current time and *p* is the prediction horizon. If you
specify fewer than *p* values, the final ECR value is used for
the remaining steps of the prediction horizon.

`RateMin`

— MV rate of change lower bound`-Inf`

(default) | nonpositive scalar | vectorMV rate of change lower bound, specified as a nonpositive scalar or vector.
The MV rate of change is defined as *MV*(*k*) -
*MV*(*k*-1), where *k* is the
current time. By default, this lower bound is unconstrained.

To use the same bound across the prediction horizon, specify a scalar value.

To vary the bound over the prediction horizon from time *k*
to time *k*+*p*-1, specify a vector of up to
*p* values. Here, *k* is the current time and
*p* is the prediction horizon. If you specify fewer than
*p* values, the final bound is used for the remaining steps of
the prediction horizon.

`RateMax`

— MV rate of change upper bound`Inf`

(default) | nonnegative scalar | vectorMV rate of change upper bound, specified as a nonnegative scalar or vector.
The MV rate of change is defined as *MV*(*k*) -
*MV*(*k*-1), where *k* is the
current time. By default, this lower bound is unconstrained.

To use the same bound across the prediction horizon, specify a scalar value.

*k*
to time *k*+*p*-1, specify a vector of up to
*p* values. Here, *k* is the current time and
*p* is the prediction horizon. If you specify fewer than
*p* values, the final bound is used for the remaining steps of
the prediction horizon.

`RateMinECR`

— MV rate of change lower bound softness`0`

(default) | nonnegative finite scalar | vectorMV rate of change lower bound softness, where a larger equal concern for relaxation (ECR) value indicates a softer constraint, specified as a nonnegative finite scalar or vector. By default, MV rate of change lower bounds are hard constraints.

To use the same ECR value across the prediction horizon, specify a scalar value.

To vary the ECR values over the prediction horizon from time
*k* to time *k*+*p*-1,
specify a vector of up to *p* values. Here, *k*
is the current time and *p* is the prediction horizon. If you
specify fewer than *p* values, the final ECR values are used for
the remaining steps of the prediction horizon.

`RateMaxECR`

— MV rate of change upper bound softness`0`

(default) | nonnegative finite scalar | vectorMV rate of change upper bound softness, where a larger equal concern for relaxation (ECR) value indicates a softer constraint, specified as a nonnegative finite scalar or vector. By default, MV rate of change upper bounds are hard constraints.

To use the same ECR value across the prediction horizon, specify a scalar value.

To vary the ECR values over the prediction horizon from time
*k* to time *k*+*p*-1,
specify a vector of up to *p* values. Here, *k*
is the current time and *p* is the prediction horizon. If you
specify fewer than *p* values, the final ECR values are used for
the remaining steps of the prediction horizon.

`Name`

— MV namestring | character vector

MV name, specified as a string or character vector.

`Units`

— MV units`""`

(default) | string | character vectorMV units, specified as a string or character vector.

`ScaleFactor`

— MV scale factor`1`

(default) | positive finite scalarMV scale factor, specified as a positive finite scalar. In general, use the operating range of the manipulated variable. Specifying the proper scale factor can improve numerical conditioning for optimization. For more information, see Specify Scale Factors.

`OutputVariables`

— Output variable information, bounds, and scale factorsstructure array

Output variable (OV) information, bounds, and scale factors, specified as a
structure array with *N _{y}* elements, where

`OV`

instead of
`OutputVariables`

.Each structure element has the following fields.

`Min`

— OV lower bound`-Inf`

(default) | scalar | vectorOV lower bound, specified as a scalar or vector. By default, this lower bound is unconstrained.

To use the same bound across the prediction horizon, specify a scalar value.

To vary the bound over the prediction horizon from time *k*+1
to time *k*+*p*, specify a vector of up to
*p* values. Here, *k* is the current time and
*p* is the prediction horizon. If you specify fewer than
*p* values, the final bound is used for the remaining steps of
the prediction horizon.

`Max`

— OV upper bound`Inf`

(default) | scalar | vectorOV upper bound, specified as a scalar or vector. By default, this upper bound is unconstrained.

To use the same bound across the prediction horizon, specify a scalar value.

To vary the bound over the prediction horizon from time *k*+1
to time *k*+*p*, specify a vector of up to
*p* values. Here, *k* is the current time and
*p* is the prediction horizon. If you specify fewer than
*p* values, the final bound is used for the remaining steps of
the prediction horizon.

`MinECR`

— OV lower bound softness`1`

(default) | nonnegative finite scalar | vectorOV lower bound softness, where a larger equal concern for relaxation (ECR) value indicates a softer constraint, specified as a nonnegative finite scalar or vector. By default, OV upper bounds are soft constraints.

To avoid creating an infeasible optimization problem at run time, it is best practice to use soft OV bounds.

To use the same ECR value across the prediction horizon, specify a scalar value.

To vary the ECR value over the prediction horizon from time
*k*+1 to time *k*+*p*,
specify a vector of up to *p* values. Here, *k*
is the current time and *p* is the prediction horizon. If you
specify fewer than *p* values, the final ECR value is used for
the remaining steps of the prediction horizon.

`MaxECR`

— OV upper bound softness`1`

(default) | nonnegative finite scalar | vectorOV upper bound softness, where a larger equal concern for relaxation (ECR) value indicates a softer constraint, specified as a nonnegative finite scalar or vector. By default, OV lower bounds are soft constraints.

To avoid creating an infeasible optimization problem at run time, it is best practice to use soft OV bounds.

To use the same ECR value across the prediction horizon, specify a scalar value.

To vary the ECR value over the prediction horizon from time
*k*+1 to time *k*+*p*,
specify a vector of up to *p* values. Here, *k*
is the current time and *p* is the prediction horizon. If you
specify fewer than *p* values, the final ECR value is used for
the remaining steps of the prediction horizon.

`Name`

— OV namestring | character vector

OV name, specified as a string or character vector.

`Units`

— OV units`""`

(default) | string | character vectorOV units, specified as a string or character vector.

`ScaleFactor`

— OV scale factor`1`

(default) | positive finite scalarOV scale factor, specified as a positive finite scalar. In general, use the operating range of the output variable. Specifying the proper scale factor can improve numerical conditioning for optimization. For more information, see Specify Scale Factors.

`DisturbanceVariables`

— Input disturbance variable information and scale factorsstructure array

Disturbance variable (DV) information and scale factors, specified as a structure
array with *N _{d}* elements, where

`DisturbanceVariables`

is the following: the first
To access this property, you can use the alias `DV`

instead of
`DisturbanceVariables`

.

Each structure element has the following fields.

`Name`

— DV namestring | character vector

DV name, specified as a string or character vector.

`Units`

— OV units`""`

(default) | string | character vectorOV units, specified as a string or character vector.

`ScaleFactor`

— DV scale factor`1`

(default) | positive finite scalarDV scale factor, specified as a positive finite scalar. Specifying the proper scale factor can improve numerical conditioning for optimization. For more information, see Specify Scale Factors.

`Weights`

— Standard cost function tuning weightsstructure

Standard cost function tuning weights, specified as a structure. The controller applies these weights to the scaled variables. Therefore, the tuning weights are dimensionless values.

The format of `OutputWeights`

must match the format of the
`Weights.OutputVariables`

property of the controller object. For
example, you cannot specify constant weights across the prediction horizon in the
controller object, and then specify time-varying weights using
`mpcmoveopt`

.

`Weights`

has the following fields. The values of these fields
depend on whether you use the standard or alternative cost function. For more
information on these cost functions, see Optimization Problem.

`ManipulatedVariables`

— Manipulated variable tuning weightsrow vector | array

Manipulated variable tuning weights, which penalize deviations from MV
targets, specified as a row vector or array of nonnegative values. The default
weight for all manipulated variables is `0`

.

To use the same weights across the prediction horizon, specify a row vector of length
*N _{mv}*, where

To vary the tuning weights over the prediction horizon from time *k* to time *k*+*p*-1, specify an array with *N _{mv}* columns and up to

If you use the alternative cost function, specify
`Weights.ManipulatedVariables`

as a cell array that contains
the
*N _{mv}*-by-

`mpcobj.Weights.ManipulatedVariables = {Ru}`

.
`ManipulatedVariablesRate`

— Manipulated variable rate tuning weightsrow vector | array | cell array

Manipulated variable rate tuning weights, which penalize large changes in
control moves, specified as a row vector or array of nonnegative values. The
default weight for all manipulated variable rates is
`0.1`

.

To use the same weights across the prediction horizon, specify a row vector of length
*N _{mv}*, where

To vary the tuning weights over the prediction horizon from time *k* to time
*k*+*p*-1, specify
an array with *N _{mv}* columns
and up to

It is best practice to use nonzero manipulated variable rate weights.

To improve the numerical robustness of the optimization problem, the
software adds the quantity `10*sqrt(eps)`

to each zero-valued
weight.

It is best practice to use nonzero manipulated variable rate weights. If all
manipulated variable rate weights are strictly positive, the resulting QP
problem is strictly convex. If some weights are zero, the QP Hessian could be
positive semidefinite. To keep the QP problem strictly convex, when the
condition number of the Hessian matrix
*K*_{ΔU} is larger than
10^{12}, the quantity `10*sqrt(eps)`

is added to each diagonal term. See Cost Function.

If you use the alternative cost function, specify
`Weights.ManipulatedVariablesRate`

as a cell array that
contains the
*N _{mv}*-by-

`mpcobj.Weights.ManipulatedVariablesRate = {Rdu}`

.
`OutputVariables`

— Output variable tuning weightsvector | array

Output variable tuning weights, which penalize deviation from output
references, specified as a row vector or array of nonnegative values. The default
weight for all output variables is `1`

.

To use the same weights across the prediction horizon, specify a row vector of length
*N _{y}*, where

To vary the tuning weights over the prediction horizon from time *k*+1 to time *k*+*p*, specify an array with *N _{y}* columns and up to

If you use the alternative cost function, specify
`Weights.OutputVariables`

as a cell array that contains the
*N _{y}*-by-

```
mpcobj.Weights.OutputVariables
= {Q}
```

. `ECR`

— Slack variable tuning weight`1e5`

(default) | positive scalarSlack variable tuning weight, specified as a positive scalar. Increase or decrease the equal concern for relaxation (ECR) weight to make all soft constraints harder or softer, respectively.

`Optimizer`

— QP optimization parametersstructure

QP optimization parameters, specified as a structure with the following fields. For more information on the supported QP solvers, see QP Solvers.

`Algorithm`

— QP solver algorithm`'active-set'`

(default) | `'interior-point'`

QP solver algorithm, specified as one of the following:

`'active-set'`

— Solve the QP problem using the KWIK active-set algorithm.`'interior-point'`

— Solve the QP problem using a primal-dual interior-point algorithm with Mehrotra predictor-corrector.

`ActiveSetOptions`

— Active-set QP solver settingsstructure

Active-set QP solver settings, specified as a structure. These settings apply
only when `Algorithm`

is
`'active-set'`

.

If `CustomSolver`

or
`CustomSolverGodeGen`

is `true`

, the
controller does not require the custom solver to honor these settings.

You can specify the following active-set optimizer settings.

`MaxIterations`

— Maximum number of iterations`'default'`

(default) | positive integerMaximum number of iterations allowed when computing the QP solution, specified as one of the following:

`'default'`

— The MPC controller automatically computes the maximum number of QP solver iterations as $$4\left({n}_{c}+{n}_{v}\right)$$, where:*n*is the total number of constraints across the prediction horizon._{c}*n*is the total number of optimization variables across the control horizon._{v}

The default

`MaxIterations`

value has a lower bound of`120`

.Positive integer — The QP solver stops after the specified number of iterations. If the solver fails to converge in the final iteration, the controller:

Freezes the controller movement if

`UseSuboptimalSolution`

is`false`

.Applies the suboptimal solution reached after the final iteration if

`UseSuboptimalSolution`

is`true`

.

The default `MaxIterations`

value can be very large
for some controller configurations, such as those with large prediction
and control horizons. When simulating such controllers, if the QP solver
cannot find a feasible solution, the simulation can appear to stop
responding, since the solver continues searching for
`MaxIterations`

iterations.

`ConstraintTolerance`

— Tolerance used to verify that inequality constraints are satisfied`1e-6`

(default) | positive scalarTolerance used to verify that inequality constraints are satisfied by
the optimal solution, specified as a positive scalar. A larger
`ConstraintTolerance`

value allows for larger
constraint violations.

`UseWarmStart`

— Flag indicating whether to warm start each QP solver iteration`true`

(default) | `false`

Flag indicating whether to *warm start* each QP
solver iteration by passing in a list of active inequalities from the
previous iteration, specified as a logical value. Inequalities are active
when their equal portion is true.

`InteriorPointOptions`

— Interior-point QP solver settingsstructure

Interior-point QP solver settings, specified as a structure. These settings
apply only when `Algorithm`

is
`'interior-point'`

.

If `CustomSolver`

or
`CustomSolverGodeGen`

is `true`

, the
controller does not require the custom solver to honor these settings.

You can specify the following interior-point optimizer settings.

`MaxIterations`

— Maximum number of iterations`50`

(default) | positive integerMaximum number of iterations allowed when computing the QP solution, specified as a positive integer. The QP solver stops after the specified number of iterations. If the solver fails to converge in the final iteration, the controller:

Freezes the controller movement if

`UseSuboptimalSolution`

is`false`

.Applies the suboptimal solution reached after the final iteration if

`UseSuboptimalSolution`

is`true`

.

`ConstraintTolerance`

— Tolerance used to verify that equality and inequality constraints are satisfied`1e-6`

(default) | positive scalarTolerance used to verify that equality and inequality constraints are
satisfied by the optimal solution, specified as a positive scalar. A larger
`ConstraintTolerance`

value allows for larger
constraint violations.

`OptimalityTolerance`

— Termination tolerance for first-order optimality (KKT dual residual)`1e-6`

(default) | positive scalarTermination tolerance for first-order optimality (KKT dual residual), specified as a positive scalar.

`ComplementarityTolerance`

— Termination tolerance for first-order optimality (KKT average complementarity residual)`1e-8`

(default) | positive scalarTermination tolerance for first-order optimality (KKT average complementarity residual), specified as a positive scalar. Increasing this value improves robustness, while decreasing this value increases accuracy.

`StepTolerance`

— Termination tolerance for decision variables`1e-8`

(default) | positive scalarTermination tolerance for decision variables, specified as a positive scalar.

`MinOutputECR`

— Minimum value allowed for output constraint ECR values`0`

(default) | nonnegative scalarMinimum value allowed for output constraint equal concern for relaxation (ECR)
values, specified as a nonnegative scalar. A value of `0`

indicates that hard output constraints are allowed. If either of the
`OutputVariables.MinECR`

or
`OutputVariables.MaxECR`

properties of an MPC controller are
less than `MinOutputECR`

, a warning is displayed and the value
is raised to `MinOutputECR`

during computation.

`UseSuboptimalSolution`

— Flag indicating whether a suboptimal solution is acceptable`false`

(default) | `true`

Flag indicating whether a suboptimal solution is acceptable, specified as a
logical value. When the QP solver reaches the maximum number of iterations without
finding a solution (the exit flag is `0`

), the controller:

Freezes the MV values if

`UseSuboptimalSolution`

is`false`

Applies the suboptimal solution found by the solver after the final iteration if

`UseSuboptimalSolution`

is`true`

To specify the maximum number of iterations, depending on the value of
`Algorithm`

, use either
`ActiveSetOptions.MaxIterations`

or
`InteriorPointOptions.MaxIterations`

.

`CustomSolver`

— Flag indicating whether to use a custom QP solver for simulation`false`

(default) | `true`

Flag indicating whether to use a custom QP solver for simulation, specified as
a logical value. If `CustomSolver`

is `true`

,
the user must provide an `mpcCustomSolver`

function on the
MATLAB^{®} path.

This custom solver is not used for code generation. To generate code for a
controller with a custom solver, use
`CustomSolverCodeGen`

.

If `CustomSolver`

is `true`

, the
controller does not require the custom solver to honor the settings in either
`ActiveSetOptions`

or
`InteriorPointOptions`

.

For more information on using a custom QP solver see, Custom QP Solver.

`CustomSolverCodeGen`

— Flag indicating whether to use a custom QP solver for code generation`false`

(default) | `true`

Flag indicating whether to use a custom QP solver for code generation,
specified as a logical value. If `CustomSolverCodeGen`

is
`true`

, the user must provide an
`mpcCustomSolverCodeGen`

function on the MATLAB path.

This custom solver is not used for simulation. To simulate a controller with a
custom solver, use `CustomSolver`

.

If `CustomSolverCodeGen`

is `true`

, the
controller does not require the custom solver to honor the settings in either
`ActiveSetOptions`

or
`InteriorPointOptions`

.

For more information on using a custom QP solver see, Custom QP Solver.

`Notes`

— User notes`{}`

(default) | cell array of character vectorsUser notes associated with the MPC controller, specified as a cell array of character vectors.

`UserData`

— User data`[]`

(default) | any MATLAB dataUser data associated with the MPC controller, specified as any MATLAB data, such as a cell array or structure.

`History`

— Controller creation date and timevector

This property is read-only.

Controller creation date and time, specified as a vector with the following elements:

`History(1)`

— Year`History(2)`

— Month`History(3)`

— Day`History(4)`

— Hours`History(5)`

— Minutes`History(6)`

— Seconds

`review` | Examine MPC controller for design errors and stability problems at run time |

`mpcmove` | Compute optimal control action |

`sim` | Simulate closed-loop/open-loop response to arbitrary reference and disturbance signals for implicit or explicit MPC |

`mpcstate` | MPC controller state |

`getCodeGenerationData` | Create data structures for `mpcmoveCodeGeneration` |

`generateExplicitMPC` | Convert implicit MPC controller to explicit MPC controller |

Create a plant model with the transfer function $$(s+1)/({s}^{2}+2s)$$.

Plant = tf([1 1],[1 2 0]);

The plant is SISO, so its input must be a manipulated variable and its output must be measured. In general, it is good practice to designate all plant signal types using either the `setmpcsignals`

command, or the LTI `InputGroup`

and `OutputGroup`

properties.

Specify a sample time for the controller.

Ts = 0.1;

Define bounds on the manipulated variable, $$u$$, such that $$-1\le u\le 1$$.

MV = struct('Min',-1,'Max',1);

`MV`

contains only the upper and lower bounds on the manipulated variable. In general, you can specify additional MV properties. When you do not specify other properties, their default values apply.

Specify a 20-interval prediction horizon and a 3-interval control horizon.

p = 20; m = 3;

Create an MPC controller using the specified values. The fifth input argument is empty, so default tuning weights apply.

MPCobj = mpc(Plant,Ts,p,m,[],MV);

-->The "Weights.ManipulatedVariables" property of "mpc" object is empty. Assuming default 0.00000. -->The "Weights.ManipulatedVariablesRate" property of "mpc" object is empty. Assuming default 0.10000. -->The "Weights.OutputVariables" property of "mpc" object is empty. Assuming default 1.00000.

To minimize computational overhead, model predictive controller creation occurs in two
phases. The first happens at *creation* when you use the
`mpc`

function, or when you change a controller property. Creation
includes basic validity and consistency checks, such as signal dimensions and nonnegativity of
weights.

The second phase is *initialization*, which occurs when you use the
object for the first time in a simulation or analytical procedure. Initialization computes all
constant properties required for efficient numerical performance, such as matrices defining
the optimal control problem and state estimator gains. Additional, diagnostic checks occur
during initialization, such as verification that the controller states are observable.

By default, both phases display informative messages in the command window. You can turn
these messages on or off using the `mpcverbosity`

function.

You can also create model predictive controllers using the **MPC
Designer** app.

*Errors starting in R2018b*

Support for implementing economic MPC using a linear MPC controller has been removed. Implement economic MPC using a nonlinear MPC controller instead. For more information on nonlinear MPC controllers, see Nonlinear MPC.

If you previously saved a linear MPC object configured with custom cost or constraint
functions, the software generates a warning when the object is loaded and an error if it
is simulated. To suppress the error and warning messages and continue using your linear
MPC controller, `mpcobj`

, without the custom costs and constraints, set
the `IsEconomicMPC`

flag to `false`

.

mpcobj.IsEconomicMPC = false;

To implement your economic MPC controller using a nonlinear MPC object:

Create an

`nlmpc`

object.Convert your custom cost function to the format required for nonlinear MPC. For more information on nonlinear MPC cost functions, see Specify Cost Function for Nonlinear MPC.

Convert your custom constraint function to the format required for nonlinear MPC. For more information on nonlinear MPC constraints, see Specify Constraints for Nonlinear MPC.

Implement your linear prediction model using state and output functions. For more information on nonlinear MPC prediction models, see Specify Prediction Model for Nonlinear MPC.

`get`

| `mpcprops`

| `mpcverbosity`

| `set`

| `setmpcsignals`

MATLAB のコマンドを実行するリンクがクリックされました。

このリンクは、Web ブラウザーでは動作しません。MATLAB コマンド ウィンドウに以下を入力すると、このコマンドを実行できます。

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)