LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sampleSys.m
1function tranSysState = sampleSys(self, numEvents)
2% TRANSYSSTATE = SAMPLESYS(NUMSAMPLES)
3options = self.getOptions;
4options.force = true;
5if isempty(self.result) || ~isfield(self.result,'infGen')
6 runAnalyzer(self);
7end
8[infGen, eventFilt] = getGenerator(self);
9[stateSpace, localStateSpace] = getStateSpace(self);
10stateSpaceAggr = getStateSpaceAggr(self);
11
12sn = self.getStruct;
13initState = sn.state;
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));
18s0 = [];
19for isf=1:length(initState)
20 w = size(localStateSpace{isf},2);
21 spaceWidths(isf) = w;
22 s0 = [s0, zeros(1,w-length(initState{isf})), initState{isf}];
23end
24nst = cumsum([1,spaceWidths]);
25
26% set initial state
27pi0 = zeros(1,size(stateSpace,1));
28pi0(matchrow(stateSpace,s0))=1;
29
30% filter all CTMC events as a marked Markovian arrival process
31D1 = cellsum(eventFilt);
32D0 = infGen-D1;
33MMAP = mmap_normalize([{D0},{D1},eventFilt(:)']);
34
35% now sampel the MMAP
36[sjt,event,~,~,sts] = mmap_sample(MMAP,numEvents, pi0);
37
38sn = self.getStruct;
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));
44end
45
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);
51 end
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);
55 end
56end
57tranSysState.isaggregate = false;
58
59end
Definition Station.m:245