LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
pfqn_oi_nc.m
1function [G, lG] = pfqn_oi_nc(Z, N, mu, options)
2% [G, LG] = PFQN_OI_NC(Z, N, MU, OPTIONS)
3%
4% Normalizing constant for a closed product-form queueing network that
5% comprises a single aggregated infinite-server (delay) node and an
6% arbitrary number of order-independent (OI) / pass-and-swap stations with
7% empty swap graph.
8%
9% The OI stations are analyzed by the balanced-fairness recursion of
10% Bonald & Proutiere (2003), "Insensitive bandwidth sharing in data
11% networks", combined with the multichain convolution over stations. For a
12% single OI station with rank rate mu(supp(n)) the balance function is
13% Phi(0) = 1, Phi(n) = (1/mu(supp n)) * sum_{r: n_r>0} Phi(n - e_r),
14% and G(N) is obtained by convolving the per-station balance functions with
15% the multinomial delay factor F_Z(n) = prod_r Z_r^{n_r} / n_r!.
16%
17% The routine returns the exact G(N) via the equivalent recursive
18% peeling: peel the last OI station (empty) then, per class r with N_r>0,
19% place one class-r job at that station and recurse on N - e_r with the
20% station rate function shifted by e_r. This reproduces the balanced-
21% fairness convolution without materializing the full Phi tables.
22%
24% Z - (1 x R) think-time demand vector of the aggregated delay node.
25% Z(r) = 1/sigma_r for a delay with per-class rate sigma_r.
26% N - (1 x R) closed population vector, finite.
27% mu - cell array {1 x M} of function handles, one per OI station. Each
28% mu{m}(n) returns the total service rate of station m given the
29% per-class occupancy (count) vector n (1 x R). For an order-
30% independent station this rate depends only on the support of n
31% (which classes are present), i.e. mu{m}(n) = sum of the capacities
32% of the servers compatible with the classes present in n. May be
33% empty to model a pure delay network.
34% options - solver options (optional, currently unused; accepted for
35% signature parity with the other pfqn_* routines).
36%
37% Returns:
38% G - Normalizing constant G(N).
39% lG - log(G(N)).
40%
41% Example (IS + two OI stations, R classes):
42% oirate = @(n) sum(mu1(any(compat1(:, find(n>0)) ~= 0, 2)));
43% oirate2 = @(n) sum(mu2(any(compat2(:, find(n>0)) ~= 0, 2)));
44% G = pfqn_oi_nc(1./sigma, N, {oirate, oirate2});
45%
46% Copyright (c) 2012-2026, Imperial College London
47% All rights reserved.
48
49if nargin < 4
50 options = struct();
51end
52if nargin < 3 || isempty(mu)
53 mu = {};
54end
55if ~iscell(mu)
56 mu = {mu};
57end
58
59R = numel(N);
60if isempty(Z)
61 Z = zeros(1, R);
62end
63if numel(Z) ~= R
64 line_error(mfilename, 'Z and N must have the same number of classes.');
65end
66if any(~isfinite(N))
67 line_error(mfilename, 'pfqn_oi_nc requires finite (closed) populations.');
68end
69
70N = round(N(:)');
71Z = Z(:)';
72
73G = oi_nc_rec(Z, N, mu);
74lG = log(G);
75end
76
77function G = oi_nc_rec(Z, N, mu)
78% Recursive balanced-fairness convolution over the OI stations.
79R = numel(N);
80
81if sum(N) == 0
82 G = 1;
83 return
84end
85
86M = numel(mu);
87if M == 0
88 % Base case: only the aggregated delay node remains. Its unnormalized
89 % weight is the multinomial factor prod_r Z_r^{N_r} / N_r!.
90 logf = 0;
91 for r = 1:R
92 if N(r) > 0
93 if Z(r) <= 0
94 G = 0; % class r has population but no delay demand: infeasible weight
95 return
96 end
97 logf = logf + N(r) * log(Z(r)) - gammaln(N(r) + 1);
98 end
99 end
100 G = exp(logf);
101 return
102end
103
104% Step A: last OI station holds no jobs; peel it off.
105mu_sub = mu(1:M-1);
106G = oi_nc_rec(Z, N, mu_sub);
107
108% Step B: place one job of each present class at the active OI station and
109% recurse with the station rate function shifted to account for that job.
110active = mu{M};
111for r = 1:R
112 if N(r) > 0
113 e_r = zeros(1, R);
114 e_r(r) = 1;
115 mu_r = active(e_r);
116 if mu_r <= 0
117 continue
118 end
119 shifted = @(state) active(state + e_r);
120 mu_next = mu;
121 mu_next{M} = shifted;
122 Nm = N;
123 Nm(r) = Nm(r) - 1;
124 G = G + (1 / mu_r) * oi_nc_rec(Z, Nm, mu_next);
125 end
126end
127end
Definition Station.m:245