1function [Z, W, Q, X] = qsys_gig1_rq(rho, mu, cs2, IaFun)
2% [Z,W,Q,X] = QSYS_GIG1_RQ(rho,mu,cs2,IaFun) - Robust Queueing (RQ)
3% approximation
for a single G/GI/1 queue partially characterized by its
4% arrival rate, index of dispersion
for counts (IDC) and
the first two moments
5% of
the service time. Implements
the mean steady-state workload
7% Z* = sup_{x>=0} { -(1-rho) x + sqrt( 2 rho x (I_a(x) + c2_s) / mu ) }
9% and
the derived steady-state performance measures. Reference: W. Whitt and
10% W. You (2018),
"A Robust Queueing Network Analyzer Based on Indices of
11% Dispersion", eqs. (13),(16)-(18).
14% rho : traffic intensity lambda/mu (0<rho<1)
16% cs2 : service SCV c2_s
17% IaFun : handle, IaFun(x) -> arrival IDC I_a(x) at time argument x>0
19% Z : mean steady-state workload E[Z]
20% W : mean steady-state waiting time E[W]
21% Q : mean steady-state queue length E[Q] (number waiting + in service)
22% X : mean number in system (= Q here for single class), kept for interface
25 Z = 0; W = 0; Q = 0; X = 0;
return;
28 Z = Inf; W = Inf; Q = Inf; X = Inf;
return;
32 function val = negf(x)
37 val = -( -(1-rho)*x + sqrt(max(0, 2*rho*x*(ia + cs2)/mu)) );
40% The objective
is a unimodal-in-practice but occasionally multimodal function
41% of x. Optimize with a coarse log-spaced scan
for bracketing followed by a
42% local golden-section refinement (fminbnd) on
the best bracket.
43xs = logspace(-6, 8, 200);
44fv = arrayfun(@(x) -negf(x), xs);
46lo = xs(max(1,imax-1));
47hi = xs(min(numel(xs),imax+1));
48opt = optimset(
'TolX',1e-10);
49[xopt, nfval] = fminbnd(@negf, lo, hi, opt);
51Z = max(Zscan, -nfval);
54% derived measures (eqs. 16-18)
55W = max(0, Z/rho - (cs2 + 1)/(2*mu));
56Q = lambda * W; % E[Q] waiting (Little's law on
the waiting time)
57X = Q + rho; % E[X] number in system including
the one in service