LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_mva_polling_analyzer.m
1function [Q,U,R,T,C,X,lG,runtime,totiter] = solver_mva_polling_analyzer(sn, options)
2% [Q,U,R,T,C,X,LG,RUNTIME,ITER] = SOLVER_MVA_POLLING_ANALYZER(QN, OPTIONS)
3
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7T0=tic;
8Q = []; U = [];
9R = []; T = [];
10C = []; X = [];
11totiter = 1;
12
13method = options.method;
14
15line_debug('MVA polling analyzer starting: method=%s, nclasses=%d', method, sn.nclasses);
16
17source_ist = sn.nodeToStation(sn.nodetype == NodeType.Source);
18queue_ist = sn.nodeToStation(sn.nodetype == NodeType.Queue);
19lambda = sn.rates(source_ist,:)*sn.visits{source_ist}(sn.stationToStateful(queue_ist));
20k = sn.nservers(queue_ist);
21mu = sn.rates(queue_ist,:);
22ca = sqrt(sn.scv(source_ist,:));
23cs = sqrt(sn.scv(queue_ist,:));
24switchover = cell(1,sn.nclasses);
25for r=1:sn.nclasses
26 if isnan(mu(r))
27 polling_type(r) = NaN;
28 switchover{r} = Immediate();
29 else
30 polling_type(r) = PollingType.toId(sn.nodeparam{queue_ist}{r}.pollingType); % we assume this is identical across all buffers
31 switchover{r} = sn.nodeparam{queue_ist}{r}.switchoverTime;
32 end
33end
34
35if strcmpi(method,'exact')
36 if all(ca == 1) && k==1 && ((polling_type == PollingType.EXHAUSTIVE) || (polling_type == PollingType.GATED))
37 method = 'stationtime';
38 else
39 line_error(mfilename,'MVA exact method unavailable for this model.');
40 end
41end
42
43switch method
44 case {'default','stationtime'}
45 if strcmpi(method, 'default')
46 line_debug('Default method: using stationtime analysis for polling\n');
47 end
48 line_debug('Using stationtime method for polling analysis');
49 switch max(polling_type,[], 'omitnan') % we assume polling types to be identical
50 case PollingType.EXHAUSTIVE
51 W = polling_qsys_exhaustive(sn.proc{source_ist},sn.proc{queue_ist},switchover);
52 case PollingType.GATED
53 W = polling_qsys_gated(sn.proc{source_ist},sn.proc{queue_ist},switchover);
54 case PollingType.KLIMITED
55 K = sn.nodeparam{sn.stationToNode(queue_ist)}{1}.pollingPar;
56 if K==1
57 W = polling_qsys_1limited(sn.proc{source_ist},sn.proc{queue_ist},switchover);
58 else
59 line_error(mfilename,'MVA method unavailable for K-limited polling with K>1.');
60 end
61 otherwise
62 line_error(mfilename,'Unsupported polling type.');
63 end
64 otherwise
65 line_error(mfilename,'Unsupported polling solution method.');
66end
67
68R = zeros(1,sn.nclasses);
69for r=1:sn.nclasses
70 R(r) = W(r) + 1/mu(r);
71end
72
73R(queue_ist,1:sn.nclasses) = R .*sn.visits{1}(sn.stationToStateful(queue_ist));
74C(queue_ist,1:sn.nclasses) = R(1,:);
75X(queue_ist,1:sn.nclasses) = lambda;
76U(queue_ist,1:sn.nclasses) = lambda./mu/k;
77T(source_ist,1:sn.nclasses) = lambda;
78T(queue_ist,1:sn.nclasses) = lambda;
79Q(queue_ist,1:sn.nclasses) = X(queue_ist,1:sn.nclasses) .* R(queue_ist,1:sn.nclasses);
80lG = 0;
81runtime=toc(T0);
82end