LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sampleSysAggr.m
1function tranSysState = sampleSysAggr(self, numEvents)
2% TRANSYSSTATE = SAMPLESYSAGGR(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. 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));
21s0 = [];
22for isf=1:length(initState)
23 w = size(localStateSpace{isf},2);
24 spaceWidths(isf) = w;
25 s0 = [s0, zeros(1,w-length(initState{isf})), initState{isf}];
26end
27nst = cumsum([1,spaceWidths]);
28
29% set initial state
30pi0 = zeros(1,size(stateSpace,1));
31pi0(matchrow(stateSpace,s0))=1;
32
33% filter all CTMC events as a marked Markovian arrival process
34D1 = cellsum(eventFilt);
35D0 = infGen-D1;
36MMAP = mmap_normalize([{D0},{D1},eventFilt(:)']);
37
38% now sampel the MMAP
39[sjt,event,~,~,sts] = mmap_sample(MMAP,numEvents, pi0);
40
41sn = self.getStruct;
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});
48end
49
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);
55 end
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);
59 end
60end
61tranSysState.isaggregate = true;
62end
Definition Station.m:245