1function [QN, UN, RN, TN, piAgg, R] = solver_mam_map_bmap_1(mapArr, bmapSvc, varargin)
2% SOLVER_MAM_MAP_BMAP_1 Solve MAP/BMAP/1 queue
using GI/M/1-type analysis.
4% Solves a MAP/BMAP/1 queue where:
5% - Arrivals follow a Markovian Arrival Process (MAP)
6% - Service follows a Batch Markovian Arrival Process (BMAP)
for
7% batch service completions
10% The queue
is modeled as a GI/M/1-type Markov chain because:
11% - MAP arrivals increase level by exactly 1
12% - BMAP service can decrease level by 1, 2, 3, ... (batch sizes)
15% [QN, UN, RN, TN] = solver_mam_map_bmap_1(mapArr, bmapSvc)
16% [QN, UN, RN, TN, piAgg, R] = solver_mam_map_bmap_1(mapArr, bmapSvc)
19% mapArr - MAP object or cell array {C0, C1} for arrivals
20% bmapSvc - BMAP object or cell array {D0, D1, D2, ...} for batch service
23% QN - Mean queue length E[N]
24% UN - Server utilization rho
25% RN - Mean response time E[R]
26% TN - Throughput (arrival rate)
27% piAgg - Aggregated stationary probabilities [pi0, pi1, piStar]
28% R - R matrix from GI/M/1-type solution
30% The GI/M/1-type structure for MAP/BMAP/1
is:
37% A0 = C1 ⊗ I_ms (MAP arrival, level +1)
38% A1 = C0 ⊗ I_ms + I_ma ⊗ D0 (phase changes, level 0)
39% A_{k+1} = I_ma ⊗ D_k (batch size k service, level -k)
42% Riska, A., & Smirni, E. (2003). ETAQA: An Efficient Technique for the
43% Analysis of QBD-Processes by Aggregation. Performance Evaluation.
45% See also: solver_mam_bmap_m_1, MAP, BMAP
55 error(
'mapArr must be a MAP object or cell array {C0, C1}');
58if isa(bmapSvc,
'BMAP')
59 K = bmapSvc.getNumberOfPhases() - 1; % Max batch size
61 D{1} = bmapSvc.getD0();
63 D{k+1} = bmapSvc.D(1, k); % D_k
for batch size k
67 K = length(D) - 1; % Max batch size
69 error(
'bmapSvc must be a BMAP object or cell array {D0, D1, D2, ...}');
73ma = size(C0, 1); % Number of MAP phases
74ms = size(D{1}, 1); % Number of BMAP phases
75m = ma * ms; % Combined phases per level
78% Check MAP
is valid generator
79rowSumsC = sum(C0 + C1, 2);
80if max(abs(rowSumsC)) > 1e-10
81 error(
'MAP matrices C0 + C1 must have zero row sums');
84% Check BMAP
is valid generator
87 DTotal = DTotal + D{k+1};
89rowSumsD = sum(DTotal, 2);
90if max(abs(rowSumsD)) > 1e-10
91 error(
'BMAP matrices D0 + D1 + ... + DK must have zero row sums');
94%% Compute arrival and service rates
95% Arrival rate from MAP
96piC = map_prob({C0, C1});
97lambdaArr = piC * C1 * ones(ma, 1);
99% Service rate from BMAP (total customers served per unit time)
100piD = map_prob({D{1}, DTotal - D{1}}); % D0, sum of D1...DK
103 muTotal = muTotal + k * (piD * D{k+1} * ones(ms, 1));
107rho = lambdaArr / muTotal;
110 warning(
'System is unstable (rho = %.4f >= 1). Results may be invalid.', rho);
113%% Construct A matrix
for GI/M/1-type (repeating part)
114% A = [A0; A1; A2; ...; A_{K+1}] with (K+2) blocks of size m x m
116% A0 = C1 ⊗ I_ms (level +1: arrival)
117% A1 = C0 ⊗ I_ms + I_ma ⊗ D0 (level 0: phase changes)
118% A_{k+1} = I_ma ⊗ D_k (level -k: batch service of k)
120A = zeros(m * (K + 2), m);
122% A0: MAP arrival (level +1)
123A0 = kron(C1, eye(ms));
126% A1: Phase changes only (level 0)
127A1 = kron(C0, eye(ms)) + kron(eye(ma), D{1});
130% A_{k+1}: Batch service of size k (level -k)
132 Ak = kron(eye(ma), D{k+1});
133 A((k+1)*m+1:(k+2)*m, :) = Ak;
136%% Construct B matrix
for boundary levels
137% For levels 0, 1, ..., K-1, we need special handling because
138% batch service of size k
is only possible when queue length >= k
140% B = [B1; B2; ...; B_{K+1}] where B_i
is m x m
142% The boundary structure accounts
for:
143% - Level 0: no service possible (empty queue)
144% - Level 1: only batch size 1 service possible
145% - Level k: batch sizes 1, 2, ..., k possible
147B = zeros(m * (K + 1) + m, m); % B has mb=m boundary rows, then K+1 blocks
149% B1 (level 0 -> level 0): Phase changes only, no service from empty
150% Arrivals from level 0 are handled by B0 = A0
151B1 = kron(C0, eye(ms)) + kron(eye(ma), D{1});
152% Add service transitions that would go to negative levels back to level 0
154 B1 = B1 + kron(eye(ma), D{k+1}); % Service from empty stays at 0
158% B2, B3, ..., B_{K+1}: Transitions to level 0 from levels 1, 2, ..., K
160 % From level j, we can service batches of size 1, 2, ..., j going to level 0
162 % Only batch sizes <= j are valid; larger batches get truncated
164 % Batch size k from level j:
if k > j, customer stays at 0
165 % But
for GI/M/1 B matrix, we accumulate transitions to level 0
166 % B_{j+1} handles transition from level j to level 0
167 Bj = Bj + kron(eye(ma), D{k+1});
169 B(m + (j-1)*m + 1 : m + j*m, :) = Bj;
172%% Compute R matrix
using GI/M/1 ETAQA
175%% Compute stationary probabilities
using GI/M/1 ETAQA
176piAgg = GIM1_pi_ETAQA(B, A, R,
'Boundary', A0);
178%% Compute performance metrics
179% Extract probability components
182piStar = piAgg(2*m+1:3*m);
184% Mean queue length
using ETAQA moments
185QN = GIM1_qlen_ETAQA(B, A, R, piAgg, 1,
'Boundary', A0);
187% Throughput equals arrival rate (in steady state)
193% Mean response time via Little
's Law