LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
mam_svc_mixture.m
1function svc = mam_svc_mixture(D_arr, pie_cell, D0_cell)
2% SVC = MAM_SVC_MIXTURE(D_ARR, PIE_CELL, D0_CELL)
3%
4% Builds the arrival-weighted phase-type mixture of the per-class service
5% laws at a station, as the service descriptor accepted by QSYS_MAPG1K and
6% QSYS_MMAPG1K.
7%
8% D_ARR - {D0, D_class1, ..., D_classR} arrival MMAP
9% PIE_CELL - per-class PH initial distributions
10% D0_CELL - per-class PH subgenerators
11%
12% The mixture is PH(alpha_mix, T_mix) with alpha_mix = [w_1*pie_1, ...],
13% T_mix = blkdiag(D0_1, ...), and w_k = lambda_k/sum_j lambda_j the fraction
14% of arrivals belonging to class k. It is therefore the service law of an
15% arbitrary packet, and it reduces to the common law exactly (as a
16% distribution) when every class shares one.
17%
18% This is the same construction MAM_TRUNCATE_RENORM already applies when a
19% station carries more than one class, and it is factored out here so that
20% the exact finite-buffer branch and the truncate-and-renormalize fallback
21% rest on identical service assumptions and remain comparable.
22%
23% See also QSYS_MMAPG1K, MAM_TRUNCATE_RENORM, MAM_DETECT_MMCK.
24
25nClasses = numel(pie_cell);
26D0 = D_arr{1};
27e_arr = ones(size(D0, 1), 1);
28Dsum = zeros(size(D0));
29for k = 1:nClasses
30 Dsum = Dsum + D_arr{k+1};
31end
32theta = ctmc_solve(D0 + Dsum);
33lambda_k = zeros(1, nClasses);
34for k = 1:nClasses
35 lambda_k(k) = theta * D_arr{k+1} * e_arr;
36end
37sumL = sum(lambda_k);
38if sumL > 0
39 w = lambda_k / sumL;
40else
41 w = ones(1, nClasses) / nClasses;
42end
43
44n_k = cellfun(@(p) numel(p), pie_cell);
45n_total = sum(n_k);
46alpha_mix = zeros(1, n_total);
47T_mix = zeros(n_total, n_total);
48offset = 0;
49for k = 1:nClasses
50 alpha_mix(offset+1 : offset+n_k(k)) = w(k) * pie_cell{k}(:)';
51 T_mix(offset+1:offset+n_k(k), offset+1:offset+n_k(k)) = D0_cell{k};
52 offset = offset + n_k(k);
53end
54
55svc = struct('type', 'ph', 'alpha', alpha_mix, 'T', T_mix);
56end
Definition Station.m:245