LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_ssa_analyzer_serial.m
1function [XN,UN,QN,RN,TN,CN,tranSysState,tranSync,sn]=solver_ssa_analyzer_serial(sn, init_state, options, isHashed)
2% [XN,UN,QN,RN,TN,CN]=SOLVER_SSA_ANALYZER_SERIAL(SN, OPTIONS)
3
4M = sn.nstations; %number of stations
5K = sn.nclasses; %number of classes
6
7% istSpaceShift = zeros(1,M);
8% for i=1:M
9% if i==1
10% istSpaceShift(i) = 0;
11% else
12% istSpaceShift(i) = istSpaceShift(i-1) + size(sn.space{i-1},2);
13% end
14% end
15
16S = sn.nservers;
17NK = sn.njobs'; % initial population per class
18sched = sn.sched;
19Tstart = tic;
20
21PH = sn.proc;
22tranSysState = [];
23tranSync = [];
24
25XN = NaN*zeros(1,K);
26UN = NaN*zeros(M,K);
27QN = NaN*zeros(M,K);
28RN = NaN*zeros(M,K);
29TN = NaN*zeros(M,K);
30CN = NaN*zeros(1,K);
31
32
33options.samples = options.samples + 1;
34if isfield(options,'config') && isfield(options.config,'eventcache')
35 eventCache = EventCache.create(options.config.eventcache, sn);
36else
37 eventCache = EventCache.create(false, sn);
38end
39
40[probSysState,StateSpaceAggr,arvRates,depRates,tranSysState,tranSync] = solver_ssa(sn, init_state, options, eventCache);
41%%
42wset = 1:size(StateSpaceAggr,1);
43for k=1:K
44 refsf = sn.stationToStateful(sn.refstat(k));
45 XN(k) = probSysState*depRates(wset,refsf,k);
46end
47
48for ist=1:M
49 isf = sn.stationToStateful(ist);
50 for k=1:K
51 TN(ist,k) = probSysState*depRates(wset,isf,k);
52 QN(ist,k) = probSysState*StateSpaceAggr(wset,(ist-1)*K+k);
53 end
54 switch sched(ist)
55 case SchedStrategy.INF
56 for k=1:K
57 UN(ist,k) = QN(ist,k);
58 end
59 case {SchedStrategy.PS, SchedStrategy.DPS, SchedStrategy.GPS, ...
60 SchedStrategy.PSPRIO, SchedStrategy.DPSPRIO, SchedStrategy.GPSPRIO, SchedStrategy.LPS}
61 if isempty(sn.lldscaling) && isempty(sn.cdscaling) && ~sn_has_joint_dependence(sn)
62 for k=1:K
63 if ~isempty(PH{ist}{k})
64 UN(ist,k) = probSysState*arvRates(wset,isf,k)/sn.rates(ist,k)/S(ist);
65 end
66 end
67 else % lld/cd/ljd cases
68 ind = sn.stationToNode(ist);
69 UN(ist,1:K) = NaN;
70 % UN(i,1:K) = 0;
71 % for st = wset
72 % [ni,nir] = State.toMarginal(sn, ind, StateSpace(st,(istSpaceShift(i)+1):(istSpaceShift(i)+size(sn.space{i},2))));
73 % if ni>0
74 % for k=1:K
75 % UN(i,k) = UN(i,k) + probSysState(st)*nir(k)*sn.schedparam(i,k)/(nir*sn.schedparam(i,:)');
76 % end
77 % end
78 % end
79 end
80 otherwise
81 if isempty(sn.lldscaling) && isempty(sn.cdscaling) && ~sn_has_joint_dependence(sn)
82 for k=1:K
83 if ~isempty(PH{ist}{k})
84 UN(ist,k) = probSysState*arvRates(wset,isf,k)*map_mean(PH{ist}{k})/S(ist);
85 end
86 end
87 else % lld/cd/ljd cases
88 ind = sn.stationToNode(ist);
89 UN(ist,1:K) = NaN;
90 % UN(i,1:K) = 0;
91 % for st = wset
92 % [ni,~,sir] = State.toMarginal(sn, ind, StateSpace(st,(istSpaceShift(i)+1):(istSpaceShift(i)+size(sn.space{i},2))));
93 % if ni>0
94 % for k=1:K
95 % UN(i,k) = UN(i,k) + probSysState(st)*sir(k)/S(i);
96 % end
97 % end
98 % end
99 end
100 end
101end
102
103for k=1:K
104 for ist=1:M
105 if TN(ist,k)>0
106 RN(ist,k) = QN(ist,k)./TN(ist,k);
107 else
108 RN(ist,k)=0;
109 end
110 end
111 CN(k) = NK(k)./XN(k);
112end
113%%
114
115% now update the routing probabilities in nodes with state-dependent routing
116for k=1:K
117 for isf=1:sn.nstateful
118 if sn.nodetype(isf) == NodeType.Cache
119 ind = sn.statefulToNode(isf);
120 TNcache(isf,k) = probSysState*depRates(:,isf,k);
121 end
122 end
123end
124
125% updates cache actual hit and miss data
126for k=1:K
127 for isf=1:sn.nstateful
128 if sn.nodetype(isf) == NodeType.Cache
129 ind = sn.statefulToNode(isf);
130 if length(sn.nodeparam{ind}.hitclass)>=k
131 h = sn.nodeparam{ind}.hitclass(k);
132 m = sn.nodeparam{ind}.missclass(k);
133 if h==0 || m==0
134 sn.nodeparam{ind}.actualhitprob(k) = NaN;
135 sn.nodeparam{ind}.actualmissprob(k) = NaN;
136 else
137 sn.nodeparam{ind}.actualhitprob(k) = TNcache(isf,h)/sum(TNcache(isf,[h,m]));
138 sn.nodeparam{ind}.actualmissprob(k) = TNcache(isf,m)/sum(TNcache(isf,[h,m]));
139 end
140 end
141 end
142 end
143end
144
145QN(isnan(QN))=0;
146CN(isnan(CN))=0;
147RN(isnan(RN))=0;
148UN(isnan(UN))=0;
149XN(isnan(XN))=0;
150TN(isnan(TN))=0;
151end
Definition mmt.m:92