1function result = qsys_geogeo1(a, s, convention)
2% QSYS_GEOGEO1 Exact closed-form analysis of a discrete-time Geo/Geo/1 queue.
4% RESULT = QSYS_GEOGEO1(A, S) analyzes a slotted single-server queue with:
5% A - per-slot arrival probability (0 < A < S)
6% S - per-slot service completion probability (0 < S <= 1)
8% RESULT = QSYS_GEOGEO1(A, S, CONVENTION) selects
the observation epoch,
9%
'LAS_DA' (
default) or
'EAS'. Time advances in slots of unit length. In each
10% slot an arrival occurs with probability A and,
if the server
is engaged, a
11% service completion occurs with probability S, independently of everything
12%
else. The system content at slot boundaries
is a discrete birth-death chain
13% whose stationary distribution
is geometric.
15% The two conventions are not two systems. They are one system, Daduna
's
16% LA-rule (events at the end of their slot) with the D/A-rule (departure
17% resolved before arrival), observed at two instants. With
18% X(t+1) = X(t) - D(t) + A(t), 'LAS_DA
' is the law of X, taken after both
19% events, and 'EAS
' is the law of Y(t) = X(t) - D(t), taken after the departure
20% and before the arrival. They are one departure apart, so the mean contents
21% differ by exactly A and, by Little's law,
the sojourn times by one slot. The
22% queueing delay
is the same under both.
24% With rho = A/S and r = A(1-S)/(S(1-A)):
25% LAS_DA: p_0 = 1-rho, p_n = (1-rho) rho/(1-A) r^(n-1), n >= 1
26% E[N] = A(1-A)/(S-A), E[T] = (1-A)/(S-A)
27% EAS: p_n = (1-r) r^n, n >= 0
28% E[N] = A(1-S)/(S-A), E[T] = (1-S)/(S-A)
29% Both give U = rho, X = A and E[W] = A(1-S)/(S(S-A)).
31% Returns a struct with fields:
32% convention - Observation epoch used,
'LAS_DA' or
'EAS'
33% arrivalProb - Per-slot arrival probability A
34% serviceProb - Per-slot service completion probability S
35% utilization - Fraction of slots with
the server serving, A/S
36% throughput - Departures per slot, A
37% emptyProb - Probability
the system
is empty at
the epoch
38% ratio - Geometric decay ratio of
the queue-length tail, r
39% meanQueueLength - Mean number of jobs in
the system
40% meanWaitingQueue - Mean number of jobs waiting, i.e. not in service
41% meanSojournTime - Mean sojourn time in slots
42% meanWaitingTime - Mean waiting time in slots (epoch independent)
43% meanServiceTime - Mean service time, 1/S under LAS_DA, (1-S)/S under EAS
44% pmf - Function handle p(n) for
the stationary queue length
45% analyzer - Identifier string
48% r = qsys_geogeo1(0.2, 0.5);
49% r.meanQueueLength % 0.5333
50% r.meanSojournTime % 2.6667
53% Reference: H. Daduna, Queueing Networks with Discrete Time Scale, LNCS 2046,
54% Springer 2001, corollary 2.7 (
the LAS_DA branch reproduces it term
for term
55% with b = A, p = S, c = 1-A, q = 1-S).
57% See also QSYS_GEOXGEO1, QSYS_MM1
59% Copyright (c) 2012-2026, Imperial College London
62if nargin < 3 || isempty(convention)
63 convention =
'LAS_DA';
65if ~ischar(convention) && ~isstring(convention)
66 line_error(mfilename,
'convention must be the string ''LAS_DA'' or ''EAS''');
68convention = upper(
char(convention));
69if ~strcmp(convention,
'LAS_DA') && ~strcmp(convention,
'EAS')
70 line_error(mfilename, 'convention must be ''LAS_DA'' or ''EAS''');
72if ~isnumeric(a) || ~isscalar(a) || ~isreal(a) || a <= 0 || a > 1
73 line_error(mfilename, 'a must be a real scalar in (0,1]');
75if ~isnumeric(s) || ~isscalar(s) || ~isreal(s) || s <= 0 || s > 1
76 line_error(mfilename, 's must be a real scalar in (0,1]');
79 line_error(mfilename, 'load a/s must be strictly less than 1');
83ratio = a * (1 - s) / (s * (1 - a));
85% The queueing delay does not depend on
the observation epoch; only
the
86% accounting of
the slot in which service takes place does.
87meanWaitingTime = a * (1 - s) / (s * (s - a));
88meanWaitingQueue = a * meanWaitingTime;
90if strcmp(convention, 'LAS_DA')
92 meanQueueLength = a * (1 - a) / (s - a);
93 meanSojournTime = (1 - a) / (s - a);
94 meanServiceTime = 1 / s;
95 pmf = @(n) las_da_pmf(n, emptyProb, rho, a, ratio);
97 emptyProb = 1 - ratio;
98 meanQueueLength = a * (1 - s) / (s - a);
99 meanSojournTime = (1 - s) / (s - a);
100 meanServiceTime = (1 - s) / s;
101 pmf = @(n) eas_pmf(n, ratio);
105result.convention = convention;
106result.arrivalProb = a;
107result.serviceProb = s;
108result.utilization = rho;
109result.throughput = a;
110result.emptyProb = emptyProb;
112result.meanQueueLength = meanQueueLength;
113result.meanWaitingQueue = meanWaitingQueue;
114result.meanSojournTime = meanSojournTime;
115result.meanWaitingTime = meanWaitingTime;
116result.meanServiceTime = meanServiceTime;
118result.analyzer = 'qsys_geogeo1';
121function pr = las_da_pmf(n, emptyProb, rho, a, ratio)
122if any(n < 0) || any(floor(n) ~= n)
123 line_error('qsys_geogeo1', 'queue length must be a non-negative integer');
126pr(n == 0) = emptyProb;
128pr(n >= 1) = emptyProb * (rho / (1 - a)) * ratio .^ (k - 1);
131function pr = eas_pmf(n, ratio)
132if any(n < 0) || any(floor(n) ~= n)
133 line_error('qsys_geogeo1', 'queue length must be a non-negative integer');
135pr = (1 - ratio) * ratio .^ n;