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.

Understanding Control Behavior by Examining Optimal Control Sequence

This example shows how to inspect the optimized sequence of manipulated variables computed by a model predictive controller at each sample time.

The plant is a double integrator subject to input saturation.

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 10

  • Input constraints -1 <= u(t) <= 1

Configure the MPC controller.

Ts = 0.1;                               % Sample time
p = 20;                                 % Prediction horizon
m = 10;                                 % Control horizon
mpcobj = mpc(tf(1,[1 0 0]),Ts,p,m);     % MPC object
mpcobj.MV = struct('Min',-1,'Max',1);   % Input saturation constraints
nu=1;                                   % Number of manipulated variables
-->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.

Simulate Model in Simulink®

To run this example, Simulink® is required.

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

Open the Simulink® model, and run the simulation.

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

The MPC Controller block has an mv.seq output port, which is enabled by selecting the Optimal control sequence block parameter. This port outputs the optimal control sequence computed by the controller at each sample time. The output signal is a (p+1)-by-Nmv array, where p is prediction horizon and Nmv is the number of manipulated variables.

In a simlar manner, the controller can output the optimal state sequence (x.seq) and the optimal output sequence (y.seq).

The model exports this control sequence to the MATLAB® workspace at each simulation step, logging the data as useq.

Analyze Optimal Control Sequences

Plot the optimal control sequence at specific time instants.

times = [0 0.2 1 2 2.1 2.2 3 3.5 5];
figure('Name','Optimal sequence history');
for t = 1:9
    ct = times(t)*10+1;
    h = stairs(0:p,useq.signals.values(ct,:));
    h.LineWidth = 1.5;
    hold on
    xlabel('prediction step')
    title(sprintf('Sequence (t=%3.1f)',useq.time(ct)))
    axis([0 p -1.1 1.1])
    hold off

The MPC controller uses the first two seconds to bring the output very close to the new set point. The controller output is at the high limit (+1) for one second and switches to the low limit (-1) for the next second, which is the best control strategy under the input constraint limits.


See Also