comparison m-toolbox/classes/@smodel/simplify.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 % SIMPLIFY implements simplify operator for smodel objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SIMPLIFY implements simplify operator for smodel objects.
5 %
6 % CALL: objs = simplify(mdls)
7 %
8 % <a href="matlab:utils.helper.displayMethodInfo('smodel', 'simplify')">Parameters Description</a>
9 %
10 % VERSION: $Id: simplify.m,v 1.10 2011/04/08 08:56:30 hewitson Exp $
11 %
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13
14 function varargout = simplify(varargin)
15
16 % Settings
17 operatorName = 'simplify';
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 % Check if the method was called by another method
26 callerIsMethod = utils.helper.callerIsMethod;
27
28 % Collect input variable names
29 in_names = cell(size(varargin));
30 for ii = 1:nargin,in_names{ii} = inputname(ii);end
31
32 % Collect all smodels and plists
33 [as, smodel_invars, rest] = utils.helper.collect_objects(varargin(:), 'smodel', in_names);
34 [pl, pl_invars, rest] = utils.helper.collect_objects(rest(:), 'plist', in_names);
35
36 % Decide on a deep copy or a modify
37 mdls = copy(as, nargout);
38
39 % Combine input plists and default PLIST
40 pl = parse(pl, getDefaultPlist());
41
42 % If the method was called by another method, we do not need to set history.
43 % As such, the info object can be empty
44 if callerIsMethod
45 infoObj = [];
46 else
47 infoObj = getInfo('None');
48 end
49
50 % Apply the method to all models
51 mdls.sop(callerIsMethod, smodel_invars, operatorName, {}, pl, infoObj);
52
53 % Set output
54 varargout{1} = mdls;
55
56 end
57
58 %--------------------------------------------------------------------------
59 % Get Info Object
60 %--------------------------------------------------------------------------
61 function ii = getInfo(varargin)
62
63 if nargin == 1 && strcmpi(varargin{1}, 'None')
64 sets = {};
65 pls = [];
66 else
67 sets = {'Default'};
68 pls = getDefaultPlist();
69 end
70 % Build info object
71 ii = minfo(mfilename, 'smodel', 'ltpda', utils.const.categories.op, '$Id: simplify.m,v 1.10 2011/04/08 08:56:30 hewitson Exp $', sets, pls);
72 end
73
74 %--------------------------------------------------------------------------
75 % Get Default Plist
76 %--------------------------------------------------------------------------
77 function plout = getDefaultPlist()
78 persistent pl;
79 if ~exist('pl', 'var') || isempty(pl)
80 pl = buildplist();
81 end
82 plout = pl;
83 end
84
85 function pl = buildplist()
86 pl = plist.EMPTY_PLIST;
87 end
88
89