1function [Pi_t, SSnode_a] = getTranProbAggr(self, node)
2% [PI_T, SSNODE_A] = GETTRANPROBAGGR(NODE)
4% Empirical transient probability of per-
class aggregate states at a station,
5% estimated from iter_max independent JMT replications.
8% Pi_t - [t, pi_t] where pi_t(k,j) = empirical fraction of replications
9% whose aggregate state at the requested node at time t(k) equals
11% SSnode_a - Unique aggregate state vectors observed at NODE across all
12% replications and time points (sorted, one row per state, one
14if GlobalConstants.DummyMode
19options = self.getOptions;
20initSeed = self.options.seed;
21if isfield(options,
'timespan') && isfinite(options.timespan(2))
23 ist = sn.nodeToStation(node.index);
25 line_error(mfilename,'getTranProbAggr in SolverJMT requires the input node to be a station.');
27 if sn.nodetype(node.index) == NodeType.Source
28 line_error(mfilename,'getTranProbAggr in SolverJMT does not apply to Source
nodes.');
32 TranSysStateAggr = cell(options.iter_max,1);
33 for it=1:options.iter_max
34 self.options.seed = initSeed + it - 1;
35 TranSysStateAggr{it} = self.sampleSysAggr;
36 tu =
union(tu, TranSysStateAggr{it}.t);
38 self.options.seed = initSeed; % restore in
case of interruption
41 iterMax = options.iter_max;
42 nclasses = sn.nclasses;
44 % interpolate per-station state onto
union grid for the requested station
45 nodeStates = NaN(nT, nclasses, iterMax);
47 tit = TranSysStateAggr{it}.t;
48 block = TranSysStateAggr{it}.state{ist};
49 if isempty(block) || isempty(tit) || any(isinf(block(:)))
52 nodeStates(:,:,it) = interp1(tit, block, tu,
'previous');
55 % flatten to (nT*iterMax) x nclasses, drop rows with any NaN, take unique
56 flat = reshape(permute(nodeStates,[1,3,2]), nT*iterMax, nclasses);
57 validMask = ~any(isnan(flat),2);
58 SSnode_a = unique(flat(validMask,:),
'rows');
59 nStates = size(SSnode_a,1);
61 % empirical fraction at each time point
62 pi_t = zeros(nT, nStates);
65 block = nodeStates(:,:,it);
66 [~, idx] = ismember(block, SSnode_a,
'rows');
69 pi_t(t_idx, idx(t_idx)) = pi_t(t_idx, idx(t_idx)) + 1;
73 pi_t = pi_t / iterMax;
78 line_error(mfilename,
'getTranProbAggr in SolverJMT requires to specify a finite timespan T, e.g., SolverJMT(model,''timespan'',[0,T]).');