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 total queue-length distribution,
8% i.e., P(n total jobs) summed over all class combinations.
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;
29
30state = sn.state{sn.stationToStateful(ist)};
31[~, nir, ~, ~] = State.toMarginal(sn, ist, state);
32
33openClasses = find(isinf(N));
34closedClasses = find(isfinite(N));
35logPnir = 0;
36
37% Product-form probability for open classes
38if ~isempty(openClasses)
39 U = self.result.Avg.U;
40 if sn.sched(ist) == SchedStrategy.INF
41 % Delay (infinite server): independent Poisson per class
42 for r = openClasses
43 if Q(ist,r) > 0
44 logPnir = logPnir + nir(r)*log(Q(ist,r)) - Q(ist,r) - gammaln(nir(r)+1);
45 elseif nir(r) > 0
46 logPnir = -Inf;
47 end
48 end
49 elseif sn.sched(ist) ~= SchedStrategy.EXT
50 % Queue station: multinomial-geometric product form
51 % P(n_1,...,n_R) = (1-rho) * n!/prod(n_r!) * prod(rho_r^n_r)
52 % where rho_r = U(ist,r) is per-server utilization
53 rho_total = sum(U(ist, openClasses));
54 n_total = sum(nir(openClasses));
55 if rho_total < 1
56 logPnir = logPnir + log(1 - rho_total) + gammaln(n_total + 1);
57 for r = openClasses
58 rho_r = U(ist, r);
59 if nir(r) > 0
60 if rho_r > 0
61 logPnir = logPnir + nir(r)*log(rho_r) - gammaln(nir(r)+1);
62 else
63 logPnir = -Inf;
64 end
65 end
66 end
67 else
68 logPnir = -Inf;
69 end
70 end
71end
72
73% Binomial approximation for closed classes
74% Rainer Schmidt, "An approximate MVA ...", PEVA 29:245-254, 1997.
75for r = closedClasses
76 logPnir = logPnir + nchoosekln(N(r),nir(r));
77 logPnir = logPnir + nir(r)*log(Q(ist,r)/N(r));
78 logPnir = logPnir + (N(r)-nir(r))*log(1-Q(ist,r)/N(r));
79end
80
81Pnir = real(exp(logPnir));
82end