Main Content

Constraints on Linear Combinations of Inputs and Outputs

You can constrain linear combinations of plant input and output variables. For example, you can constrain a particular manipulated variable (MV) to be greater than a linear combination of two other MVs.

The general form of such constraints is:

$$Eu\left( {k + i} \right) + Fy\left( {k + i} \right) +
Sv\left( {k + i} \right) \le G + {\varepsilon _k}V$$


  • ${\varepsilon _k}$ is the QP slack variable used for constraint softening. For more information, see Constraint Softening.

  • $u\left( {k + i} \right)$ are the ${N_{mv}}$ manipulated variable values, in engineering units.

  • $y\left( {k + i} \right)$ are the $N_y$ predicted plant outputs, in engineering units.

  • $v\left( {k + i} \right)$ are the ${N_{md}}$ measured plant disturbance inputs, in engineering units.

  • $E$, $F$, $S$, $G$, and $V$ are constant matrices and vectors. For more information, see setconstraint.

As with the QP cost function, output prediction using the state observer makes these constraints a function of the QP decision variables.

To set the mixed input/output constraints of an MPC controller, use the setconstraint function. To obtain the existing constraints from a controller, use getconstraint.

When using mixed input/output constraints, consider the following:

  • Mixed input/output constraints are dimensional by default.

  • Run-time updating of mixed input/output constraints is supported at the command line and in Simulink®. For more information, see Update Constraints at Run Time.

  • Using mixed input/output constraints is not supported in MPC Designer.

As an example, consider an MPC controller for a double-integrator plant with mixed input/output constraints.

Create Initial MPC Controller

The basic setup of the MPC controller includes:

  • A double integrator as the prediction model

  • Prediction horizon of 20

  • Control horizon of 20

  • Input constraints: $- 1 \le u\left( t \right) \le 1$

plant = tf(1,[1 0 0]);
Ts = 0.1;
p = 20;
m = 20;
mpcobj = mpc(plant,Ts,p,m);
mpcobj.MV = struct('Min',-1,'Max',1);
-->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000.
-->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000.
-->"Weights.OutputVariables" is empty. Assuming default 1.00000.

Define Mixed Input/Output Constraints

Constrain the sum of the input u(t) and output y(t) must be nonnegative and smaller than 1.2:

$$0 \le u\left( t \right) + y\left( t \right) \le 1.2$$

To impose this combined (mixed) I/O constraint, formulate it as a set of inequality constraints involving $u\left( t \right)$ and $y\left( t \right)$.

u\left( t \right) + y\left( t \right) \le 1.2\\
 - u\left( t \right) - y\left( t \right) \le 0

To define these constraints using the setconstraint function, set the constraint constants as follows:

$$E = \left[ {\begin{array}{*{20}{c}}
{ - 1}
\end{array}} \right],\;F = \left[ {\begin{array}{*{20}{c}}
{ - 1}
\end{array}} \right],\;G = \left[ {\begin{array}{*{20}{c}}
\end{array}} \right]$$


Simulate Controller

Simulate closed-loop control of the linear plant model in Simulink. The controller mpcobj is specified in the MPC Controller block.

mdl = 'mpc_mixedconstraints';
-->Converting the "Model.Plant" property to state-space.
-->Converting model to discrete time.
   Assuming no disturbance added to measured output #1.
-->"Model.Noise" is empty. Assuming white noise on each measured output.

The MPC controller keeps the sum $u+y$ between 0 and 1.2 while tracking the reference signal, $r = 1$.


See Also



Related Examples

More About