LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
aoi_extract_params.m
1function [aoiParams, aoiInfo] = aoi_extract_params(sn, aoiInfo, options)
2%AOI_EXTRACT_PARAMS Extract parameters from LINE network for aoi-fluid solvers
3%
4% [aoiParams, aoiInfo] = AOI_EXTRACT_PARAMS(sn, aoiInfo, options)
5%
6% Maps LINE model representation to aoi-fluid function inputs:
7% - For bufferless (capacity=1): extract (tau, T, sigma, S, p)
8% - For single-buffer (capacity=2): extract (lambda, sigma, S, r)
9%
10% Parameters:
11% sn (struct): Network structure from Network.getStruct()
12% aoiInfo (struct): Topology information from aoi_is_aoi()
13% options (struct): Solver options, may contain:
14% - config.aoi_preemption: Override preemption probability (0-1)
15%
16% Returns:
17% aoiParams (struct): Parameters for aoi-fluid solver:
18% For bufferless:
19% .tau: Arrival initial probability vector
20% .T: Arrival sub-generator matrix
21% .sigma: Service initial probability vector
22% .S: Service sub-generator matrix
23% .p: Preemption probability (0=FCFS, 1=preemptive)
24% For single-buffer:
25% .lambda: Arrival rate (Poisson)
26% .sigma: Service initial probability vector
27% .S: Service sub-generator matrix
28% .r: Replacement probability (0=FCFS, 1=replacement)
29% aoiInfo (struct): Updated with extracted parameters
30
31% Copyright (c) 2012-2026, Imperial College London
32% All rights reserved.
33
34if nargin < 3
35 options = struct();
36end
37
38aoiParams = struct();
39
40% Get station indices
41sourceStation = aoiInfo.sourceStation;
42queueStation = aoiInfo.queueStation;
43
44% Find the open class
45openClasses = find(isinf(sn.njobs));
46classIdx = openClasses(1);
47
48% Get capacity and system type
49capacity = aoiInfo.capacity;
50schedStrategy = aoiInfo.schedStrategy;
51
52% =========================================================================
53% EXTRACT SERVICE PROCESS (same for both bufferless and single-buffer)
54% =========================================================================
55
56serviceProc = sn.proc{queueStation}{classIdx};
57
58if isempty(serviceProc) || (iscell(serviceProc) && isnan(serviceProc{1}(1)))
59 % Simple exponential service
60 mu = sn.rates(queueStation, classIdx);
61 aoiParams.sigma = 1;
62 aoiParams.S = -mu;
63else
64 % Phase-type service
65 [sigma, S] = aoi_dist2ph(serviceProc);
66 aoiParams.sigma = sigma;
67 aoiParams.S = S;
68end
69
70% =========================================================================
71% EXTRACT ARRIVAL PROCESS AND PREEMPTION PARAMETER
72% =========================================================================
73
74if capacity == 1
75 % BUFFERLESS: PH/PH/1/1 or PH/PH/1/1*
76 % Need: tau, T, sigma, S, p
77
78 arrivalProc = sn.proc{sourceStation}{classIdx};
79
80 if isempty(arrivalProc) || (iscell(arrivalProc) && isnan(arrivalProc{1}(1)))
81 % Simple exponential arrival (Poisson)
82 lambda = sn.rates(sourceStation, classIdx);
83 aoiParams.tau = 1;
84 aoiParams.T = -lambda;
85 else
86 % Phase-type arrival
87 [tau, T] = aoi_dist2ph(arrivalProc);
88 aoiParams.tau = tau;
89 aoiParams.T = T;
90 end
91
92 % Determine preemption probability p
93 if isfield(options, 'config') && isfield(options.config, 'aoi_preemption')
94 % User-specified preemption probability
95 aoiParams.p = options.config.aoi_preemption;
96 else
97 % Automatic based on scheduling strategy
98 switch schedStrategy
99 case SchedStrategy.FCFS
100 aoiParams.p = 0; % No preemption
101 case SchedStrategy.LCFS
102 aoiParams.p = 0; % Non-preemptive LCFS
103 case SchedStrategy.LCFSPR
104 aoiParams.p = 1; % Preemptive LCFS
105 otherwise
106 aoiParams.p = 0; % Default to FCFS behavior
107 end
108 end
109
110 aoiInfo.arrivalType = 'PH';
111
112else
113 % SINGLE-BUFFER: M/PH/1/2 or M/PH/1/2*
114 % Need: lambda, sigma, S, r
115
116 % Arrival must be Poisson (exponential interarrival times)
117 aoiParams.lambda = sn.rates(sourceStation, classIdx);
118
119 % Determine replacement probability r
120 if isfield(options, 'config') && isfield(options.config, 'aoi_preemption')
121 % User-specified replacement probability
122 aoiParams.r = options.config.aoi_preemption;
123 else
124 % Automatic based on scheduling strategy
125 switch schedStrategy
126 case SchedStrategy.FCFS
127 aoiParams.r = 0; % No replacement (FCFS)
128 case SchedStrategy.LCFS
129 aoiParams.r = 1; % Replacement (LCFS)
130 case SchedStrategy.LCFSPR
131 aoiParams.r = 1; % Preemptive also maps to replacement
132 otherwise
133 aoiParams.r = 0; % Default to FCFS behavior
134 end
135 end
136
137 aoiInfo.arrivalType = 'M';
138end
139
140% Store extracted info
141aoiInfo.aoiParams = aoiParams;
142
143end