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)
4% Copyright (c) 2012-2026, Imperial College London
13method = options.method;
15line_debug(
'MVA polling analyzer starting: method=%s, nclasses=%d', method, sn.nclasses);
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);
27 polling_type(r) = NaN;
28 switchover{r} = Immediate();
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;
35if strcmpi(method,
'exact')
36 if all(ca == 1) && k==1 && ((polling_type == PollingType.EXHAUSTIVE) || (polling_type == PollingType.GATED))
37 method = 'stationtime';
39 line_error(mfilename,'MVA exact method unavailable for this model.');
44 case {
'default',
'stationtime'}
45 if strcmpi(method,
'default')
46 line_debug('Default method: using stationtime analysis for polling\n');
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;
57 W = polling_qsys_1limited(sn.proc{source_ist},sn.proc{queue_ist},switchover);
59 line_error(mfilename,
'MVA method unavailable for K-limited polling with K>1.');
62 line_error(mfilename,
'Unsupported polling type.');
65 line_error(mfilename,
'Unsupported polling solution method.');
68R = zeros(1,sn.nclasses);
70 R(r) = W(r) + 1/mu(r);
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);