LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sampleSysAggr.m
1function tranSysState = sampleSysAggr(self, numSamples, markActivePassive)
2% TRANSYSSTATEAGGR = sampleSysAggr(NUMSAMPLES)
3options = self.getOptions;
4
5if GlobalConstants.DummyMode
6 tranSysState = NaN;
7 return
8end
9
10if nargin<2 %~exist('numSamples','var')
11 numSamples = options.samples;
12end
13
14if nargin<3
15 markActivePassive = false;
16end
17
18switch options.method
19 case {'default','serial'}
20 options.samples = numSamples;
21 options.force = true;
22 sn = self.getStruct;
23 options.method = 'serial'; % nrm does not support tran*
24
25 [~, tranSystemState, tranSync] = self.runAnalyzer(options);
26 tranSysState = struct();
27 tranSysState.handle = self.model.getStatefulNodes';
28 tranSysState.t = tranSystemState{1};
29 tranSysState.state = {tranSystemState{2:end}};
30 tranSysState.event = tranSync;
31 event = tranSync;
32
33 for isf=1:sn.nstateful
34 if size(tranSysState.state{isf},1) > numSamples
35 tranSysState.t = tranSystemState(1:numSamples);
36 tranSysState.state{isf} = tranSysState.state{isf}(1:numSamples,:);
37 end
38 [~,tranSysState.state{isf}] = State.toMarginal(sn,sn.statefulToNode(isf),tranSysState.state{isf});
39 end
40
41 sn = self.getStruct;
42 tranSysState.event = {};
43 for e = 1:length(event)
44 for a=1:length(sn.sync{event(e)}.active)
45 tranSysState.event{end+1} = sn.sync{event(e)}.active{a};
46 tranSysState.event{end}.t = tranSysState.t(e);
47 end
48 for p=1:length(sn.sync{event(e)}.passive)
49 tranSysState.event{end+1} = sn.sync{event(e)}.passive{p};
50 tranSysState.event{end}.t = tranSysState.t(e);
51 end
52 end
53 tranSysState.isaggregate = true;
54 otherwise
55 line_error(mfilename,'sampleSys is not available in SolverSSA with the chosen method.');
56end
57
58if markActivePassive
59 apevent = cell(1,length(tranSysState.t)-1);
60 for ti = 1:length(apevent)
61 apevent{ti} = struct('active',[],'passive',[]);
62 end
63 for e=1:length(tranSysState.event)
64 ti = find(tranSysState.event{e}.t == tranSysState.t);
65 if ~isempty(ti) && ti<length(tranSysState.t)
66 switch tranSysState.event{e}.event
67 case EventType.ARV
68 apevent{ti}.passive = tranSysState.event{e};
69 otherwise
70 apevent{ti}.active = tranSysState.event{e};
71 end
72 end
73 end
74 tranSysState.event = apevent';
75end
76end