1function tranSysState = sampleSys(self, numEvents)
2% TRANSYSSTATE = SAMPLESYS(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 (see sampleSysAggr).
17spaceWidths = zeros(1,length(initState));
19for isf=1:length(initState)
20 w = size(localStateSpace{isf},2);
22 s0 = [s0, zeros(1,w-length(initState{isf})), initState{isf}];
24nst = cumsum([1,spaceWidths]);
27pi0 = zeros(1,size(stateSpace,1));
28pi0(matchrow(stateSpace,s0))=1;
30% filter all CTMC events as a marked Markovian arrival process
31D1 = cellsum(eventFilt);
33MMAP = mmap_normalize([{D0},{D1},eventFilt(:)
']);
36[sjt,event,~,~,sts] = mmap_sample(MMAP,numEvents, pi0);
39tranSysState = struct();
40tranSysState.handle = self.model.getStatefulNodes';
41tranSysState.t = cumsum([0,sjt(1:end-1)
']');
42for isf=1:length(initState)
43 tranSysState.state{isf} = stateSpace(sts,(nst(isf):nst(isf+1)-1));
46tranSysState.event = {};
47for e = 1:length(event)
48 for a=1:length(sn.sync{event(e)}.active)
49 tranSysState.event{end+1} = sn.sync{event(e)}.active{a};
50 tranSysState.event{end}.t = tranSysState.t(e);
52 for p=1:length(sn.sync{event(e)}.passive)
53 tranSysState.event{end+1} = sn.sync{event(e)}.passive{p};
54 tranSysState.event{end}.t = tranSysState.t(e);
57tranSysState.isaggregate =
false;