Home > m > timetools > statespacefunctions > utp_ltpda_ss_random_generate.m

utp_ltpda_ss_random_generate

PURPOSE ^

utp_ltpda_ss_random_generate subfunction generates a random system

SYNOPSIS ^

function varargout = utp_ltpda_ss_random_generate(varargin)

DESCRIPTION ^

 utp_ltpda_ss_random_generate subfunction generates a random system
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: utp_ltpda_ss_random_generate subfunction generates randomly
 a p-th system out of nSysTot systems, with nUTot exogenous inputs,
 nSysTot possible 'inner' inputs, OutputSizes and InputSizes neing the
 respective sizes of the output sizes of the pSys systems and sizes of the
 nUTot input streams.

 CALL: utp_ltpda_ss_random_generate

 INPUTS: none

 OUTPUTS: 1/0

 ***** THERE ARE NO DEFAULT PARAMETERS *****

 VERSION: $Id: utp_ltpda_ss_random_generate.m,v 1.3 2008/02/26 20:18:19 adrien Exp $

 HISTORY: 22-01-2008 A Grynagier

 TO DO : Nothing
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = utp_ltpda_ss_random_generate(varargin)
0002 % utp_ltpda_ss_random_generate subfunction generates a random system
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % DESCRIPTION: utp_ltpda_ss_random_generate subfunction generates randomly
0006 % a p-th system out of nSysTot systems, with nUTot exogenous inputs,
0007 % nSysTot possible 'inner' inputs, OutputSizes and InputSizes neing the
0008 % respective sizes of the output sizes of the pSys systems and sizes of the
0009 % nUTot input streams.
0010 %
0011 % CALL: utp_ltpda_ss_random_generate
0012 %
0013 % INPUTS: none
0014 %
0015 % OUTPUTS: 1/0
0016 %
0017 % ***** THERE ARE NO DEFAULT PARAMETERS *****
0018 %
0019 % VERSION: $Id: utp_ltpda_ss_random_generate.m,v 1.3 2008/02/26 20:18:19 adrien Exp $
0020 %
0021 % HISTORY: 22-01-2008 A Grynagier
0022 %
0023 % TO DO : Nothing
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 ALGONAME = mfilename;
0027 VERSION =  '$Id: utp_ltpda_ss_random_generate.m,v 1.3 2008/02/26 20:18:19 adrien Exp $';
0028 CATEGORY = 'STATESPACE';
0029 display(['starting ' ALGONAME]);
0030 
0031 if length(varargin) >0
0032     if isequal( varargin{1}, 'Version')
0033         varargout = VERSION;
0034         return;
0035     elseif isequal(varargin{1}, 'Params')
0036         varargout = plist();
0037         return;
0038     elseif isequal(varargin{1}, 'Category')
0039         varargout = CATEGORY;
0040         return;
0041     end
0042 end
0043 
0044 nSysTot = varargin{1};
0045 pSys = varargin{2};
0046 nUTot = varargin{3};
0047 OutputSizes = varargin{4};
0048 InputSizes = varargin{5};
0049 
0050 
0051 TYPE = 'SUBSYSTEM';
0052 NAME = ['Y_', num2str(pSys)];
0053 INPUTNAMES = {};
0054 NBINPUTS_exo = floor((nUTot+1)*rand);
0055 NBINPUTS_in = floor((nSysTot+1)*rand);
0056 NBINPUTS = NBINPUTS_exo + NBINPUTS_in ;
0057 InputsexoVals = ones(NBINPUTS_exo,1) + floor(nUTot*rand(NBINPUTS_exo,1));
0058 InputsInVals = ones(NBINPUTS_in,1) + floor(nSysTot*rand(NBINPUTS_in,1));
0059 for i=1:NBINPUTS_exo
0060     INPUTNAMES = [INPUTNAMES ['U_',num2str(InputsexoVals(i))]];
0061 end
0062 for i=1:NBINPUTS_in
0063     INPUTNAMES = [INPUTNAMES ['Y_',num2str(InputsInVals(i))]];
0064 end
0065 INPUTISUSED = floor(2*rand(NBINPUTS,1));
0066 %time representation for the matrices, given by the timestep for discrete
0067 %case and by a 0 for a time continuous representation
0068 TIMESTEP = 0;  %to be randomized !!!
0069 %declaration of the symbollic variables TO CHANGE AND LOAD DATA FROM A
0070 %PLIST (WRITE FUNCTION TO *MODIFY* THE PLIST SEPARATELY)
0071 NBPARAMS = floor(10*rand);
0072 PARAMNAMES = cell(NBPARAMS,1);
0073 PARAMVALUES = randn(NBPARAMS,1);
0074 PARAMSIGMAS = rand(NBPARAMS,1);
0075 for i=1:NBPARAMS
0076     PARAMNAMES{i} = ['Param_Y', num2str(pSys),'_',num2str(i)];
0077 end
0078 %declaring the symbolic variables
0079 for indice=1:length(PARAMNAMES)
0080     declaration = [  eval(['PARAMNAMES{', num2str(indice),  '}']) , '=sym( ''', eval(['PARAMNAMES{' , num2str(indice), '}']) , ''');'];
0081     eval(declaration);
0082 end
0083 %Making sure no reserved parameter is used
0084 for i=1:length(PARAMNAMES)
0085     if ( (isequal(PARAMNAMES{i},'z')==1) || (isequal(PARAMNAMES{i},'t')==1) || (isequal(PARAMNAMES{i},'T')==1) || (isequal(PARAMNAMES{i},'s')==1) )
0086         msg = ['wrong (reserved for time/frequency) name for variable "',  PARAMNAMES{i}, '" in MatModel from file : ', NAME];
0087         error(msg)
0088     end
0089 end
0090 %Size of state space
0091 nss = floor(abs(2*randn(1)));
0092 A = randn(nss,nss);
0093 C = rand(OutputSizes(pSys),nss);
0094 AMAT = {A};
0095 CMAT = {C};
0096 BMATS = cell(NBINPUTS,1);
0097 DMATS = cell(NBINPUTS,1);
0098 for i=1:NBINPUTS_exo
0099     BMATS{i} = rand(nss,InputSizes(InputsexoVals(i)));
0100     DMATS{i} = rand(OutputSizes(pSys),InputSizes(InputsexoVals(i)));
0101 end
0102 for i=1:NBINPUTS_in
0103     BMATS{i+NBINPUTS_exo} = rand(nss,OutputSizes(InputsInVals(i)));
0104     DMATS{i+NBINPUTS_exo} = rand(OutputSizes(pSys),OutputSizes(InputsInVals(i)));
0105 end
0106 INPUTSIZES = zeros(length(BMATS),1);
0107 for i=1:length(BMATS)
0108     INPUTSIZES(i)= size(BMATS{i},2);
0109 end
0110 XISOUTPUT=floor(2*rand);
0111 YISOUTPUT=floor(2*rand);
0112 XINI = rand(nss,1);
0113 
0114 syst = plist('TYPE', TYPE ,'NAME', NAME ,'TIMESTEP', TIMESTEP , ...
0115     'XISOUTPUT',XISOUTPUT,'YISOUTPUT',YISOUTPUT,'XINI', XINI , ...
0116     'PARAMNAMES', PARAMNAMES ,'PARAMVALUES', PARAMVALUES ,'PARAMSIGMAS', PARAMSIGMAS ,...
0117     'NBINPUTS', NBINPUTS ,'INPUTNAMES', INPUTNAMES ,'INPUTSIZES', INPUTSIZES , 'INPUTISUSED', INPUTISUSED ,...
0118     'AMAT', AMAT ,'BMATS', BMATS ,'CMAT', CMAT ,'DMATS', DMATS );
0119 %making content tests on the subsystem
0120 ltpda_ss_check(syst);
0121 %erasing useless fields
0122 clear A B C D E F PARAMNAMES PARAMVALUES PARAMSIGMAS
0123 %Saving the workspace in the file named "subsystem_GENERATE_workspaceGenerated".
0124 % filename = [mfilename,'_workspaceGenerated'];
0125 % save(filename);
0126 varargout = {syst};
0127 end

Generated on Fri 07-Mar-2008 15:46:43 by m2html © 2003