LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_mva_qsys_sizebased_analyzer.m
1function [Q,U,R,T,C,X,lG,runtime,totiter,actualmethod] = solver_mva_qsys_sizebased_analyzer(sn, options, schedType)
2% [Q,U,R,T,C,X,LG,RUNTIME,ITER] = SOLVER_MVA_QSYS_SIZEBASED_ANALYZER(SN, OPTIONS, SCHEDTYPE)
3%
4% Analyzer for M/G/1 queueing systems with size-based scheduling.
5% Supports: SRPT, PSJF, FB/LAS, LRPT, SETF
6%
7% This function handles multiclass open queueing systems with size-based
8% scheduling policies using the analytical formulas from:
9% A. Wierman and M. Harchol-Balter, "Classifying scheduling policies with
10% respect to unfairness in an M/GI/1", SIGMETRICS 2003.
11
12% Copyright (c) 2012-2026, Imperial College London
13% All rights reserved.
14
15T0 = tic;
16Q = []; U = [];
17R = []; T = [];
18C = []; X = [];
19totiter = 1;
20
21% Extract model parameters
22source_ist = sn.nodeToStation(sn.nodetype == NodeType.Source);
23queue_ist = sn.nodeToStation(sn.nodetype == NodeType.Queue);
24
25K = sn.nclasses;
26lambda = zeros(K, 1);
27mu = zeros(K, 1);
28cs = zeros(K, 1);
29
30for k = 1:K
31 lambda(k) = sn.rates(source_ist, k) * sn.visits{source_ist}(sn.stationToStateful(queue_ist), k);
32 mu(k) = sn.rates(queue_ist, k);
33 cs(k) = sqrt(sn.scv(queue_ist, k));
34end
35
36% Check for valid parameters
37if any(lambda <= 0) || any(mu <= 0)
38 line_error(mfilename, 'Invalid arrival or service rates (must be positive).');
39end
40
41% Compute total utilization
42rho = sum(lambda ./ mu);
43if rho >= 1
44 line_warning(mfilename, 'System is unstable (rho = %.4f >= 1).', rho);
45end
46
47% Call appropriate qsys function based on scheduling type
48switch schedType
49 case SchedStrategy.SRPT
50 line_debug('Using M/G/1/SRPT exact solution');
51 [W, ~] = qsys_mg1_srpt(lambda, mu, cs);
52 actualmethod = 'mg1.srpt';
53 case SchedStrategy.PSJF
54 line_debug('Using M/G/1/PSJF exact solution');
55 [W, ~] = qsys_mg1_psjf(lambda, mu, cs);
56 actualmethod = 'mg1.psjf';
57 case SchedStrategy.FB
58 line_debug('Using M/G/1/FB (LAS) exact solution');
59 [W, ~] = qsys_mg1_fb(lambda, mu, cs);
60 actualmethod = 'mg1.fb';
61 case SchedStrategy.LRPT
62 line_debug('Using M/G/1/LRPT exact solution');
63 [W, ~] = qsys_mg1_lrpt(lambda, mu, cs);
64 actualmethod = 'mg1.lrpt';
65 case SchedStrategy.SETF
66 line_debug('Using M/G/1/SETF (non-preemptive FB) exact solution');
67 [W, ~] = qsys_mg1_setf(lambda, mu, cs);
68 actualmethod = 'mg1.setf';
69 otherwise
70 line_error(mfilename, 'Unsupported scheduling type for size-based analyzer.');
71end
72
73% Initialize result matrices
74M = sn.nstations;
75R = zeros(M, K);
76Q = zeros(M, K);
77U = zeros(M, K);
78T = zeros(M, K);
79C = zeros(M, K);
80X = zeros(M, K);
81
82% Populate results
83for k = 1:K
84 visits = sn.visits{source_ist}(sn.stationToStateful(queue_ist), k);
85 R(queue_ist, k) = W(k) * visits;
86 T(source_ist, k) = lambda(k);
87 T(queue_ist, k) = lambda(k);
88 X(queue_ist, k) = lambda(k);
89 U(queue_ist, k) = lambda(k) / mu(k);
90 Q(queue_ist, k) = lambda(k) * W(k);
91 C(queue_ist, k) = R(queue_ist, k);
92end
93
94lG = 0;
95runtime = toc(T0);
96end
Definition Station.m:245