LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_mvaldmx.m
1%{
2%{
3 % @file pfqn_mvaldmx.m
4 % @brief Load-dependent MVA for mixed open/closed networks with limited load dependence.
5%}
6%}
7
8%{
9%{
10 % @brief Load-dependent MVA for mixed open/closed networks with limited load dependence.
11 % @fn pfqn_mvaldmx(lambda, D, N, Z, mu, S)
12 % @param lambda Arrival rate vector.
13 % @param D Service demand matrix.
14 % @param N Population vector.
15 % @param Z Think time vector.
16 % @param mu Load-dependent rate matrix.
17 % @param S Number of servers per station.
18 % @return XN System throughput.
19 % @return QN Mean queue lengths.
20 % @return UN Utilization.
21 % @return CN Cycle times.
22 % @return lGN Logarithm of normalizing constant.
23 % @return Pc Marginal queue-length probabilities.
24%}
25%}
26function [XN,QN,UN,CN,lGN,Pc] = pfqn_mvaldmx(lambda,D,N,Z,mu,S)
27% [XN,QN,UN,CN,lGN,Pc] = PFQN_MVALDMX(LAMBDA,D,N,Z,MU,S)
28
29if nargin<5
30 mu=ones(size(D,1),sum(N(isfinite(N))));
31 S=ones(size(D,1),1);
32end
33if size(mu,2) < sum(N(isfinite(N)))
34 line_error(mfilename,'MVALDMX requires to specify the load-dependent rates with one job more than the maximum closed population.');
35end
36if any(N(find(lambda))>0 & isfinite(N(find(lambda))))
37 line_error(mfilename,'Arrival rate cannot be specified on closed classes.');
38end
39[M,R] = size(D);
40openClasses = find(isinf(N));
41closedClasses = setdiff(1:length(N), openClasses);
42
43XN = zeros(1,R);
44UN = zeros(M,R);
45CN = zeros(M,R);
46QN = zeros(M,R);
47lGN = 0;
48mu(:,end+1) = mu(:,end); % we need up to sum(N)+1, but there is limited load dep
49[EC,E,Eprime] = pfqn_mvaldmx_ec(lambda,D,mu);
50C = length(closedClasses); % number of closed classes
51Dc = D(:,closedClasses);
52Nc = N(closedClasses);
53Zc = Z(closedClasses);
54prods = zeros(1,C); % needed for fast hashing
55for r=1:C
56 prods(r)=prod(Nc(1:r-1)+1);
57end
58% Start at nc=(0,...,0)
59nvec = pprod(Nc);
60% Initialize Pc
61Pc = zeros(M,1+sum(Nc),prod(1+Nc));
62x = zeros(C,prod(1+Nc));
63w = zeros(M,C,prod(1+Nc));
64for ist=1:M
65 Pc(ist, 1 + 0, hashpop(nvec,Nc,C,prods)) = 1.0;
66end
67u = zeros(M,C);
68% Population recursion
69while nvec>=0
70 hnvec = hashpop(nvec,Nc,C,prods);
71 nc = sum(nvec);
72 for ist=1:M
73 for c=1:C
74 if nvec(c)>0
75 hnvec_c = hashpop(oner(nvec,c),Nc,C,prods);
76 % Compute mean residence times
77 for n=1:nc
78 w(ist,c,hnvec) = w(ist,c,hnvec) + Dc(ist,c) * n * EC(ist,n) * Pc(ist, 1+(n-1), hnvec_c);
79 end
80 end
81 end
82 end
83 % Compute tput
84 for c=1:C
85 x(c,hnvec) = nvec(c) / (Zc(c)+sum(w(1:M,c,hnvec)));
86 end
87 for ist=1:M
88 for n=1:nc
89 for c=1:C
90 if nvec(c)>0
91 hnvec_c = hashpop(oner(nvec,c),Nc,C,prods);
92 Pc(ist, 1 + n, hnvec) = Pc(ist, 1 + n, hnvec) + Dc(ist,c) * EC(ist,n) * x(c,hnvec) * Pc(ist, 1+(n-1), hnvec_c);
93 end
94 end
95 end
96 Pc(ist, 1 + 0, hnvec) = max(eps,1-sum(Pc(ist, 1 + (1:nc), hnvec)));
97 end
98
99 % now compute the normalizing constant
100 last_nnz = find(nvec>0, 1, 'last' );
101 if sum(nvec(1:last_nnz-1)) == sum(Nc(1:last_nnz-1)) && sum(nvec((last_nnz+1):C))==0
102 logX = log(XN(last_nnz));
103 if ~isempty(logX)
104 lGN = lGN - logX;
105 end
106 end
107
108 nvec = pprod(nvec, Nc);
109end
110
111% compute performance indexes at Nc for closed classes
112hnvec = hashpop(Nc,Nc,C,prods);
113for c=1:C
114 hnvec_c = hashpop(oner(Nc,c),Nc,C,prods);
115 for ist=1:M
116 u(ist,c) = 0;
117 for n=1:sum(Nc) % closed class utilization
118 u(ist,c) = u(ist,c) + Dc(ist,c) * x(c,hnvec) * Eprime(ist,1+n-1) / E(ist,1+n-1) * Pc(ist, 1+n-1, hnvec_c);
119 end
120 end
121end
122
123% Throughput
124XN(closedClasses) = x(1:C,hnvec);
125% Utilization
126UN(1:M,closedClasses) = u(1:M,1:C);
127% Response time
128CN(1:M,closedClasses) = w(1:M,1:C,hnvec);
129% Queue-length
130QN(1:M,closedClasses) = repmat(XN(closedClasses),M,1) .* CN(1:M,closedClasses);
131
132% Compute performance indexes at Nc for open classes
133for r=openClasses
134 % Throughput
135 XN(r) = lambda(r);
136 for ist=1:M
137 % Queue-length
138 QN(ist,r) = 0;
139 for n=0:sum(Nc)
140 QN(ist,r) = QN(ist,r) + lambda(r) * D(ist,r) * (n+1) * EC(ist,n+1) * Pc(ist, 1+n, hnvec);
141 end
142 % Response time
143 CN(ist,r) = QN(ist,r) / lambda(r);
144 % Utilization - the formula from Bruell-Balbo-Ashfari does not
145 % match simulation, this appears to be simly lambda_r*D_{ir}
146 UN(ist,r) = 0;
147 for n=0:sum(Nc)
148 UN(ist,r) = UN(ist,r) + lambda(r) * Eprime(ist,1+n+1) / E(ist,1+n+1) * Pc(ist, 1+n, hnvec);
149 end
150 end
151end
152
153Pc = Pc(1:M,:,hnvec);
154end