Documentation

getconstraint

Set custom constraints on linear combinations of plant inputs and outputs

Syntax

  • [E,F,G,V,S] = getconstraint(MPCobj)
    example

Description

example

[E,F,G,V,S] = getconstraint(MPCobj) returns the custom constraints previously defined for the MPC controller, MPCobj. The constraints are in the general form:

Eu(k + j|k) + Fy(k + j|k) + Sv(k + j|k) ≤ G + εV

where j = 0,...,p, and:

  • p is the prediction horizon.

  • k is the current time index.

  • u is a column vector manipulated variables.

  • y is a column vector of all plant output variables.

  • v is a column vector of measured disturbance variables.

  • ε is a scalar slack variable used for constraint softening (as in Standard Cost Function).

  • E, F, G, V, and S are constant matrices.

Since the MPC controller does not optimize u(k+p|k), getconstraint calculates the last constraint at time k+p assuming that u(k+p|k) = u(k+p-1|k).

Examples

collapse all

Retrieve Custom Constraints from MPC Controller

Create a third-order plant model with two manipulated variables, one measured disturbance, and two measured outputs.

plant = rss(3,2,3);
plant.D = 0;
plant = setmpcsignals(plant,'mv',[1 2],'md',3);

Create an MPC controller for this plant.

MPCobj = mpc(plant,0.1);
-->The "PredictionHorizon" property of "mpc" object is empty. Trying PredictionHorizon = 10.
-->The "ControlHorizon" property of the "mpc" object is empty. Assuming 2.
-->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.

Assume that you have two soft constraints.

$$\begin{array}{l}
{u_1} + {u_2} \le 5\\
{y_2} + v \le 10
\end{array}$$

Set the constraints for the MPC controller.

E = [1 1; 0 0];
F = [0 0; 0 1];
G = [5;10];
V = [1;1];
S = [0;1];
setconstraint(MPCobj,E,F,G,V,S)

Retrieve the constraints from the controller.

[E,F,G,V,S] = getconstraint(MPCobj)
E =

     1     1
     0     0


F =

     0     0
     0     1


G =

     5
    10


V =

     1
     1


S =

     0
     1

Input Arguments

collapse all

MPCobj — Model predictive controllerMPC controller object

Model predictive controller, specified as an MPC controller object. To create an MPC controller, use mpc.

Output Arguments

collapse all

E — Manipulated variable constraint constantmatrix

Manipulated variable constraint constant, returned as a matrix with:

  • nc rows, where nc is the number of constraints.

  • nu columns, where nu is the number of manipulated variables.

If MPCobj has no custom constraints, then E is empty, [].

F — Controlled output constraint constantmatrix

Controlled output constraint constant, returned as a matrix with:

  • nc rows, where nc is the number of constraints.

  • ny columns, where ny is the number of controlled outputs (measured and unmeasured).

If MPCobj has no custom constraints, then F is empty [].

G — Custom constraint constantcolumn vector

Custom constraint constant, returned as a column vector with nc elements, where nc is the number of constraints.

If MPCobj has no custom constraints, then G is empty [].

V — Constraint softening constantcolumn vector

Constraint softening constant representing the equal concern for the relaxation (ECR), returned as a column vector with nc elements, where nc is the number of constraints. If MPCobj has no custom constraints, then V is empty [].

If V is not specified, a default value of 1 is applied to all constraint inequalities and all constraints are soft. This behavior is the same as the default behavior for output bounds, as described in Standard Cost Function.

To make the ith constraint hard, specify V(i) = 0.

To make the ith constraint soft, specify V(i) > 0 in keeping with the constraint violation magnitude you can tolerate. The magnitude violation depends on the numerical scale of the variables involved in the constraint.

In general, as V(i) decreases, the controller hardens the constraints by decreasing the constraint violation that is allowed.

S — Measured disturbance constraint constantmatrix

Measured disturbance constraint constant, returned as a matrix with:

  • nc rows, where nc is the number of constraints.

  • nv columns, where nv is the number of measured disturbances.

If there are no measured disturbances in the custom constraints, or MPCobj has no custom constraints, then S is empty [].

See Also

Introduced in R2011a

Was this topic helpful?