LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Q_RAP_RAP_1.m
1function [ql]=Q_RAP_RAP_1(C0,C1,D0,D1,varargin)
2% [ql]=Q_RAP_RAP_1(C0,C1,D0,D1) computes the Queue-length distribution
3% of a RAP(C0,C1)/RAP(D0,D1)/1/FCFS queue
4%
5% INPUT PARAMETERS:
6% * RAP(C0,C1) arrival process (with mA states)
7%
8% * RAP(D0,D1) service process (with mS states)
9%
10% RETURN VALUES:
11% * Queue length distribution,
12% ql(i) = Prob[(i-1) customers in the queue]
13%
14% OPTIONAL PARAMETERS:
15% Mode: The underlying function to compute the R matrix of the
16% underlying QBD can be selected using the following
17% parameter values (default: 'CR')
18% 'CR' : Cyclic Reduction [Bini, Meini]
19% 'FI' : Functional Iterations [Neuts]
20% 'IS' : Invariant Subspace [Akar, Sohraby]
21% 'LR' : Logaritmic Reduction [Latouche, Ramaswami]
22% 'NI' : Newton Iteration
23%
24% MaxNumComp: Maximum number of components for the vectors containig
25% the performance measure.
26%
27% Verbose: When set to 1, the progress of the computation is printed
28% (default:0).
29%
30% Optfname: Optional parameters for the underlying function fname.
31% These parameters are included in a cell with one entry holding
32% the name of the parameter and the next entry the parameter
33% value. In this function, fname can be equal to:
34% 'QBD_CR' : Options for Cyclic Reduction [Bini, Meini]
35% 'QBD_FI' : Options for Functional Iterations [Neuts]
36% 'QBD_IS' : Options for Invariant Subspace [Akar, Sohraby]
37% 'QBD_LR' : Options for Logaritmic Reduction [Latouche, Ramaswami]
38% 'QBD_NI' : Options for Newton Iteration
39%
40% USES: QBD Solver and QBD_pi of the SMCSolver tool
41
42
43OptionNames=[
44 'Mode ';
45 'MaxNumComp ';
46 'Verbose ';
47 'OptQBD_CR ';
48 'OptQBD_FI ';
49 'OptQBD_IS ';
50 'OptQBD_LR ';
51 'OptQBD_NI '];
52
53OptionTypes=[
54 'char ';
55 'numeric';
56 'numeric';
57 'cell ';
58 'cell ';
59 'cell ';
60 'cell ';
61 'cell '];
62
63OptionValues{1}=['CR';
64 'FI';
65 'IS';
66 'LR';
67 'NI'];
68
69options=[];
70for i=1:size(OptionNames,1)
71 options.(deblank(OptionNames(i,:)))=[];
72end
73
74% Default settings
75options.Mode='CR';
76options.MaxNumComp = 50;
77options.Verbose = 0;
78options.OptQBD_CR=cell(0);
79options.OptQBD_FI=cell(0);
80options.OptQBD_IS=cell(0);
81options.OptQBD_LR=cell(0);
82options.OptQBD_NI=cell(0);
83
84% Parse Parameters
85Q_RAP_ParsePara(C0,'C0',C1,'C1')
86Q_RAP_ParsePara(D0,'D0',D1,'D1')
87
88% Parse Optional Parameters
89options=Q_ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
90% Check for unused parameter
91Q_CheckUnusedParaQBD(options)
92
93% Determine constants
94mA=size(C0,1);
95mS=size(D0,1);
96
97% Test the load of the queue
98pi_a = stat(C0+C1+eye(mA));
99pi_s = stat(D0+D1+eye(mS));
100lambda = sum(pi_a*C1);
101mu = sum(pi_s*D1);
102
103load=lambda/mu
104if load >= 1
105 error('MATLAB:Q_RAP_RAP_1:LoadExceedsOne',...
106 'The load %d of the system exceeds one',load);
107end
108
109% Compute QBD blocks A0, A1 and A2
110A0=kron(eye(mA),D1);
111A1=kron(C0,eye(mS))+kron(eye(mA),D0);
112A2=kron(C1,eye(mS));
113
114B0=A0;
115B1=kron(C0,eye(mS));
116
117if (strfind(options.Mode,'FI')>0)
118 [G,R]=QBD_FI(A0,A1,A2,options.OptQBD_FI{:},'RAPComp',1);
119elseif (strfind(options.Mode,'LR')>0)
120 [G,R]=QBD_LR(A0,A1,A2,options.OptQBD_LR{:},'RAPComp',1);
121elseif (strfind(options.Mode,'IS')>0)
122 [G,R]=QBD_IS(A0,A1,A2,options.OptQBD_IS{:},'RAPComp',1);
123elseif (strfind(options.Mode,'NI')>0)
124 [G,R]=QBD_NI(A0,A1,A2,options.OptQBD_NI{:},'RAPComp',1);
125else
126 [G,R]=QBD_CR(A0,A1,A2,options.OptQBD_CR{:},'RAPComp',1);
127end
128
129pi = QBD_pi(B0,B1,R, 'MaxNumComp',options.MaxNumComp,'Verbose',options.Verbose,'RAPComp',1);
130
131
132% compute queue length
133ql = zeros(1, size(pi, 2)/(mA*mS));
134for i = 1:size(pi,2)/(mA*mS)
135 ql(i) =sum(pi((i-1)*mA*mS+1:i*mA*mS));
136end