1function [Q,U,R,T,C,X,lG] = solver_mva_lcfsqn(sn, options, lcfsStat, lcfsprStat)
2% [Q,U,R,T,C,X,LG] = SOLVER_MVA_LCFSQN(SN, OPTIONS, LCFSSTAT, LCFSPRSTAT)
3% Specialized MVA solver
for LCFS + LCFS-PR 2-station networks
5% This function wraps the pfqn_lcfsqn algorithm and maps LINE
's data
6% structures to/from the algorithm's expected format.
9% sn - network structure
10% options - solver options
11% lcfsStat - index of the LCFS station
12% lcfsprStat - index of the LCFS-PR station
15% Q - queue length matrix (stations x
classes)
16% U - utilization matrix (stations x
classes)
17% R - response time matrix (stations x
classes)
18% T - throughput matrix (stations x
classes)
19% C - cycle time vector (1 x
classes)
20% X - throughput vector (1 x
classes)
21% lG - log of normalizing constant (NaN
for this method)
23% Copyright (c) 2012-2026, Imperial College London
27nclasses = sn.nclasses;
30% Extract service times
for each class at each station
31% alpha(r) = mean service time at LCFS station
for class r
32% beta(r) = mean service time at LCFS-PR station
for class r
33alpha = zeros(1, nclasses);
34beta = zeros(1, nclasses);
39 % Service rate at station
for class r
40 mu_lcfs = rates(lcfsStat, r);
41 mu_lcfspr = rates(lcfsprStat, r);
43 if mu_lcfs <= 0 || ~isfinite(mu_lcfs)
44 line_error(mfilename, sprintf(
'Invalid service rate at LCFS station for class %d.', r));
46 if mu_lcfspr <= 0 || ~isfinite(mu_lcfspr)
47 line_error(mfilename, sprintf(
'Invalid service rate at LCFS-PR station for class %d.', r));
50 alpha(r) = 1 / mu_lcfs;
51 beta(r) = 1 / mu_lcfspr;
55% Get population vector
58% Call the LCFS MVA algorithm
59% Returns: T_lcfs (throughput), Q_lcfs (2xR queue lengths),
60% U_lcfs (2xR utilizations), B_lcfs (2xR back probabilities)
61[T_lcfs, Q_lcfs, U_lcfs, ~] = pfqn_lcfsqn_mva(alpha, beta, N);
63% Map results back to LINE format
64% Initialize output matrices
for all stations
65Q = zeros(M, nclasses);
66U = zeros(M, nclasses);
67T = zeros(M, nclasses);
68R = zeros(M, nclasses);
69X = zeros(1, nclasses);
70C = zeros(1, nclasses);
73Q(lcfsStat, :) = Q_lcfs(1, :);
74Q(lcfsprStat, :) = Q_lcfs(2, :);
77U(lcfsStat, :) = U_lcfs(1, :);
78U(lcfsprStat, :) = U_lcfs(2, :);
80% Throughput
is the same at all stations in a closed network
84 T(lcfsStat, r) = T_lcfs(r);
85 T(lcfsprStat, r) = T_lcfs(r);
89% Compute response times: R = Q / T (
using Little
's Law)
90for k = [lcfsStat, lcfsprStat]
93 R(k, r) = Q(k, r) / T(k, r);
98% Compute cycle times: C = sum of response times at all stations
101 C(r) = R(lcfsStat, r) + R(lcfsprStat, r);
105% Log of normalizing constant is not computed by this method