This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

setconstraint

Set mixed input/output constraints for model predictive controller

Syntax

setconstraint(MPCobj,E,F,G)
setconstraint(MPCobj,E,F,G,V)
setconstraint(MPCobj,E,F,G,V,S)
setconstraint(MPCobj)

Description

example

setconstraint(MPCobj,E,F,G) specifies mixed input/output constraints of the following form for the MPC controller, MPCobj:

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

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

  • p is the prediction horizon.

  • k is the current time index.

  • E, F, and G are constant matrices. Each row of E, F, and G represents a linear constraint to be imposed at each prediction horizon step.

  • u is a column vector of manipulated variables.

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

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

example

setconstraint(MPCobj,E,F,G,V) adds constraints of the following form:

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

where V is a constant vector representing the equal concern for the relaxation (ECR).

example

setconstraint(MPCobj,E,F,G,V,S) adds constraints of the following form:

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

where:

  • v is a column vector of measured disturbance variables.

  • S is a constant matrix.

example

setconstraint(MPCobj) removes all mixed input/output constraints from the MPC controller, MPCobj.

Examples

collapse all

Specify a constraint of the form 0u2-2u3+y215 on an MPC controller.

Create a third-order plant model with three manipulated variables and two measured outputs.

plant = rss(3,2,3);
plant.D = 0;

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.

Formulate the constraint in the required form:

[0-1201-2][u1u2u3]+[0-101][y1y2][015]+ε[11]

Specify the constraint matrices.

E = [0 -1 2;0 1 -2];
F = [0 -1;0 1];
G = [0;15];

Set the constraints in the MPC controller.

setconstraint(MPCobj,E,F,G)

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

plant = rss(3,2,2);
plant.D = 0;

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 hard constraints.

u1+u25y1+y210

Specify the constraint matrices.

E = [1 1; 0 0];
F = [0 0; 1 1];
G = [5;10];

Specify the constraints as hard by setting V to zero for both constraints.

V = [0;0];

Set the constraints in the MPC controller.

setconstraint(MPCobj,E,F,G,V)

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

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

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 three soft constraints.

u1+u25y1+v110y2+v212

Specify the constraint matrices.

E = [1 1; 0 0; 0 0];
F = [0 0; 1 0; 0 1];
G = [5;10;12];
S = [0 0; 1 0; 0 1];

Set the constraints in the MPC controller using the default value for V.

setconstraint(MPCobj,E,F,G,[],S)

Define a plant model and create an MPC controller.

plant = rss(3,2,2);
plant.D = 0;
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.

Define controller custom constraints.

E = [-1 2; 1 -2];
F = [0 1; 0 -1];
G = [0; 10];
setconstraint(MPCobj,E,F,G)

Remove the custom constraints.

setconstraint(MPCobj)
-->Removing mixed input/output constraints.

Input Arguments

collapse all

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

Manipulated variable constraint constant, specified as an Nc-by-Nmv array, where Nc is the number of constraints, and Nmv is the number of manipulated variables.

Controlled output constraint constant, specified as an Nc-by-Ny array, where Ny is the number of controlled outputs (measured and unmeasured).

Mixed input/output constraint constant, specified as a column vector of length Nc.

Constraint softening constant representing the equal concern for the relaxation (ECR), specified as a column vector of length Nc.

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.

Note

If a constraint is difficult to satisfy, reducing its V(i) value to make it harder can be counterproductive. Doing so can lead to erratic control actions, instability, or failure of the QP solver that determines the control action.

Measured disturbance constraint constant, specified as an Nc-by-Nmd array, where Nmd is the number of measured disturbances.

Tips

  • The outputs, y, are being predicted using a model. If the model is imperfect, there is no guarantee that a constraint can be satisfied.

  • Since the MPC controller does not optimize u(k + p|k), the last constraint at time k + p assumes that u(k+p|k) = u(k+p–1|k).

  • When simulating an MPC controller, you can update the E, F, G, and S constraint arrays at run time. For more information, see Update Constraints at Run Time.

Introduced in R2011a