Accelerating the pace of engineering and science

Documentation

Using Custom Input and Output Constraints

This example shows how to design model predictive controller with mixed input/output constraints.

Design 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 <= u(t) <= 1

```plant = tf(1,[1 0 0]);                          % Prediction model
Ts = .1;                                        % Sampling time
p = 20;                                         % Prediction horizon
m = 20;                                         % Control horizon
mpcobj = mpc(plant,Ts,p,m);                     % MPC object
mpcobj.MV = struct('Min',-1,'Max',1);           % Input saturation constraints
```
```-->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 Mixed Input/Output (I/O) Constraint

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

`                0 <= u(t) + y(t) <= 1.2`

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

```                u(t) +  y(t) <= 1.2
-u(t) + -y(t) <= 0```
```setconstraint(mpcobj,[1;-1],[1;-1],[1.2;0]);
```

To run this example, Simulink® is required.

```if ~mpcchecktoolboxinstalled('simulink')
disp('Simulink(R) is required to run this example.')
return
end
```

Simulate closed-loop control of the linear plant model in Simulink. Controller "mpcobj" is specified in the block dialog.

```mdl = 'mpc_mixedconstraints';
```-->Converting the "Model.Plant" property of "mpc" object to state-space.
```bdclose(mdl);