1function tranSysState = sampleSysAggr(self, numEvents)
2% TRANSYSSTATE = SAMPLESYSAGGR(NUMSAMPLES)
3options = self.getOptions;
5if isempty(self.result) || ~isfield(self.result,
'infGen')
8[infGen, eventFilt] = getGenerator(self);
9[stateSpace, localStateSpace] = getStateSpace(self);
10stateSpaceAggr = getStateSpaceAggr(self);
14% Pad each stateful node's initial state (compact representation) with
15% leading zeros up to
the enumerated per-node state-space width, so that
16% s0 lines up
column-wise with
the joint stateSpace. Phase-type stations
17% (e.g. Erlang/Coxian service) enumerate phase-augmented rows that are much
18% wider than
the compact initial state, so an unpadded concatenation would
19% not match any stateSpace row. Mirrors solver_ctmc_transient_analyzer.
20spaceWidths = zeros(1,length(initState));
22for isf=1:length(initState)
23 w = size(localStateSpace{isf},2);
25 s0 = [s0, zeros(1,w-length(initState{isf})), initState{isf}];
27nst = cumsum([1,spaceWidths]);
30pi0 = zeros(1,size(stateSpace,1));
31pi0(matchrow(stateSpace,s0))=1;
33% filter all CTMC events as a marked Markovian arrival process
34D1 = cellsum(eventFilt);
36MMAP = mmap_normalize([{D0},{D1},eventFilt(:)
']);
39[sjt,event,~,~,sts] = mmap_sample(MMAP,numEvents, pi0);
42tranSysState = struct();
43tranSysState.handle = self.model.getStatefulNodes';
44tranSysState.t = cumsum([0,sjt(1:end-1)
']');
45for isf=1:length(initState)
46 tranSysState.state{isf} = stateSpace(sts,(nst(isf):nst(isf+1)-1));
47 [~,tranSysState.state{isf}] = State.toMarginal(sn,sn.statefulToNode(isf),tranSysState.state{isf});
50tranSysState.event = {};
51for e = 1:length(event)
52 for a=1:length(sn.sync{event(e)}.active)
53 tranSysState.event{end+1} = sn.sync{event(e)}.active{a};
54 tranSysState.event{end}.t = tranSysState.t(e);
56 for p=1:length(sn.sync{event(e)}.passive)
57 tranSysState.event{end+1} = sn.sync{event(e)}.passive{p};
58 tranSysState.event{end}.t = tranSysState.t(e);
61tranSysState.isaggregate =
true;