1function tranSysState = sampleSysAggr(self, numSamples, markActivePassive)
2% TRANSYSSTATEAGGR = sampleSysAggr(NUMSAMPLES)
3options = self.getOptions;
5if GlobalConstants.DummyMode
10if nargin<2 %~exist(
'numSamples',
'var')
11 numSamples = options.samples;
15 markActivePassive = false;
19 case {
'default',
'serial'}
20 options.samples = numSamples;
23 options.method =
'serial'; % nrm does not support tran*
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;
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,:);
38 [~,tranSysState.state{isf}] = State.toMarginal(sn,sn.statefulToNode(isf),tranSysState.state{isf});
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);
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);
53 tranSysState.isaggregate = true;
55 line_error(mfilename,'sampleSys
is not available in SolverSSA with the chosen method.
');
59 apevent = cell(1,length(tranSysState.t)-1);
60 for ti = 1:length(apevent)
61 apevent{ti} = struct('active
',[],'passive
',[]);
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
68 apevent{ti}.passive = tranSysState.event{e};
70 apevent{ti}.active = tranSysState.event{e};
74 tranSysState.event = apevent';