LSmodel - Large Scale Model Class
LSmodel is a class for representation and management of Large Scale (LS) models. LS model is described as a set of submodels together with description of submodels mutual interconnections and submodels interconnections with external inputs and outputs.
Signal interconnections is name based, i.e. to define that outputs and intpus of certain submodels are conneted requires to give them the same names. Submodels are internally represented as state-space models. However any model type, which can be converted by SS command, can by supplied as submodel and original model is stored in LSmodel class along with its state-space conversion.
LS model is created from a set of submodels with named inputs and outputs (at least interconnection signals should be named), a set of summator created for example by SUMBLK commands and string cell arrays defining external inputs and outputs (see LSmodel_example.m). The model can be later modyfied by adding new submodels, removing submodels, adding/removing external inputs/outputs.
LS model supports specification of different signal types for each signal
------------------------------------------------------- | Signal Type | Abbreviation | Channel | ------------------------------------------------------- | Manipulated | MV | Input | | Measured Disturbances | MD | Input | | Unmeasured Disturbances | UD | Input | | Measured Outputs | MO | Output | | Unmeasured Outputs | UO | Output | | Internal Signal | X | -- | -------------------------------------------------------
and specification of signal limits (min/max values, min/max slopes,...). This information is later used for estimator and/or controller design.
LSmodel has methods for structured model order reduction, decomposition of subsystems into groups for distributed control/estimation and merging of information from multiple models into single one.
Model structure can be ploted by overloaded plot command and model analysis can be done by many standard overloaded functions (see bellow).
State-space model of full LSmodel can be obtained by SS method. Parts of model can be obtained either for selected inputs and outputs or by extracting group of subsystems, where grouping information may be a result of built-in decomposition method.
Methods
LSmodel - constructor, compatible with Matlab connect function
add_mod - adds submodel to LS model add_sum - adds summator (creates new internal signal) add_ext_inp - adds external input to LS model add_ext_out - adds external output from LS model rem_mod - removes submodel from LS model rem_sum - removes summator rem_ext_inp - removes external input rem_ext_out - removes external output
set_sig_type - signal types according to the MPC toolbox set_sig_lim - set signal limits (min/max, delta min/max) set_sig_data - assigns (user) data structure to selcted signal(s)
select - extracts part of the model for selected inputs and outputs group - extracts subsystems belonging to given group squeeze - remove unused external inputs/outputs and unconnected submodels
struct_red - structured model order reduction merge - merging of ARX models of different structure freq_uncert - return frequency uncertainty for ARX model eps - epsilon decomposition bbd - Border Block Diagonal decomposition
display - presents the model content and shows the numbering of subsystems, summators, inputs and outputs n - returns total order (sum of subsystems order) orders - returns subsystems orders plot - plots interaction between subsystems
Overloaded functions
dcgain, pole, zero, impulse, step, bode, nyquist, pzmap, iopzmap, ss, ...
Internal model structure
Internal model structure can be seen in the following figure. The signal names are:
w ... external inputs to LS model z ... external outputs from LS model u ... aggregated inputs to submodels y ... aggregated outputs from submodels
Submodels are stored in cell array M as state-space models. The original models supplied by the user are stored in cell array Morig. External model inputs are stored in string cell array Wnames and outputs in Znames. Static interconnections matrices Lzw,Lzy,Luw,Luy represent submodels mutual interconnections and submodel interconnections with external inputs and outputs. They are automatically computed after each model modification.
Contents
- LSmodel Constructor
- Remove Model
- Remove Summator
- Add Model
- Add Summator
- Remove External Input
- Add External Input
- Remove External Output
- Add External Output
- Display Object
- Return Global Model Order
- Return Orders of Subsystems
- Get Global SS Model
- Epsilon Decomposition
- Set Signal Type
- Set Signal Limits
- Set Signal Data
- Master Connection Matrix
- Extract model part for given external inputs and outputs
- Extract submodels belonging to given group
- Remove unused external inputs/outputs and submodels
- Structured Model Order Reduction
- Merging of uncertain models
- Frequency uncertainty of ARX model
LSmodel Constructor
LSMODEL( X1,...,Xn, INPUT_NAMES, OUTPUT_NAMES ) constructs large scale model by specifying a set of submodels, summators and a list of external input and output names. Internal connections are automatically created by matching signal names. Xi are models or summators (single or in a cell array). INPUT_NAMES and OUTPUT_NAMES are cell arrays of strings with external input and output names. Summators can be created by command SUMBLK. Examples:
mod = LSmodel(M,sum,{'fuel','demand'},{'pressure','flow'});
mod = LSmodel(M1,M2,M3,M4,sum1,sum2,{'fuel','demand'},{'pressure','flow'});
M is cell array of models (ss,tf,...) with named inputs and outputs. SUM is cell array of summators created by SUMBLK.
Constructor is compatible with standard CONNECT function. It is also possible to construct the model by using CONNECT compatible numeric indexing of inputs and outputs (see help on CONNECT). However, name based signal referencing will be prefered as numeric indexing may be confusing for large scale models.
Remove Model
REM_MOD(OBJ,PAR) removes model from large scale system. PAR is a vector of indexes or string cell array of model names to be deleted. (model indexes are shown by display function)
Remove Summator
REM_SUM(OBJ,PAR) removes summator from large scale system. PAR is the index or the name of the summator to be deleted. Summator indexes are shown by display function.
Add Model
ADD_MOD(OBJ,NEWM) adds new model NEWM to large scale model class and connects it according to the input / output names. NEWM can be a cell array of models.
Add Summator
ADD_SUM(OBJ,NEWS) adds new summator to the model and connects it according the input/output names. Numeric based interconnection is not possible. NEWS can be an array of summators.
Summator can be created by SUMBLK function.
Remove External Input
REM_EXT_INP(OBJ,PAR) Removes external input. PAR can be input index or its NAME.
Add External Input
ADD_EXT_INP(OBJ,NAME) adds external input named NAME.
Remove External Output
REM_EXT_OUT(OBJ,PAR) Removes external output. PAR can be output index or its NAME.
Add External Output
ADD_EXT_OUT(OBJ,NAME) adds external output named NAME.
Display Object
DISPLAY Displays basic information about LSmodel.
Return Global Model Order
N=N(OBJ) returns global model order as a sum of subsystem orders.
Return Orders of Subsystems
N=ORDERS(OBJ) returns orders of subsystems in array
Get Global SS Model
MOD=SS(obj) returns state space model of the whole model.
Epsilon Decomposition
EPS(OBJ,N_TARGET) finds \epsilon decomposition of water network model after leafs condensation. Decomposes the network to N_TARGET subnetworks.
Set Signal Type
SET_SIG_TYPE(OBJ,NAMES,TYPE) - set type of signals for MPC design. Signal types are compatible with MPC toolbox:
------------------------------------------------------- | Signal Type | Abbreviation | Channel | ------------------------------------------------------- | Manipulated | MV | Input | | Measured Disturbances | MD | Input | | Unmeasured Disturbances | UD | Input | | Measured Outputs | MO | Output | | Unmeasured Outputs | UO | Output | | Internal Signal | X | -- | -------------------------------------------------------
MODEL is name or index of submodel. SIGNALS is a cell of input names or their indexes and TYPE is abbreviation of signal type (MV,MD,UD).
Set Signal Limits
SET_SIG_LIM(OBJ,NAMES,MIN,MAX,DMIN,DMAX,SMIN,SMAX) sets MIN / MAX limits on absolute values, sets DMIN / DMAX limits on speed of change and sets SMIN / SMAX soft limits on absolute values. Limits are applied to signal(s) specified by name in NAMES
SET_SIG_LIM(OBJ,NAMES,MIN,MAX,DMIN,DMAX) sets MIN / MAX limits on absolute values and sets DMIN / DMAX limits on speed of change.
SET_SIG_LIM(OBJ,NAMES,MIN,MAX) sets MIN / MAX limits on absolute values.
SET_SIG_LIM(OBJ,NAMES) removes all limits (sets them to inf).
Set Signal Data
SET_SIG_DATA(OBJ,NAMES,DATA) assigns user data structure to signal(s) specified in NAMES.
Master Connection Matrix
[MZW,MZY,MUW,MUY] = MASTERL(OBJ) returns aggregated matrices indicating connection between external inputs, submodels and external outputs.
Extract model part for given external inputs and outputs
NOBJ = SELECT(OBJ,INPUTS,OUTPUTS) extracts part of the model for selected inputs and outputs. Submodels, which are not conotrllable or observable from selected inputs and outputs are not included in extracted model. INPUTS and OUTPUTS can be cell array of inputs/outputs signal names or their numerical index (see DISP).
NOBJ = SELECT(OBJ,INPUTS,OUTPUTS,OPT) parameter OPT controls, which submodels are kept and which are removed from final model:
'io' ........ eliminates submodels, which are not controllable and/or observable 'full' ...... keep all submodels 'ss' ........ (default) eliminates submodels which are not controllable and observable are removed
Extract submodels belonging to given group
NOBJ = GROUP(OBJ,GR_IND) extracts parts of LS model, where submodels belong to the group(s) specified in vector GR_IND.
Remove unused external inputs/outputs and submodels
NOBJ = SQUEEZE(OBJ) removes external inputs and outputs, which are not connected to any submodels and also removes submodels which are not connected anything.
Structured Model Order Reduction
OBJ = STRUCT_RED(OBJ,N_TARGET) ...
OBJ = STRUCT_RED(OBJ,N_TARGET,METHOD) ...
Based on: Henrik Sandberg, Richard M. Murray: "Model reduction of interconnected linear systems". Optimal Control, Applications and Methods, Special Issue on Directions, Applications, and Methods in Robust Control, 30:3, pp. 225--245, May/June 2009.
Merging of uncertain models
MERGE(OBJ,MOD,NEW_MOD,TARGET_NB,TARGET_NA) updates uncertain submodel by new model. Updated submodel is determined by its index or its name in variable MOD and new model is specified by NEW_MOD. This function supports so far only ARX models (IDARX or IDPOLY classes of submodels).
Frequency uncertainty of ARX model
[MEAN,VAR] = FREQ_UNCERT(OBJ,MOD,W) returns mean value and variation for model MOD on frequencies W. This function supports so far only ARX models (IDARX or IDPOLY classes of submodels).