LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_mva_qsys_prio_analyzer.m
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)
3%
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.
8%
9% Copyright (c) 2012-2026, Imperial College London
10% All rights reserved.
11
12T0 = tic;
13totiter = 0;
14lG = 0;
15actualmethod = 'mg1.prio'; % exact Cobham formula, reported in the solver banner
16K = sn.nclasses;
17M = sn.nstations;
18
19Q = zeros(M,K); U = zeros(M,K);
20R = zeros(M,K); T = zeros(M,K);
21C = zeros(M,K); X = zeros(1,K);
22
23source_ist = sn.nodeToStation(sn.nodetype == NodeType.Source);
24queue_ist = sn.nodeToStation(sn.nodetype == NodeType.Queue);
25
26% Order classes by priority (lowest value = highest priority, stable)
27[~, order] = sort(sn.classprio(:)', 'ascend');
28
29lambdaOrd = sn.rates(source_ist, order);
30muOrd = sn.rates(queue_ist, order);
31scvOrd = sn.scv(queue_ist, order);
32scvOrd(~isfinite(scvOrd) | scvOrd <= 0) = 1;
33csOrd = sqrt(scvOrd);
34
35W = qsys_mg1_prio(lambdaOrd, muOrd, csOrd);
36
37for j = 1:K
38 r = order(j);
39 lam = lambdaOrd(j);
40 if lam <= 0 || ~isfinite(muOrd(j))
41 continue
42 end
43 R(queue_ist, r) = W(j);
44 C(queue_ist, r) = W(j);
45 X(r) = lam;
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;
50end
51
52runtime = toc(T0);
53end
Definition Station.m:245