4 % @brief Compute joint queue-length probability distribution.
10 % @brief Compute joint queue-length probability distribution.
11 % @fn pfqn_joint(n, L, N, Z, lGN)
12 % @param n Queue-length state vector (total or per-
class).
13 % @param L Service demand matrix.
14 % @param N Population vector.
15 % @param Z Think time vector (optional).
16 % @param lGN Log normalizing constant at N (optional, computed
if not provided).
17 % @
return pjoint Joint probability of state n.
20function pjoint = pfqn_joint(n,L,N,Z,lGN)
21% pjoint = pfqn_joint(n,L,N,Z,lGN)
23% Compute the joint queue-length probability
for vector n=(n_1,...,n_M) or
24% (n_{11},...n_{M,R}), with M the number of queues, and R the number of
25%
classes. If there
is a think time Z, then n
is just the queue population.
26% Optionally, the logarithm of the normalizing constant G at N can be passed
27% as an input to reduce the computational cost.
30% * Total queue-lengths
33%
for z=0:4-n % think time
34% pjoint(end+1) = pfqn_joint([n;4-n-z],[10,2;5,4],[2,2],[91,92]);
39% * Per-
class queue-lengths
41%
for n1=0:4 % queue 1,
class 1
42%
for n2=0:3 % queue 1,
class 2
43%
for z1=0:4-n1 % think time,
class 1
44%
for z2=0:3-n2 % think time,
class 2
45% pjoint(end+1) = pfqn_joint([n1,n2;4-n1-z1,3-n2-z2],[10,2;5,4],[4,3],[91,92]);
57 [~,lGn] = pfqn_ca(L,N,Z);
60 % Joint probability of total queue lengths
63 Fjoint = Fper([L;Z],N,[n(:);n0]);
64 pjoint = exp(log(Fjoint)-lGn-factln(sum(n0)));
66 Fjoint = Fper(L,N,[n(:)]);
67 pjoint = exp(log(Fjoint)-lGn);
71 % joint probability of total per-
class queue-lengths
73 Fjoint = sum(n0.*log(Z))-sum(factln(n0));
78 Fjoint = Fjoint + multinomialln(n(i,:)) + sum(n(i,:).*log(L(i,:)));
80 pjoint = exp(Fjoint-lGn);
82 line_error(mfilename,
'Invalid argument to pfqn_joint');
86function [F,A] = Fper(L,N,m)
90 Ak = [Ak, repmat(L(:,r),1,N(r))];
95 A((end+1):(end+m(i)),:) = repmat(Ak(i,:),m(i),1);
98F=perm(A)/prod(factorial(N));