LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
me_gegecn.m
1function [p, L, U, PB, Lq] = me_gegecn(lambda, Ca, mu, Cs, c, K, N)
2%ME_GEGECN Censored GE/GE/c/K;N queue by entropy maximisation
3%
4% Maximum Entropy solution of the single-class censored FCFS GE/GE/c/K;N
5% queue of Kouvatsos (1994), Section 4.1. The queue holds at most N jobs
6% and never fewer than K; arrivals finding N jobs present are turned away
7% and departures are not allowed from state K. For a queue embedded in an
8% OPEN network K is always 0; positive K arises in closed networks, where
9% it records the minimum occupancy forced by the remaining stations being
10% full.
11%
12% The ME state probabilities subject to normalisation, the marginal
13% utilisations u(l), the mean queue length excluding J jobs and the
14% full-buffer probability coincide with the global balance solution
15%
16% p(n) = p(K) * G_n * x^h(n) * y^f(n), n = K+1,...,N (4.2)
17%
18% with G_n = prod_{l=K+1}^{m(n)} g(l), J = max(c,K+1),
19% h(n) = max(0,n-J), f(n) = max(0,n-N+1), m(n) = max{K+1,min(c,n)}, and
20% the Lagrangian coefficients g(l), x, y given in closed form by raw
21% system data. The coefficients are invariant to N and K, so letting
22% K -> 0 and N -> Inf recovers the stable GE/GE/c solution used by
23% ME_OQN.
24%
25% INPUTS:
26% lambda - Arrival rate offered to the queue (attempts, including the
27% arrivals that are turned away)
28% Ca - Squared coefficient of variation of the interarrival times
29% (Ca >= 1: the GE distribution is defined for scv >= 1)
30% mu - Service rate of one server
31% Cs - Squared coefficient of variation of the service times
32% (Cs >= 1)
33% c - Number of servers (c >= 1, finite)
34% K - Minimum number of jobs in the queue (K >= 0)
35% N - Buffer capacity in jobs, in service included (N > K, finite)
36%
37% OUTPUTS:
38% p - Queue length distribution, p(idx) = Pr{n = K+idx-1}, idx = 1..N-K+1
39% L - Mean number of jobs in the queue, sum_n n*p(n)
40% U - Utilization, E[min(n,c)]/c (mean fraction of busy servers)
41% PB - Probability that an arrival of the queue's own aggregate stream
42% finds the queue full, eq. (4.3)
43% Lq - Mean number of jobs waiting, L - E[min(n,c)]
44%
45% Reference:
46% D.D. Kouvatsos, "Entropy Maximisation and Queueing Network Models",
47% Annals of Operations Research, 48:63-126, 1994, Section 4.1,
48% equations (4.1)-(4.3).
49%
50% Copyright (c) 2012-2026, Imperial College London
51% All rights reserved.
52
53if ~isfinite(N)
54 line_error(mfilename, 'me_gegecn requires a finite buffer capacity N; use me_oqn for infinite capacity.');
55end
56if ~isfinite(c) || c < 1
57 line_error(mfilename, 'me_gegecn requires a finite number of servers c >= 1.');
58end
59if N <= K
60 line_error(mfilename, 'me_gegecn requires N > K.');
61end
62if Ca < 1 - 1e-12 || Cs < 1 - 1e-12
63 line_error(mfilename, 'me_gegecn requires Ca >= 1 and Cs >= 1: the GE distribution is not defined for scv < 1.');
64end
65if mu <= 0
66 line_error(mfilename, 'me_gegecn requires a positive service rate.');
67end
68
69c = round(c);
70K = round(K);
71N = round(N);
72
73tau = 2 / (Ca + 1);
74sigma = 2 / (Cs + 1);
75rho = lambda / (c * mu);
76
77J = max(c, K + 1);
78den1 = sigma * (1 - tau) + tau; % sigma(1-tau)+tau
79den2 = tau * rho * (1 - sigma) + sigma; % tau*rho(1-sigma)+sigma
80
81% Lagrangian coefficients g(l), l = K+1,...,J
82g = ones(J, 1);
83if K < c - 1
84 g(K+1) = tau * c * rho / ((K + 1) * den1);
85elseif K == c - 1
86 g(K+1) = tau * sigma * rho / den2;
87else % K >= c
88 g(K+1) = (den1 / den2) * tau * rho;
89end
90for l = (K+2):J
91 if l < J
92 g(l) = (tau * c * rho + (l - 1) * sigma * (1 - tau)) / (l * den1);
93 else
94 g(l) = sigma * (tau * c * rho + (J - 1) * sigma * (1 - tau)) / (J * den2);
95 end
96end
97
98x = (tau * rho + sigma * (1 - tau)) / den2;
99y = 1 / (1 - (1 - sigma) * x);
100
101% Unnormalized log-probabilities. Working in log space keeps x^(N-J) from
102% overflowing on a saturated queue with a large buffer, and makes the
103% rho=1 case (x=1) fall out of the same expression instead of needing the
104% separate p(K) branch of (4.2).
105n = K:N;
106cumlogg = cumsum(log(g(K+1:J)));
107logp = zeros(1, numel(n));
108for idx = 1:numel(n)
109 nn = n(idx);
110 if nn > K
111 m = max(K + 1, min(c, nn));
112 logp(idx) = cumlogg(m - K);
113 end
114end
115logp = logp + max(0, n - J) * log(x) + max(0, n - N + 1) * log(y);
116logp = logp - max(logp);
117p = exp(logp);
118p = p / sum(p);
119
120busy = min(n, c);
121L = sum(n .* p);
122Ebusy = sum(busy .* p);
123U = Ebusy / c;
124Lq = L - Ebusy;
125PB = me_gegecn_pb(p, K, N, c, Cs, Ca);
126end