2 % @brief Solves a RAP/RAP/1 queue
using QBD methods
4 % @author LINE Development Team
8 % @brief Analyzes RAP/RAP/1 queue
using Quasi-Birth-Death process
11 % This function solves a RAP/RAP/1 queue (Rational Arrival Process)
using
12 % QBD methods, computing throughput, queue length, utilization, and other
13 % performance metrics.
15 % The two RAPs are INDEPENDENT of each other, so the QBD phase space
is the
16 % product of the two phase spaces and the blocks
factor as Kronecker
17 % products. This function
is the thin product-space wrapper; the analysis
18 % itself
is the block-level core qbd_rap.m, which solves an arbitrary QBD
19 % with RAP components. A model whose arrival process and sequence of
20 % service times share a phase space, and are therefore cross-correlated,
21 % has no such product structure and must call qbd_rap directly.
24 % N. G. Bean and B. F. Nielsen,
"Quasi-Birth-and-Death Processes with
25 % Rational Arrival Process Components", Stochastic Models, 26(3), 2010,
26 % pp. 309-334. The analysis rests on the prediction-process interpretation
27 % of a RAP due to Asmussen and Bladt, which
is what allows a QBD argument
28 % to be carried over to matrices that are not nonnegative. The same
29 % prediction process underlies the conditional-vector RAP sampler in
32 % @par Phase ordering:
33 % The QBD phase
is the pair (arrival phase, service phase) laid out with
34 % the ARRIVAL phase major and the service phase minor, i.e. the phase index
35 %
is (a-1)*ns + s. That
is the ordering produced by kron(RAPa, eye(ns)) and
36 % kron(eye(na), RAPs), and pqueue
is indexed by it downstream in
37 % solver_mam_basic, so the two Kronecker factors must not be swapped.
41 % [XN, QN, UN, pqueue, R, eta, G, B, L, F] = qbd_raprap1(RAPa, RAPs)
42 % [XN, QN, UN, pqueue, R, eta, G, B, L, F] = qbd_raprap1(RAPa, RAPs, util)
47 % <tr><th>Name<th>Description
48 % <tr><td>RAPa<td>Arrival process (RAP)
49 % <tr><td>RAPs<td>Service process (RAP)
50 % <tr><td>util<td>(Optional) Target utilization to scale service rate
55 % <tr><th>Name<th>Description
56 % <tr><td>XN<td>System throughput
57 % <tr><td>QN<td>Mean queue length
58 % <tr><td>UN<td>Utilization
59 % <tr><td>pqueue<td>Queue length distribution
60 % <tr><td>R<td>Rate matrix R
61 % <tr><td>eta<td>Caudal characteristic
62 % <tr><td>G<td>Rate matrix G
63 % <tr><td>B<td>Backward transition block
64 % <tr><td>L<td>Local transition block
65 % <tr><td>F<td>Forward transition block
68function [XN,QN,UN,pqueue,R,eta,G,B,L,F]=qbd_raprap1(RAPa,RAPs,util)
69% [XN,QN,UN,PQUEUE,R,ETA]=QBD_RAPRAP1(RAPA,RAPS,UTIL)
74if nargin>=3 %exist(
'util',
'var')
75 RAPs = map_scale(RAPs,util/map_lambda(RAPa));
78% see _kb/03-api-layer.md (QBD boundary conventions) for rationale
79F = kron(RAPa{2},eye(ns)); % arrivals, level up
80L = kron(RAPa{1},eye(ns)) + kron(eye(na),RAPs{1});
81B = kron(eye(na),RAPs{2}); % service completions, level down
82B1 = kron(RAPa{1},eye(ns));
84% Theorem 7 of Bean and Nielsen (2010), in qbd_rap.m: G from the quadratic
85% matrix equation, U = L + F*G, R = F*inv(-U), and pi0 from the boundary
86% equation pi0*(B1 + R*B) = 0 normalised by pi0*inv(I-R)*e = 1.
87[~,~,R,G,~,eta,~,pi0] = qbd_rap(F, L, B, F, B1, 0);
89% see _kb/03-api-layer.md (QBD boundary conventions)
for rationale
94while sumpi < 1-1e-10 && numit < 1+maxNumComp
95 pqueue(numit+1,1:(na*ns)) = pqueue(numit,:)*R;
97 sumpi = sumpi + sum(pqueue(numit,:));
100numLevels = size(pqueue,1);
101levelProb = sum(pqueue,2);
102QN = (0:(numLevels-1))*levelProb;
107 UN= 1 - sum(pqueue(1,:));