LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_bs.m
1%{
2%{
3 % @file pfqn_bs.m
4 % @brief Bard-Schweitzer Approximate Mean Value Analysis (MVA).
5%}
6%}
7
8function [XN,QN,UN,RN,it]=pfqn_bs(L,N,Z,tol,maxiter,QN0,type)
9%{
10%{
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.
25%}
26%}
27% [XN,QN,UN,RN]=PFQN_BS(L,N,Z,TOL,MAXITER,QN)
28
29if nargin<3%~exist('Z','var')
30 Z=0*N;
31end
32if nargin<4%~exist('tol','var')
33 tol = 1e-6;
34end
35if nargin<5%~exist('maxiter','var')
36 maxiter = 1000;
37end
38
39[M,R]=size(L);
40CN=zeros(M,R);
41if nargin<6 || isempty(QN0) %~exist('QN','var')
42 QN = repmat(N,M,1)/M;
43else
44 QN = QN0;
45end
46if nargin<7
47 type = SchedStrategy.PS * ones(M,1);
48end
49
50XN=zeros(1,R);
51UN=zeros(M,R);
52for it=1:maxiter
53 QN_1 = QN;
54 for r=1:R
55 for ist=1:M
56 CN(ist,r) = L(ist,r);
57 if L(ist,r) == 0
58 % 0 service demand at this station => this class does not visit the current node
59 continue;
60 end
61 for s=1:R
62 if s~=r
63 if type(ist) == SchedStrategy.FCFS
64 CN(ist,r) = CN(ist,r) + L(ist,s)*QN(ist,s);
65 else
66 CN(ist,r) = CN(ist,r) + L(ist,r)*QN(ist,s);
67 end
68 else
69 CN(ist,r) = CN(ist,r) + L(ist,r)*QN(ist,r)*(N(r)-1)/N(r);
70 end
71 end
72 end
73 XN(r) = N(r)/(Z(r)+sum(CN(:,r)));
74 end
75 for r=1:R
76 for ist=1:M
77 QN(ist,r) = XN(r)*CN(ist,r);
78 end
79 end
80 for r=1:R
81 for ist=1:M
82 UN(ist,r) = XN(r)*L(ist,r);
83 end
84 end
85 if max(abs(1-QN./QN_1)) < tol
86 break
87 end
88end
89RN = QN ./ repmat(XN,M,1);
90end