4 % @brief Bard-Schweitzer Approximate Mean Value Analysis (MVA).
8function [XN,QN,UN,RN,it]=pfqn_bs(L,N,Z,tol,maxiter,QN0,type)
11 % @brief Bard-Schweitzer Approximate Mean Value Analysis (MVA).
12 % @fn pfqn_bs(L, N, Z, tol, maxiter, QN0, type)
13 % @param L Service demand matrix.
14 % @param N Population vector.
15 % @param Z Think time vector.
16 % @param tol Tolerance
for convergence.
17 % @param maxiter Maximum number of iterations.
18 % @param QN0 Initial guess
for queue lengths.
19 % @param type Scheduling strategy type (
default: PS).
20 % @return XN System throughput.
21 % @return QN Mean queue lengths.
22 % @return UN Utilization.
23 % @return RN Residence times.
24 % @return it Number of iterations performed.
27% [XN,QN,UN,RN]=PFQN_BS(L,N,Z,TOL,MAXITER,QN)
29if nargin<3%~exist(
'Z',
'var')
32if nargin<4%~exist(
'tol',
'var')
35if nargin<5%~exist('maxiter','var')
41if nargin<6 || isempty(QN0) %~exist('QN','var')
47 type = SchedStrategy.PS * ones(M,1);
56 % Empty class: it contributes no jobs anywhere. Without this
the
57 % Schweitzer term below evaluates QN*(N(r)-1)/N(r) = 0*(-Inf) = NaN,
58 % which then propagates to every other class through
the s~=r term,
59 % so a single empty class returns an all-NaN solution.
69 % 0 service demand at this station => this class does not visit
the current node
74 if type(ist) == SchedStrategy.FCFS
75 CN(ist,r) = CN(ist,r) + L(ist,s)*QN(ist,s);
77 CN(ist,r) = CN(ist,r) + L(ist,r)*QN(ist,s);
80 CN(ist,r) = CN(ist,r) + L(ist,r)*QN(ist,r)*(N(r)-1)/N(r);
84 XN(r) = N(r)/(Z(r)+sum(CN(:,r)));
88 QN(ist,r) = XN(r)*CN(ist,r);
93 UN(ist,r) = XN(r)*L(ist,r);
96 % Convergence
is measured on
the non-empty classes only: an empty class has
97 % QN = QN_1 = 0, and 0/0 = NaN would make
the test never fire.
99 if isempty(find(nz,1)) || max(max(abs(1-QN(:,nz)./QN_1(:,nz)))) < tol
103RN = QN ./ repmat(XN,M,1);
104RN(:,N==0) = 0; % 0/0 for an empty class; its residence time
is 0, not NaN