LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sampleAggr.m
1function stationStateAggr = sampleAggr(self, node, numSamples, markActivePassive)
2% SAMPLE = SAMPLEAGGR(NODE, NUMSAMPLES)
3
4if GlobalConstants.DummyMode
5 stationStateAggr = NaN;
6 return
7end
8
9if nargin<2 %~exist('node','var')
10 line_error(mfilename,'sampleAggr requires to specify a station.');
11end
12
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.');
15%end
16
17options = self.getOptions;
18switch options.method
19 case {'default','serial'}
20 options.samples = numSamples;
21 options.force = true;
22 options.method = 'serial'; % nrm does not support tran*
23 [~, tranSystemState, event] = self.runAnalyzer(options);
24 sn = self.getStruct;
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;
31 sn = self.getStruct;
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);
37 end
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);
41 end
42 end
43 stationStateAggr.isaggregate = true;
44 otherwise
45 line_error(mfilename,'sampleAggr is not available in SolverSSA with the chosen method.');
46end
47%stationStateAggr.t = [0; stationStateAggr.t(2:end)];
48if markActivePassive
49 apevent = cell(1,length(stationStateAggr.t)-1);
50 for ti = 1:length(apevent)
51 apevent{ti} = struct('active',[],'passive',[]);
52 end
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
57 case EventType.ARV
58 apevent{ti}.passive = stationStateAggr.event{e};
59 otherwise
60 apevent{ti}.active = stationStateAggr.event{e};
61 end
62 end
63 end
64 stationStateAggr.event = apevent';
65end
66end