1function [W,rhohat]=qsys_gg1(lambda,mu,ca2,cs2)
2% [W,RHOHAT]=QSYS_GG1(LAMBDA,MU,CA2,CS2) analyzes a G/G/1 queue.
4% Uses exact methods
for special cases (M/M/1, M/G/1, G/M/1) and
5% Allen-Cunneen approximation for
the general case. In
the G/M/1 case,
6%
the interarrival-time distribution
is fitted from (LAMBDA,CA2) by a
7% two-moment renewal process (H2 with balanced means for CA2>1, mixed
8% Erlang for CA2<1) and sigma
is the root of sigma = A*(mu*(1-sigma)),
9% with A*
the interarrival-time LST.
12% LAMBDA - Arrival rate
14% CA2 - Squared coefficient of variation of inter-arrival time
15% CS2 - Squared coefficient of variation of service time
18% W - Average time in system (response time)
19% RHOHAT - Modified utilization (so that M/M/1 formulas still hold)
21% Copyright (c) 2012-2026, Imperial College London
26if abs(ca2 - 1) < tol && abs(cs2 - 1) < tol
28 [W,rhohat] = qsys_mm1(lambda, mu);
29elseif abs(ca2 - 1) < tol
30 % M/G/1 case (ca2 = 1)
31 [W,rhohat] = qsys_mg1(lambda, mu, sqrt(cs2));
32elseif abs(cs2 - 1) < tol
33 % G/M/1 case (cs2 = 1)
34 sigma = qsys_gm1_sigma(lambda, mu, ca2);
35 W = qsys_gm1(sigma, mu);
36 rhohat = W * lambda / (1 + W * lambda);
38 % General G/G/1 case - use Allen-Cunneen approximation
39 [W,rhohat] = qsys_gig1_approx_allencunneen(lambda, mu, sqrt(ca2), sqrt(cs2));
44function sigma = qsys_gm1_sigma(lambda, mu, ca2)
45% Root in (0,1) of sigma = A*(mu*(1-sigma)) for a two-moment fit of
the
46% interarrival-time LST A*. (Handle-free so that MATLAB Coder can mexify.)
47jj = 0; p = 0; nu = 0; p1 = 0; l1 = 0; l2 = 0;
49 % hyperexponential H2 with balanced means
50 p1 = (1 + sqrt((ca2-1)/(ca2+1)))/2;
54 % mixed Erlang(j-1,j) with common rate (Tijms, 1994)
56 p = (jj*ca2 - sqrt(jj*(1+ca2) - jj^2*ca2))/(1+ca2);
59% fixed-point iteration; T(x)=A*(mu*(1-x))
is increasing with
the queue
60% root as its smallest fixed point, so iterates converge monotonically
65 % deterministic interarrival times
66 signew = exp(-s/lambda);
68 signew = p*(nu/(s+nu))^(jj-1) + (1-p)*(nu/(s+nu))^jj;
70 signew = p1*l1/(s+l1) + (1-p1)*l2/(s+l2);
72 if abs(signew-sigma) < 1e-13