LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_mva_lcfsqn.m
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
4%
5% This function wraps the pfqn_lcfsqn algorithm and maps LINE's data
6% structures to/from the algorithm's expected format.
7%
8% Parameters:
9% sn - network structure
10% options - solver options
11% lcfsStat - index of the LCFS station
12% lcfsprStat - index of the LCFS-PR station
13%
14% Returns:
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)
22%
23% Copyright (c) 2012-2026, Imperial College London
24% All rights reserved.
25
26M = sn.nstations;
27nclasses = sn.nclasses;
28njobs = sn.njobs;
29
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);
35
36rates = sn.rates;
37for r = 1:nclasses
38 if njobs(r) > 0
39 % Service rate at station for class r
40 mu_lcfs = rates(lcfsStat, r);
41 mu_lcfspr = rates(lcfsprStat, r);
42
43 if mu_lcfs <= 0 || ~isfinite(mu_lcfs)
44 line_error(mfilename, sprintf('Invalid service rate at LCFS station for class %d.', r));
45 end
46 if mu_lcfspr <= 0 || ~isfinite(mu_lcfspr)
47 line_error(mfilename, sprintf('Invalid service rate at LCFS-PR station for class %d.', r));
48 end
49
50 alpha(r) = 1 / mu_lcfs;
51 beta(r) = 1 / mu_lcfspr;
52 end
53end
54
55% Get population vector
56N = njobs;
57
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);
62
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);
71
72% Map queue lengths
73Q(lcfsStat, :) = Q_lcfs(1, :);
74Q(lcfsprStat, :) = Q_lcfs(2, :);
75
76% Map utilizations
77U(lcfsStat, :) = U_lcfs(1, :);
78U(lcfsprStat, :) = U_lcfs(2, :);
79
80% Throughput is the same at all stations in a closed network
81for r = 1:nclasses
82 if njobs(r) > 0
83 X(r) = T_lcfs(r);
84 T(lcfsStat, r) = T_lcfs(r);
85 T(lcfsprStat, r) = T_lcfs(r);
86 end
87end
88
89% Compute response times: R = Q / T (using Little's Law)
90for k = [lcfsStat, lcfsprStat]
91 for r = 1:nclasses
92 if T(k, r) > 0
93 R(k, r) = Q(k, r) / T(k, r);
94 end
95 end
96end
97
98% Compute cycle times: C = sum of response times at all stations
99for r = 1:nclasses
100 if njobs(r) > 0
101 C(r) = R(lcfsStat, r) + R(lcfsprStat, r);
102 end
103end
104
105% Log of normalizing constant is not computed by this method
106lG = NaN;
107
108end