1function stationStateAggr = sampleAggr(self, node, numSamples, markActivePassive)
2% SAMPLE = SAMPLEAGGR(NODE, NUMSAMPLES)
4if GlobalConstants.DummyMode
5 stationStateAggr = NaN;
9if nargin<2 %~exist(
'node',
'var')
10 line_error(mfilename,'sampleAggr requires to specify a station.');
13%if exist('numsamples','var')
14 %line_warning(mfilename,'SolveSSA does not support the numsamples parameter, use instead the samples option upon instantiating the solver.');
17options = self.getOptions;
19 case {
'default',
'serial'}
20 options.samples = numSamples;
22 options.method =
'serial'; % nrm does not support tran*
23 [~, tranSystemState, event] = self.runAnalyzer(options);
25 isf = sn.nodeToStateful(node.index);
26 [~,nir]=State.toMarginal(sn,sn.statefulToNode(isf),tranSystemState{1+isf});
27 stationStateAggr =
struct();
28 stationStateAggr.handle = node;
29 stationStateAggr.t = tranSystemState{1};
30 stationStateAggr.state = nir;
32 stationStateAggr.event = {};
33 for e = 1:length(event)
34 for a=1:length(sn.sync{event(e)}.active)
35 stationStateAggr.event{end+1} = sn.sync{event(e)}.active{a};
36 stationStateAggr.event{end}.t = stationStateAggr.t(e);
38 for p=1:length(sn.sync{event(e)}.passive)
39 stationStateAggr.event{end+1} = sn.sync{event(e)}.passive{p};
40 stationStateAggr.event{end}.t = stationStateAggr.t(e);
43 stationStateAggr.isaggregate =
true;
45 line_error(mfilename,
'sampleAggr is not available in SolverSSA with the chosen method.');
47%stationStateAggr.t = [0; stationStateAggr.t(2:end)];
49 apevent = cell(1,length(stationStateAggr.t)-1);
50 for ti = 1:length(apevent)
51 apevent{ti} =
struct(
'active',[],
'passive',[]);
53 for e=1:length(stationStateAggr.event)
54 ti = find(stationStateAggr.event{e}.t == stationStateAggr.t);
55 if ~isempty(ti) && ti<length(stationStateAggr.t)
56 switch stationStateAggr.event{e}.event
58 apevent{ti}.passive = stationStateAggr.event{e};
60 apevent{ti}.active = stationStateAggr.event{e};
64 stationStateAggr.event = apevent
';