Integrated Multiple Predictive Algorithm Control Tool
Integrated Multiple Predictive Algorithm Control Tool
Integrated Multiple Predictive Algorithm Control Tool
SUMMARY
Page
1. Introduction
2. Installation
3. Users interface
4. System Source files for Impact
5. System
6. The System File Window
7. Controller
7.1. GPC: Generalized Predictive Control
7.2. SPG: GPC with Smith Predictor
7.3. DMC: Dynamic Matrix Control
7.4. PFC: Predictive Functional Control
7.5. SSMPC: State Space MPC
8. Experiment
9. Indications to perform an experiment
10. Acceding variables through Matlab workspace
11. Possible errors
2
2
3
4
7
8
9
10
11
12
14
14
17
23
25
26
APPENDIX I
Files from the book: the way of preloading an experiment
12.1. Example source Code
12.2. Glossary of code for preloading
28
28
29
The algorithms for all these controllers have been programmed for a generic
multivariable case to work with SISO and MIMO systems.
The interface will let to select the system to simulate, the controller to be used, and the
design parameters of this control. Regarding to the parameters relative to the
experiment, it will be possible to set its duration, reference to reach, constraints and
additional fields, such as noise and disturbances.
The result of the simulation will be a graphic, time versus outputs, and it will be
possible to add other ones to get more information about the experiment.
2. INSTALLATION
1. Unzip the file IMPACT.ZIP into a directory, this will result in the files needed
for this program (p files), and some subdirectories with the examples (m files).
2. It is necessary to add the path of this directory into the Matlab path in order to
run IMPACT correctly.
3. USERS INTERFACE
Typing impact in the MATLAB Command Window brings up the IMPACT interface
with the next figure:
1
C ( z 1 ) e(t )
A and B model the system, and the delay factor (z-d) have been integrated in B.
For example a model with d=3 given by:
(1 az 1 ) y (t ) z 3 (b0 b1 z 1 ) u (t 1) e(t )
y (t ) g i u (t i )
i 1
Used by DMC, it is implemented by the matrix g in the file. The length of this
matrix sets the upper value of the prediction horizon in the DMC controller. The
variable gninputs contains the inputs of the system, necessary if IMPACT works with
the step response model.
3. Space State Model
X (t ) M X (t 1) N u (t 1)
y (t ) Q X (t )
M, N and Q describe the system. In the file their names are the variables Mm,
Nm and Qm. They are used by PFC and SSMPC controllers.
These models are used by the simulator of the process, but it is possible that the
controller uses a different model of the system, i.e. an Error Modelling, that can be
enabled in the interface. In this case the file system will contain other matrices named
by Ap and Bp for the CARIMA, gp for the Step response, and Mp, Np and Qp for the
State Space Model.
A general information about the system in the file is contained in the cell array sinfo.
The system file also contains two variables that set the reference for the system:
1. Constant Reference: vrefc, that contains a constant reference for the outputs. It is a
column vector with the Set-Points in the case of using a constant reference in the
experiment. Notice that its size will be the number of outputs of the system.
2. Variable Reference: vrefv, built by the creator of the system file to describe changes
in the Set-Point. It is a matrix whose vectors are the Set-Points for each output. The
length of these vectors will be adapted to the simulation time of the experiment.
An example of the structure of a m-file accepted by IMPACT is the next one (SISO
system):
% e1s1d0.m
% Model Matrices
A=[1 -0.8];
B=[0.2];
% Error Model Matrices:.
Ap=[1 -0.875];
Bp=[0.154];
%Step response model and error modelling
g =[0;0.2;0.36;0.488;0.5904;0.67232;0.737856;0.7902;0.83222;...
0.865782272;0.8926258176;0.91410065408;0.9312805;0.945];
gp=g;
gninputs=1; %Needed if the system only works with g
%State-Space Model
Mm=0.8; Nm=0.5; Qm=0.4;
%State Space Error Modelling
Mp=0.9; Np=0.5; Qp=0.35;
%Information of the system
sinfo={'FIRST ORDER SYSTEM WITHOUT DELAY'};
%Constant SP
vrefc=[0.5];
%Built Variable SP built on vrefv
intt=50;totalt=100; %Local variables to built vrefv
vrefv=[0.5*ones(1,intt) , 0.25*ones(1,(totalt-intt)+1)];
There are several options for the system files that are described in Appendix I. These
ones are designed specifically to load an experiment directly with the system file. They
have been used with the example and exercise files that accompany this software,
corresponding to the chapters of the book MPC.
In spite of this, these options can be used by the user to create his system and
experiment files.
5. SYSTEM
It moves to the
directory above
List of
subdirectories
In the field Directory it is possible to write directly the root of the system file
location. To search it, press the button to go to the directory above of choose in the list
menu some of the subdirectories to continue. When the root directory is ready, press the
button Apply.
Then the main window loads the names of all the m-files in the root in the field FILE.
You can display it and choose some of the system files.
CAUTION 1: When a file is selected, the program executes the m-file, so this one has
to store the parameters required by the interface. However if you choose another kind of
system, the results could be unpredictable, causing errors. In this case close the
IMPACT interface and load it again, selecting an appropriate system.
CAUTION 2: Type the name of the unit in the edit field if you want to change from C:\
the unit that stores the system files.
Selecting one of the system file the system is completed with the next fields:
General Information
about the system
Button that
opens the
system
window
In the case of selecting a system file with the possibility of loading an experiment from
the file, such as files with examples and exercises of the book, a new button appears.
Pressing LOAD EXPERIMENT all the parameters of the experiment and the control are
loaded (see Appendix I for more information).
This step is quite enough to continue the selection of the controller and the experiment.
If you want to see more details of the system, change it of save a new system into a file,
press the System Info button to open the System File Window.
6. THE SYSTEM FILE WINDOW
All the fields indicated in the previous point could be showed by pressing the System
Info in the main menu.
The fields Inputs, Outputs and Delays are automatically calculated by IMPACT through
the given model.
Then, it is possible to change the system by some of its model descriptions, writing
directly over the edit fields. In this case the fields inputs, outputs and delays, can be
automatically reloaded, changing the matrices of the system.
Press Cancel if you do not want to load the changes. The changes will be enabled
pressing Save Changes and Close.
If we want to save the changed system pressing on Save in a File, a new window
appears, asking for the name and the root of the file.
Change the directory or the file name to the wished one. A general information about the
system (commentaries, description, 5 lines maximum) could be added too. Pressing
SAVE button the changes are completed and the file is saved.
7. CONTROLLER
This part enables the type of controller to be used, and the possibility of considering a
modelling error for the system load above.
The modelling error button enables it for Prediction Model , Ap,Bp, or Mp,Np and Qp
instead of the model represented by A,B or Mm, Nm and Qm. This mode will be
possible only if the system file contains an error modelling, in other case a warning
window will be displayed.
ON
1
C ( z 1 ) e(t )
J( N1, N2, N u) =
y (t j | t ) w(t j )
Nu
j N1
u (t j 1 | t )
2
Q
j 1
Applying for each controller, the tuning parameters appear on the right side of the
controller to show the active parameters and their values.
Pressing on the Robustness filter button, it is possible to choose the constant of the
filter for each output.
Tf is a column vector with a size equal to the outputs of the system. A value different
from 0 makes active the filter when Modelling Error is ON.
g
i 1
u (t i )
J=
y (t j / t ) w(t j )
jN1
Nu
u (t j 1)
2
Q
j 1
The DMC controller implemented in IMPACT uses the Step response Model stored in
the system file, or a Step Response Model that is calculated from the CARIMA model,
also stored in the file.
The DMC allows to the user the selection of the source of this Step Response Model.
Pressing the button DMC we can see the parameters for this kind of control:
List menu, to choose the Step Response Model, directly from file through matrix
g (or gp if Error Modelling is ON), or from CARIMA model. If some of the two
models are not in the file, the options are nor enabled.
p : Value for Prediction Horizon. N1=1 and N2=p
N: Highest Value for Prediction Horizon. This parameter depends on the model,
if Step Response model from file is active, N must be lower than the length of
the array g. If the CARIMA model is enabled, the program calculates the Step
Response Model with the length N.
m: Control horizon, Nu=m.
Q1 and R1: weighting vectors, similar to the previous controllers.
CAUTION 1:
If the system file does not contain the matrix g, the program will use the CARIMA
model to perform the Step response model. In this case the try of enabling the Step
response model from file provokes the next message, changing the option to the
CARIMA model.
CAUTION 2:
If the Step Response model from file is enabled, the possible highest value for the
prediction horizon is the length of g. If this parameter is selected higher, the next
warning message appears, changing N to the highest value.
CAUTION 3:
If p has been selected higher than N, the next error message appears.
CAUTION 4:
p has got a minimum value that is m-1. If p has been selected higher than this one, the
next error message appears, changing automatically to the minimum correct value.
k 1
In the case of selecting the PFC, the algorithm has not been implemented with the
possibility of adding CONSTRAINTS, so they are not supported.
This kind of controller always uses the Filter Reference for trajectory, so it is not
enabled the value of alpha is set to 0.
7.5. STATE SPACE MPC (SSMPC)
This control uses the Space State model, given by:
X (t ) M m X (t 1) N m u (t 1)
y (t ) Q m X (t )
The SSMPC controller designed for IMPACT considers two different cases:
Case 1: Non Incremental Model
The cost function is:
w(t j | t ) Q
N2
j N1
Subject to:
J=
x (t j | t )
2
R
u (t j 1 | t )
2
Q
w(t N 2 | t ) Q
x (t N 2 | t )
2
P
x(t i | t ) X , i N1...N 2
Qm x(t i | t ) Y , i N1...N 2
u (t i 1 | t ) U , i N1...N 2
u (t i 1 | t ) K x(t i 1 | t ), i N 3...N 2
(Re st1)
where N1 is considered as 0.
The matrix P and K are computed as follows:
LQ local controller enabled: the LQ regulator is considered as local controller,
and hence
K=KLQR
P= PLQR
LQ controller disabled: the control actions are considered to remain constant.
Then the constraints corresponding to Rest1 is transformed into:
u (t i | t ) u (t i 1 | t ) u (t N 3 1 | t ), i N 3...N 2
z k 1
y k Qm
0 z k
Nm
I
xk N m
u k
uk I
w(t j | t ) Q
N2
jN1
x(t j | t )
2
R
u (t j 1 | t )
2
Q
w(t N 2 | t ) Q
x(t N 2 | t )
subject to:
x(t i | t ) X , i N1...N 2
Qm x(t i | t ) Y , i N1...N 2
u (t i 1 | t ) U , i N1...N 2
u (t i 1 | t ) K X x (t i 1 | t ) KU u (t i 1 | t ), i N 3...N 2
(Re st 2)
Attending to this configuration, the parameters for this controller inside IMPACT are:
2
P
N1: Initial value for the prediction horizon. Its value is fixed to 1.
N2: Final value for the prediction horizon.
N3: Control horizon.
Q1: Control weighting vector.
R1: Reference weighting vector.
8. EXPERIMENT
SAMPLE TIME
It establishes the number of samples of the experiment. Initially it has a duration of 100.
FILTER FOR REFERENCE TRAJECTORY.
IMPACT allows setting the way of choose the reference trajectory w(t) in the cost
function where it appears.
It can be done in two different ways:
1.Filter for reference trajectory ON. It means that the reference is estimated in all the
prediction horizon in the way:
w(t k ) w(t k 1) (1 )ref (t k )
k 1...N
(alpha) is a parameter between 0 and 1(the closer to 1 the smoother the approximation)
that constitutes an adjustable value that influence the dynamic response of the system.
2.Filter OFF. The reference trajectory is equal to ref in the entire prediction horizon.
ref contains the set-point for the experiment in each instant, and it is loaded from file or
built in the experiment through the option DEFINE SET-POINT.
REFERENCE KNOWN A PRIORI
Impact allows the user to set if the future reference is known a priori or not. If this is
known the system can react before the change has effectively been made, thus avoiding
the effects of delay in the process response.
In SSMPC and PFC the reference has to be known a priori, so this field is ON.
SET-POINT DEFINITION
CONSTANT SET POINT
When the system is loaded, appear the set-point constant values stored in the variable
vrefc from the system file.
It could be changed into different values for the experiment.
Selecting CONSTANT SP, IMPACT creates a set-point vector for each output with the
needed size (based on the prediction horizon) stored in variable ref.
DEFINE SET-POINT
Press Draw to see the new set-point, Accept to validate the changes and close the
window, and Exit to Close it without saving.
CAUTION 1:
Every time that the Time of the experiment is redefined the Set-Point definition mode
turns to CONSTANT SP.
CAUTION 2:
The variable set-point defined in the file corresponds to a experiment time, that is, if
vrefv has a length of 100, this corresponds to a experiment time of 100. If this time is
not equal to this length, IMPACT fits the reference vector to the time. This is made in
two ways:
1. If vrefv contains a number of points lower than the experiment time, the
program extends the vector till the length corresponding to the experiment time
with a value constant and equal to the last value of vrefv.
2. If vrefv contains a number of points higher than the experiment time, the
program cuts the vector to the length corresponding to the experiment time, and
the rest is not considered.
In these two cases, a warning dialog is displayed and changes internally made:
CONSTRAINTS
The button CONSTRAINTS open a window that gives the possibility of setting the
restrictions for the controllers.
These constraints are the next ones:
Constraints on incremental inputs.
Constraints on inputs.
Constraints on outputs.
These are enabled for GPC,SPGPC, DMC and SSMPC controllers.
Constraints on states.
Only enabled for SSMPC controller.
Monotonic Constraints
Non-Minimum Phase Constraints.
Only enabled for GPC, SPGPC and DMC controller. They can not be used
simultaneously.
The algorithm implemented by IMPACT for PFC controller does not allow using
constraints, so they all are not enabled for it.
The CONSTRAINTS window has this appearance:
To active some of the constraints mark the corresponding radiobutton and press
APPLY. In the main window appears an information about the constraints enabled.
In the two cases the user will select the output that will be disturbed and its value.
Select the times for disturbance and press APPLY IMPULSE or APPLY STEP to
validate the changes, or CANCEL to Exit without activating noise or disturbances.
GRAPHICS
These buttons allows the user choose what graphics will be displayed after the
calculation made by APPLY BUTTON.
Pressing Apply and not activating any of the GRAPHICS button, the program plots the
output signals of the system by defect.
Plots that can be added are
Some information about the control and the experiment has been added in the plots.
This information contains the selected parameters for the controller, and it they are
enabled, the features added to the experiment, such as Error Modelling, Disturbances or
Noise.
In the case of selecting STATES plots for the SSMPC, these graphics are drawn
into a new window.
9. INDICATIONS TO PERFORM AN EXPERIMENT
We recommend following these indications in order to execute correctly the experiment:
1. Select the system.
If you need to make some modifications or simply to see its values, go into the
System Info Window.
2. Select the controller and its parameters.
This step is necessary every time to change the system, that is because the
parameters have to be reloaded in a correct way. That is, if you select a 2x2
system and its control, the matrices R1 and Q1 will take values of size 2x1;
therefore if you change the to a 1x1 system these matrices will not be correct,
unless you reload the control and force the change.
3. Fill the experiment parameters.
It is convenient to follow this order filling these fields.
Set the experiment time.
Select the Filter for the Reference trajectory and the value of alpha (when
it is possible).
Select if the Reference is known a priori.
Select the set-point (Constant or Variable).
Fill the constraints if the experiment requires it.
Add noises or disturbances.
Select the graphics to be drawn
4. Press the button Apply
Then the simulation is performed in two stages. In the first one the system and
the experiment parameters are validated, and a message like this appears in order
to advise the user that all the parameters have been filled correctly:
The selected system is not appropriate for IMPACT, i.e, the system file has not got the
structure described in point 4.
Some other Error Windows are opened with this one. Close all of them and try with
another system.
It appears when the previous error has been not detected, and System File Window is
pressed. Load other system file.
3. Error in Matlab command window
Missing operator, comma, or semi-colon.
Error in ==> C:\MATLABR11\work\vacNu.m
On line 10 ==> Nu1=eval(get(gco,'String'));
??? Error while evaluating uicontrol Callback.
??? 5
|
Missing operator, comma, or semi-colon.
Error in ==> C:\MATLABR11\work\writeSSMPCpar.m
On line 9 ==> vNu=eval(N3SSMPC);
??? Error while evaluating uicontrol Callback.
This error is due to an error writing some of the parameters of the controller, i.e. to write
a character instead a number, or a parenthesis instead a bracket.
This does not stop IMPACT, so you can continue the simulation realizing that the
correct change has to be done.
4. Error validating data pressing Apply.
If you press Apply in IMPACT interface and some of the parameters introduced are not
correct or have not the correct size, a message like this will appear:
In the adverse case, the parameters are considered correct and the simulation loop starts.
5. Error in simulation loop (controller execution).
If during some sample of the simulation loop the controller fails, a message error is
displayed with the time where this occurs.
And some information about the source of the error, for instance:
APPENDIX I
FILES FROM THE BOOK. THE WAY OF PRELOADING AN EXPERIMENT
It is possible to add in the system file the parameters for the controller and the
experiment in order to store and load some specific experiment. This part is not
important for the user that does not need especially to deep in the interface
configuration, but only in its performing.
This possibility has been used by creators of IMPACT in the system files from the
directory Examples MPC, to build the examples and the exercises of the book MPC. In
this manner, it is very simple to load these files and see the results in the easiest way.
Any system with the experiment defined inside the file, is detected by IMPACT,
showing the button LOAD EXPERIMENT in the SYSTEM field:
In this case, simply pressing the button LOAD EXPERIMENT, the controller and the
experiment are configured, and the user only have to press the APPLY button to perform
the preloaded experiment.
1. EXAMPLE SOURCE CODE
IMPACT uses the structure opt to receive all these kind of parameters. You can see the
specific rules to preload the experiments in point 12.2.
The next code is added to a system file to preload the controller and the experiment. It is
a GPC controller and the experiment takes 200 samples, filter reference enabled with
alpha 0.9, constant SP, and constraints on incremental inputs.
%OPTIONS TO FILL THE INTERFACE
%controller DMC
opt.GPC='on';
opt.NGPC=10;
opt.NuGPC=5;
opt.Q1GPC=[1];
opt.R1GPC=[1];
%experiment
opt.time=200;
opt.sp='constant';
opt.reffilter='on';
opt.alpha=0.9;
opt.refknown='on';
opt.constdu='on';
opt.umax=[2];
opt.umin=[-3];
Although this utility has been designed to load in the simplest way the experiment
described in the book, it can be very interesting to the user to create its own options to
add to its files.
Assignment Value
on
numeric value
numeric value;
[value/s (sep by ;)]
[value/s (sep by ;)]
Example
opt.GPC='on';
opt.NGPC=10;
opt.NuGPC=5;
opt.Q1DMC=[1;.9];
opt.R1DMC=[1;3];
Assignment Value
on
numeric value
numeric value;
[value/s (by ;)]
[value/s (by ;)]
on
[value/s (by ;)]
Example
opt.SPG='on';
opt.NSPG=10;
opt.NuSPG=5;
opt.Q1SPG=[1;.9];
opt.R1SPG=[1;3];
opt.robust'on';
opt.Tf=[0.7;0.8];
CONTROLLER DMC
Assignment Value
on
step/carima
numeric value
numeric value;
numeric value;
[value/s (by ;)]
[value/s (by ;)]
Example
Parameters
opt.DMC
Step Response Model
opt.modstep
Min Prediction horizon opt.pDMC
Max Prediction horizon opt.NDMC
Control horizon
opt.mDMC
Control weighting
opt.Q1DMC
Reference weighting
opt.R1DMC
CONTROLLER PFC
Parameters
opt.PFC
Prediction horizon
opt.NPFC
Number of basis functions opt.nBPFC
CONTROLLER
SSMPC
LQ CONTROLLER
INCREMENTAL
Prediction horizon
Control horizon
Control weighting
Reference weighting
Assignment Value
on
numeric value
numeric value;
Parameters
Assignment
Value
opt.SSMPC
on
opt.LQ
on/off
opt.incremental on/off
opt.N2SSMPC numeric value
opt.N3SSMPC numeric value;
opt.Q1SSMPC [value/s (by ;)]
opt.R1SSMPC [value/s (by ;)]
Parameters
opt.moderror
opt.DMC='on';
opt.modstep='step';
opt.pDMC=15;
opt.NDMC=20;
opt.mDMC=2;
opt.Q1DMC=[1];
opt.R1DMC=[1];
Example
opt.PFC='on';
opt.NPFC=10;
opt.nBPFC=1;
Example
opt.SSMPC='on';
opt.LQ='on';
opt.incremental='off';
opt.N2SSMPC=20;
opt.N3SSMPC=2;
opt.Q1SSMPC=[1];
opt.R1SSMPC=[1];
Assignment Value
on/off
Example
opt.moderror,'on'
EXPERIMENT
Feature
Parameters
Assignment Value
Example
Time
Filter for
Reference
Trajectory
Value of Alpha
Set Point type
opt.time
numeric value
opt.time=25;
opt.reffilter
on/off
opt.reffilter='off';
opt.alpha
opt.sp
opt.alpha=0.9;
numeric value
constant/variable opt.sp='constant';
Reference known
a priori
opt.refknown
off/on
Constraints on
Inc Inp(du)
Value of dumax
Value of dumin
opt.constdu
opt.umax
opt.umin
on
[value/s (by ;)]
[value/s (by ;)]
Constraints on
Inputs (u)
Value of dumax
Value of dumin
opt.constu
opt.Umax
opt.Umin
on
[value/s (by ;)]
[value/s (by ;)]
Constraints on
Outputs (y)
Value of ymax
Value of ymin
opt.consty
opt.ymax
opt.ymin
on
[value/s (by ;)]
[value/s (by ;)]
Constraints on
States (x)
Value of xmax
Value of xmin
opt.constu
on
[value/s (by ;)]
[value/s (by ;)]
Non Minimum
Phase Monotonic
Constraints
opt.constfnm
opt.constmon
Disturbances
Type of
disturbance
Values of
disturbance
Time for impulse
Start time for step
End time for step
opt.disturbances on
opt.vper
opt.tper
opt.t1per
opt.t2per
Noise
Outputs with noise
Amplitude of
opt.noise
opt.vnoise
opt.amplitude
on
[value/s (by ;)]
number
opt.xmax
opt.xmin
opt.refknown='on';
opt.constdu='on';
opt.umax=[2];
opt.umin=[-3];
on
on
opt.disturbmode impulse/step
opt.disturbances='on';
opt.disturbmode='step';
opt.vper=[.3;0];
opt.t1per=1;
opt.t2per=120;
opt.noise='on';
opt.vnoise=[0;1];
opt.amplitude=0.025;
noise
CAUTION:
It is important to use the same format of the strings in the structure opt.
Note that opt.GPC=ON is not the same that opt.GPC=on, so please do not use the
capital ones.