1function [Q,U,R,T,C,X,lG,runtime,totiter,actualmethod] = solver_mva_qsys_prio_analyzer(sn, options)
2% [Q,U,R,T,C,X,LG,RUNTIME,ITER,ACTUALMETHOD] = SOLVER_MVA_QSYS_PRIO_ANALYZER(SN, OPTIONS)
4% Exact non-preemptive priority (HOL) analyzer
for a single open M/G/1 queue
5% with Poisson per-
class arrivals: dispatches to
the Cobham formula
6% (qsys_mg1_prio) instead of
the AMVA preemptive shadow-server approximation,
7% which underestimates
the waiting time of every class.
9% Copyright (c) 2012-2026, Imperial College London
15actualmethod = 'mg1.prio'; % exact Cobham formula, reported in
the solver banner
19Q = zeros(M,K); U = zeros(M,K);
20R = zeros(M,K); T = zeros(M,K);
21C = zeros(M,K); X = zeros(1,K);
23source_ist = sn.nodeToStation(sn.nodetype == NodeType.Source);
24queue_ist = sn.nodeToStation(sn.nodetype == NodeType.Queue);
26% Order classes by priority (lowest value = highest priority, stable)
27[~, order] = sort(sn.classprio(:)', 'ascend');
29lambdaOrd = sn.rates(source_ist, order);
30muOrd = sn.rates(queue_ist, order);
31scvOrd = sn.scv(queue_ist, order);
32scvOrd(~isfinite(scvOrd) | scvOrd <= 0) = 1;
35W = qsys_mg1_prio(lambdaOrd, muOrd, csOrd);
40 if lam <= 0 || ~isfinite(muOrd(j))
43 R(queue_ist, r) = W(j);
44 C(queue_ist, r) = W(j);
46 U(queue_ist, r) = lam / muOrd(j);
47 T(queue_ist, r) = lam;
48 Q(queue_ist, r) = lam * W(j);
49 T(source_ist, r) = lam;