LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
qsys_gg1.m
1function [W,rhohat]=qsys_gg1(lambda,mu,ca2,cs2)
2% [W,RHOHAT]=QSYS_GG1(LAMBDA,MU,CA2,CS2) analyzes a G/G/1 queue.
3%
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.
6%
7% Inputs:
8% LAMBDA - Arrival rate
9% MU - Service rate
10% CA2 - Squared coefficient of variation of inter-arrival time
11% CS2 - Squared coefficient of variation of service time
12%
13% Returns:
14% W - Average time in system (response time)
15% RHOHAT - Modified utilization (so that M/M/1 formulas still hold)
16
17% Copyright (c) 2012-2026, Imperial College London
18% All rights reserved.
19
20tol = 1e-8;
21
22if abs(ca2 - 1) < tol && abs(cs2 - 1) < tol
23 % M/M/1 case
24 [W,rhohat] = qsys_mm1(lambda, mu);
25elseif abs(ca2 - 1) < tol
26 % M/G/1 case (ca2 = 1)
27 [W,rhohat] = qsys_mg1(lambda, mu, sqrt(cs2));
28elseif abs(cs2 - 1) < tol
29 % G/M/1 case (cs2 = 1)
30 rho = lambda / mu;
31 W = qsys_gm1(rho, mu);
32 rhohat = W * lambda / (1 + W * lambda);
33else
34 % General G/G/1 case - use Allen-Cunneen approximation
35 [W,rhohat] = qsys_gig1_approx_allencunneen(lambda, mu, sqrt(ca2), sqrt(cs2));
36end
37
38end