LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
qsys_gig1_rq.m
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
6%
7% Z* = sup_{x>=0} { -(1-rho) x + sqrt( 2 rho x (I_a(x) + c2_s) / mu ) }
8%
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).
12%
13% Inputs:
14% rho : traffic intensity lambda/mu (0<rho<1)
15% mu : service rate
16% cs2 : service SCV c2_s
17% IaFun : handle, IaFun(x) -> arrival IDC I_a(x) at time argument x>0
18% Outputs:
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
23
24if rho <= 0
25 Z = 0; W = 0; Q = 0; X = 0; return;
26end
27if rho >= 1
28 Z = Inf; W = Inf; Q = Inf; X = Inf; return;
29end
30lambda = rho * mu;
31
32 function val = negf(x)
33 if x <= 0
34 val = 0; return;
35 end
36 ia = IaFun(x);
37 val = -( -(1-rho)*x + sqrt(max(0, 2*rho*x*(ia + cs2)/mu)) );
38 end
39
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);
45[~, imax] = max(fv);
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);
50Zscan = fv(imax);
51Z = max(Zscan, -nfval);
52Z = max(Z, 0);
53
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
58end
Definition Station.m:245