LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getProbAggr.m
1function [Pnir,logPnir] = getProbAggr(self, ist)
2% [PNIR,LOGPNIR] = GETPROBAGGR(IST)
3%
4% Probability of a SPECIFIC per-class job distribution at a station.
5% Returns P(n1 jobs of class 1, n2 jobs of class 2, ...) for current state.
6%
7% Compare with getProbMarg: returns queue-length distribution for a
8% single class, i.e., P(n jobs of class r) for n=0,1,...,N(r).
9%
10% Input:
11% ist - Station index
12%
13% Output:
14% Pnir - Scalar probability in [0,1]
15% logPnir - Log probability for numerical stability
16
17if nargin<2 %~exist('ist','var')
18 line_error(mfilename,'getProbAggr requires to pass a parameter the station of interest.');
19end
20sn = self.getStruct;
21if ist > sn.nstations
22 line_error(mfilename,'Station number exceeds the number of stations in the model.');
23end
24if isempty(self.result)
25 self.run;
26end
27Q = self.result.Avg.Q;
28N = sn.njobs;
29if all(isfinite(N))
30 switch self.options.method
31 case 'exact'
32 line_error(mfilename,'Exact marginal state probabilities not available yet in SolverMVA.');
33 otherwise
34 state = sn.state{sn.stationToStateful(ist)};
35 [~, nir, ~, ~] = State.toMarginal(sn, ist, state);
36 % Binomial approximation with mean fitted to queue-lengths.
37 % Rainer Schmidt, "An approximate MVA ...", PEVA 29:245-254, 1997.
38 logPnir = 0;
39 for r=1:size(nir,2)
40 logPnir = logPnir + nchoosekln(N(r),nir(r));
41 logPnir = logPnir + nir(r)*log(Q(ist,r)/N(r));
42 logPnir = logPnir + (N(r)-nir(r))*log(1-Q(ist,r)/N(r));
43 end
44 Pnir = real(exp(logPnir));
45 end
46else
47 line_error(mfilename,'getProbAggr not yet implemented for models with open classes.');
48end
49end