comparison m-toolbox/classes/@ssm/sMinReal.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % SMINREAL gives a minimal realization of a ssm object by deleting unreached states
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SMINREAL gives a minimal realization of a ssm object by
5 % deleting unreached states (! this is not always the minimal realization)
6 %
7 % CALL: >> sys = sMinReal(sys);
8 %
9 % sys - an array of ssm object
10 %
11 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'sMinReal')">Parameters Description</a>
12 %
13 % VERSION: $Id: sMinReal.m,v 1.14 2011/04/08 08:56:23 hewitson Exp $
14 %
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
17 function varargout = sMinReal(varargin)
18
19 %% Check if this is a call for parameters
20 if utils.helper.isinfocall(varargin{:})
21 varargout{1} = getInfo(varargin{3});
22 return
23 end
24
25 %% send starting message
26 import utils.const.*
27 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
28
29 %% collecting input
30 in_names = cell(size(varargin));
31 for ii = 1:nargin,in_names{ii} = inputname(ii);end
32
33 [sys, ssm_invars] = utils.helper.collect_objects(varargin(:), 'ssm', in_names);
34
35 pl_user = plist;
36
37 internal = strcmp(varargin{end}, 'internal');
38
39 sys = copy(sys, nargout);
40
41 %% begin function body
42 for i_sys=1:numel(sys)
43 if ~sys(i_sys).isnumerical
44 error('system should be numeric')
45 end
46 [A, B, C] = double(sys(i_sys), plist);
47 x_control = isreached(A,B);
48 x_sensing = isreached(A.',C.');
49 x = logical(min(x_control, x_sensing));
50 positions = ssm.blockMatRecut(x,sys(i_sys).sssizes, 1);
51
52 options = plist('inputs','ALL','outputs','ALL', 'states', positions);
53 sys(i_sys).doSimplify(options);
54 if ~internal
55 % append history step
56 sys(i_sys).addHistory(getInfo('None'), pl_user, ssm_invars(i_sys), sys(i_sys).hist);
57 end
58 end
59 if nargout == numel(sys)
60 for ii = 1:numel(sys)
61 varargout{ii} = sys(ii);
62 end
63 else
64 varargout{1} = sys;
65 end
66
67 end
68
69 function x = isreached(A,B)
70 Alog = double(~(A==0));
71 Blog = double(~(B==0));
72 Nss = size(B,1);
73 Nin = size(B,2);
74 x = zeros(Nss, 1);
75 for i =0:Nss
76 Ai = Alog^i;
77 for j=1:Nin
78 xloc = Ai*Blog(:,j);
79 xloc = double(~(xloc==0));
80 x = max(x, xloc);
81 end
82 end
83 end
84
85
86 %--------------------------------------------------------------------------
87 % Get Info Object
88 %--------------------------------------------------------------------------
89 function ii = getInfo(varargin)
90
91 if nargin == 1 && strcmpi(varargin{1}, 'None')
92 sets = {};
93 pl = [];
94 else
95 sets = {'Default'};
96 pl = getDefaultPlist;
97 end
98 % Build info object
99 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.op, '$Id: sMinReal.m,v 1.14 2011/04/08 08:56:23 hewitson Exp $', sets, pl);
100 end
101
102 %--------------------------------------------------------------------------
103 % Get Default Plist
104 %--------------------------------------------------------------------------
105 function plo = getDefaultPlist()
106 plo = plist;
107 end
108