impact: integrated multiple predictive algorithm …danirr/impact.doc · web viewssmpc (state space...

41
Integrated Multiple Predictive Algorithm Control Tool. Tool for the Second Edition of the book MPC By E.F.Camacho and C.Bordons

Upload: lyminh

Post on 16-Mar-2018

225 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

Integrated Multiple Predictive Algorithm Control Tool.

Tool for the Second Edition of the book MPCBy E.F.Camacho and C.Bordons

Page 2: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

SUMMARY Page

1. Introduction 22. Installation 23. User’s interface 34. System Source files for Impact 45. System 76. The System File Window 87. Controller 9

7.1. GPC: Generalized Predictive Control 107.2. SPG: GPC with Smith Predictor 117.3. DMC: Dynamic Matrix Control 127.4. PFC: Predictive Functional Control 147.5. SSMPC: State Space MPC 14

8. Experiment 179. Indications to perform an experiment 2310. Acceding variables through Matlab workspace 2511. Possible errors 26

APPENDIX I 28Files from the book: the way of preloading an experiment

12.1. Example source Code 2812.2. Glossary of code for preloading 29

Page 3: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

IMPACT: Integrated Multiple Predictive Algorithm Control Tool.

1. INTRODUCTION

The objective of this program is to show several linear predictive controllers inside an only user interface that allows simulating systems in such an easy and fast way. It gives the opportunity to change the parameters of a simulation to analyze the differences produced.The controllers implemented under the interface are:

GPC (Generalized Predictive Control) SPGPC (GPC with Smith Predictor) DMC (Dynamic Matrix Control) PFC (Predictive Functional Control) SSMPC (State Space Model Predictive Control)

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.

Page 4: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

3. USER’S INTERFACE

Typing impact in the MATLAB Command Window brings up the IMPACT interface with the next figure:

The interface is divided in three different parts: SYSTEM: This part loads the system file to be simulated, changes its properties

(matrices) and saves a system created by the user in a file. CONTROLLER: It sets the kind of MPC controller to be used, and allows

changing the specific tuning parameters, such as horizons or weighting matrices. EXPERIMENT: It establishes the main features of the simulation: time,

reference parameters, constraints, noises, disturbances and graphics to be showed.

Apply and Cancel are the buttons that start the simulation or close the interface respectively. Apply makes all the calculations of the experiment verifying the correct

Page 5: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

filling of the fields in the interface, and advising through warning or error windows about possible errors.4. SYSTEM SOURCE FILES FOR IMPACT A system source file in IMPACT will contain the different matrices that model the behaviour of a system.The following forms of modelling a system are accepted by IMPACT.

1. Carima Model.

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:

will be described in the system file in the next way:

A=[1 a]; B=[0 0 0 b0 b1];

This model is used by controllers GPC, SPGPC and DMC, for this case with a previous transformation from CARIMA into a Step Response model.

2. Step Response Model

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

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.

Page 6: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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 MatricesA=[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 ModellingMp=0.9; Np=0.5; Qp=0.35;

%Information of the system sinfo={'FIRST ORDER SYSTEM WITHOUT DELAY'};%Constant SPvrefc=[0.5];%Built Variable SP built on vrefvintt=50;totalt=100; %Local variables to built vrefvvrefv=[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.

Page 7: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

5. SYSTEMThe system part initially present two fields:

A list menu that includes the m-files of the directory A button that allows changing the directory which the system files are included

in.

Pressing this button the next window appears:

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:

Current directory

It moves to the directory above

List of subdirectories

General Information about the system

Button that opens the system window

Page 8: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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 WINDOWAll the fields indicated in the previous point could be showed by pressing the System Info in the main menu.

Page 9: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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

Page 10: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

7.1. GENERALIZED PREDICTIVE CONTROL (GPC)

This control uses the CARIMA model, where B contains the delay factor:

where the unmeasurable disturbance is given by a white noise coloured by C(z-1).

The objective function is a quadratic cost function of he form::

J( N1, N2, N u) =

Where is the optimal prediction in t+j of the system output computed in t, w is the reference trajectory. N1 and N2 are the initial and the final value of the prediction horizon and Nu is the control horizon. R and Q are positive matrices that represent the weightings for the trajectory and the control respectively.Considering the effect of the delay d in the system, the horizons N1 and N2 have been chosen in the following way:

N1=d+1N2=d+N

N will be the prediction horizon parameter of the GPC.

Four parameters are necessary for tuning the controller: N, PREDICTING HORIZON Nu, CONTROL HORIZON Q1, CONTROL WEIGHT. Column vector that contains the weighting of each

control input. Its size is [q1;…;qn], being n: number of inputs. R1, REFERENCE WEIGHT. Column vector that contains the weighting of each

output with size number of outputs.

Q1 and R1 appear initially as column vectors with 1s. The program internally uses a diagonal matrices Q and R, whose diagonals are the elements of Q1 and R1.

Page 11: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

Applying for each controller, the tuning parameters appear on the right side of the controller to show the active parameters and their values.

7.2. GPC WITH SMITH PREDICTOR (SPGPC)It uses the same parameters as GPC, but internally contains a Smith Predictor as dead time compensator.It is equal to the GPC but it offers the possibility of tuning a ROBUSTNESS FILTER in the case when the error modelling is enabled.

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.

Page 12: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

7.3 DYNAMIC MATRIX CONTROL (DMC)This controller used the Step Response Model, that is:

where gi are the coefficients of the Step Response. And the objective function is:

J =

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.

Press the button Apply to make the control active.

CAUTION 1:

Page 13: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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.

7.4. PREDICTIVE FUNCTIONAL CONTROL (PFC)

Page 14: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

This control uses the Space State model, given by:

and the next objective function:

J =

This controller has two parameters for tuning: Prediction Horizon, Nh. Number of basis functions: nB.

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:

The SSMPC controller designed for IMPACT considers two different cases:

Case 1: Non Incremental ModelThe cost function is:

J=

Subject to:

Page 15: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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 henceK=KLQR P= PLQR

LQ controller disabled: the control actions are considered to remain constant. Then the constraints corresponding to Rest1 is transformed into:

and P is considered as P=0.Case 2: Incremental Model.

The model is transformed into:

The cost function is:

subject to:

The two possibilities through the LQ controller are: LQ controller enabled: The local controller of the augmented plant is the LQR.

Thus, K=[KX , KU]= KLQR P= PLQR

LQ controller disabled: The increments of the control actions are considered to be zero, and hence

K=0 P= 0

Attending to this configuration, the parameters for this controller inside IMPACT are:

Incremental Model: Pressing on this button it will be used the Incremental model for the control.

LQ Controller: To active the local control press the button LQ local Control. 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.

Page 16: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

R1: Reference weighting vector.

And the aspect of the parameters menu for SSMPC is:

8. EXPERIMENT

SAMPLE TIMEIt 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.

Page 17: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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:

α(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 PRIORIImpact 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 DEFINITIONCONSTANT SET POINTWhen 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-POINTThis field allows using a dynamic set-point in the experiment.

Page 18: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

It opens a new window with the different ways of selection:

It could be done in two different ways: Variable SP from file:

It takes the vector built in the system file and stored on the variable vrefv. Define Variable SP.

This tool allows building a set-point though steps. The number of steps in the set-point is defined in the list NUMBER OF STEPS, until a maximum of 3 steps.This option displays a new window, SET POINT BUILDER, where it is possible to set the step time, the values and draw the new set-point.

It loads the value of vrefv on set-point

It builds a new set-point using steps in reference

Page 19: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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:

CONSTRAINTSThe 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.

Page 20: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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.

The button CONSTRAINTS turns green to indicate that it is active.

CAUTION:

Press the button APPLY to make the changes, but try not to use the Close Window button in the right upper corner. If you want to cancel the constraints, enter again in the window and make all ones inactive.

Page 21: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

NOISES AND DISTURBANCES

IMPACT includes the possibility for adding noises and disturbances to the outputs signals in the experiment.

Noises: It is a coloured white noise added to the output signal in a range given by user.

Disturbances: It is a signal added to the output signal in a time given by user.

In both cases we can activate the noises or disturbances setting ON in the pop-up menu:

The Noise Window.Impact allows setting the ouput signal with added noise, simply enabling the corresponding radio button.It is possible to define the amplitude of the noise, writing the values for the highest and the lowest value to be added.

The Disturbances WindowIn the same way that in noise case, we activate the output signal through the corresponding radio button.There are two possibilities to select the disturbance:

Impulse Disturbance: disturbance produced in a sample time. Step Disturbance, produced between two sample times.

The value of the disturbance can be edited in the frame closest to the output. A value equal to 0 indicates the same thing that if the output were not enabled.There are three times that can be selected by user:

Page 22: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

Time for Impulse disturbance: The time where the disturbance is added to the output signal.

Start time for Step disturbance. End time for Step Disturbance.

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.

GRAPHICSThese 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

Delta u: It plots the incremental inputs. U: It plots the inputs of the system. Set-Points: reference drawn together with the output signals States: Only for SSMPC.

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.

Page 23: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

The keys for some words of the plot title are: LQ: LQ controller ON for SSMPC controller. INC: Incremental ON for SSMPC controller. ERR MOD: Error Modelling ON. DIST: Disturbances added in the experiment. NOISE: Noise added in the experiment. RKNOWN: Reference known a priori. RFILTER: Filter for reference ON.

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).

Page 24: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

Fill the constraints if the experiment requires it. Add noises or disturbances. Select the graphics to be drawn

4. Press the button ApplyThen 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:

Pressing OK the simulation loop starts, a message about its evolution is displayed:

If the experiment is completed IMPACT will displayed the graphics. If some error occurs an error window appears (See 11).

10. ACCESSING VARIABLES THROUGH MATLAB WORKSPACE

Every time IMPACT performs a simulation, some variables are ready in Matlab workspace. The most of them are not important, because they are used for the interface and to store additional information to execute correctly the experiment.Some of them can be useful for other purposes and they are available for any other Matlab application.

Variables that stores the graphical outputs:

Timeplot: Vector with the sample times. Ypplot: Column vector with the outputs. Refplot: Column vector with the set-points. Upplot: Column vector with the inputs. urealplot: Column vector with the incremental inputs. xplot: Column vector with the states (only for SSMPC).

Other accessible variables:

YP: Column vectors with the outputs. ref: Column vector with the set-points. UP: Column vector with the incremental inputs. ureal: Column vector with the inputs.

Page 25: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

xplot: Column vector with the states (only for SSMPC). ruidos: Vector with noise added to the output signal. Ypert: Vector with disturbances added to the output signal.

These variables appear complete and they are cut by IMPACT to obtain the plot variables.GPC, SPGPC and DMC:

G: GPC matrix for GPC and SPGPC, and Dynamic Matrix for DMC. H: is equal to G’RG+Q R: Reference Weighting Matrix. Q: Control Weighting Matrix.

PFC: Bb: Matrix for base functions. YB: Matrix that stores the response for each of the base functions in every

instant of the horizon. X: Column vector with the states. Xp: Column vector with the states considering the process model.

SSMPC: A, B, C: Matrices of the system (A is Mm, B is Nm and C is Qm). X, Y, U, IncU: Matrices for constraints. K: LQ Local Controller. P: Weighting matrix for Terminal cost.

11. POSSIBLE ERRORS

Some errors can be produced whilst the IMPACT is executed. Here we give a brief description about this possibility. We appreciate very much any contribution to detect them, so do not hesitate to contact the authors for any problem executing IMPACT, in order to improve the interface and solve these ones.

1. Error in file

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.

2. Non Appropriate system file

Page 26: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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

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:

And a message with the source of the error:

Missing operator, comma, or semi-colon.

Error in ==> C:\MATLABR11\work\vacNu.mOn 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.mOn line 9 ==> vNu=eval(N3SSMPC);

??? Error while evaluating uicontrol Callback.

Page 27: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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 IFILES 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:

Page 28: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

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 DMCopt.GPC='on';opt.NGPC=10; opt.NuGPC=5;opt.Q1GPC=[1]; opt.R1GPC=[1];

%experimentopt.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.2. GLOSSARY OF CODE FOR PRELOADING Controller and Parameters:

CONTROLLER GPC Parameters Assignment Value Example

Prediction horizonControl horizonControl weightingReference weighting

opt.GPCopt.NGPC opt.NuGPC opt.Q1GPC opt.R1GPC

’on’numeric valuenumeric value;[value/s (sep by ;)][value/s (sep by ;)]

opt.GPC='on';opt.NGPC=10; opt.NuGPC=5;opt.Q1DMC=[1;.9]; opt.R1DMC=[1;3];

CONTROLLER SPGPC Parameters Assignment Value Example

Prediction horizonControl horizonControl weightingReference weightingRobustness Filter

opt.SPGopt.NSPG opt.NuSPG opt.Q1SPG opt.R1SPG

’on’numeric valuenumeric value;[value/s (by ;)][value/s (by ;)]‘on’

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];

Page 29: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

Constants for filter opt.robust opt.Tf

[value/s (by ;)]

CONTROLLER DMC Parameters Assignment Value Example

Step Response ModelMin Prediction horizonMax Prediction horizonControl horizonControl weightingReference weighting

opt.DMCopt.modstepopt.pDMC opt.NDMC opt.mDMC opt.Q1DMCopt.R1DMC

’on’‘step’/’carima’numeric valuenumeric value;numeric value;[value/s (by ;)][value/s (by ;)]

opt.DMC='on';opt.modstep='step';opt.pDMC=15;opt.NDMC=20;opt.mDMC=2;opt.Q1DMC=[1];opt.R1DMC=[1];

CONTROLLER PFC Parameters Assignment Value Example

Prediction horizonNumber of basis functions

opt.PFCopt.NPFC opt.nBPFC

’on’numeric valuenumeric value;

opt.PFC='on';opt.NPFC=10;opt.nBPFC=1;

CONTROLLER SSMPC

Parameters Assignment Value

Example

LQ CONTROLLERINCREMENTALPrediction horizonControl horizonControl weightingReference weighting

opt.SSMPCopt.LQopt.incrementalopt.N2SSMPC opt.N3SSMPCopt.Q1SSMPCopt.R1SSMPC

’on’‘on’/’off’‘on’/’off’numeric valuenumeric value;[value/s (by ;)][value/s (by ;)]

opt.SSMPC='on';opt.LQ='on';opt.incremental='off';opt.N2SSMPC=20;opt.N3SSMPC=2;opt.Q1SSMPC=[1];opt.R1SSMPC=[1];

FOR ALL CONTROLLERS Parameters Assignment Value ExampleMODELLING ERROR opt.moderror ‘on’/’off’ opt.moderror,'on'

EXPERIMENT

Feature Parameters Assignment Value Example

TimeFilter for Reference TrajectoryValue of AlphaSet Point type

Reference known a priori

Constraints onInc Inp(du)Value of dumax

opt.time

opt.reffilter

opt.alphaopt.sp

opt.refknown

opt.constduopt.umaxopt.umin

numeric value ‘on’/’off’

numeric value‘constant’/’variable’

‘off’/’on’

‘on’[value/s (by ;)][value/s (by ;)]

opt.time=25;

opt.reffilter='off';

opt.alpha=0.9;opt.sp='constant';

opt.refknown='on';

opt.constdu='on';opt.umax=[2];opt.umin=[-3];

Page 30: IMPACT: Integrated Multiple Predictive Algorithm …danirr/IMPACT.doc · Web viewSSMPC (State Space Model Predictive Control) The algorithms for all these controllers have been programmed

Value of dumin

Constraints onInputs (u) Value of dumaxValue of dumin

Constraints on Outputs (y)Value of ymaxValue of ymin

Constraints onStates (x)Value of xmaxValue of xmin

Non Minimum Phase Monotonic Constraints

DisturbancesType of disturbanceValues of disturbanceTime for impulseStart time for stepEnd time for step

NoiseOutputs with noiseAmplitude of noise

opt.constuopt.Umaxopt.Umin

opt.constyopt.ymaxopt.ymin

opt.constu

opt.xmaxopt.xmin

opt.constfnmopt.constmon

opt.disturbances

opt.disturbmode

opt.vperopt.tperopt.t1peropt.t2per

opt.noiseopt.vnoiseopt.amplitude

‘on’[value/s (by ;)][value/s (by ;)]

‘on’[value/s (by ;)][value/s (by ;)]

‘on’[value/s (by ;)][value/s (by ;)]

‘on’‘on’

‘on’

‘impulse’/‘step’

[value/s (by ;)]numbernumbernumber

‘on’[value/s (by ;)]number

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;

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.