1function [aoiParams, aoiInfo] = aoi_extract_params(sn, aoiInfo, options)
2%AOI_EXTRACT_PARAMS Extract parameters from LINE network
for aoi-fluid solvers
4% [aoiParams, aoiInfo] = AOI_EXTRACT_PARAMS(sn, aoiInfo, options)
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)
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)
17% aoiParams (struct): Parameters for aoi-fluid solver:
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)
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
31% Copyright (c) 2012-2026, Imperial College London
41sourceStation = aoiInfo.sourceStation;
42queueStation = aoiInfo.queueStation;
45openClasses = find(isinf(sn.njobs));
46classIdx = openClasses(1);
48% Get capacity and system type
49capacity = aoiInfo.capacity;
50schedStrategy = aoiInfo.schedStrategy;
52% =========================================================================
53% EXTRACT SERVICE PROCESS (same
for both bufferless and single-buffer)
54% =========================================================================
56serviceProc = sn.proc{queueStation}{classIdx};
58if isempty(serviceProc) || (iscell(serviceProc) && isnan(serviceProc{1}(1)))
59 % Simple exponential service
60 mu = sn.rates(queueStation, classIdx);
65 [sigma, S] = aoi_dist2ph(serviceProc);
66 aoiParams.sigma = sigma;
70% =========================================================================
71% EXTRACT ARRIVAL PROCESS AND PREEMPTION PARAMETER
72% =========================================================================
75 % BUFFERLESS: PH/PH/1/1 or PH/PH/1/1*
76 % Need: tau, T, sigma, S, p
78 arrivalProc = sn.proc{sourceStation}{classIdx};
80 if isempty(arrivalProc) || (iscell(arrivalProc) && isnan(arrivalProc{1}(1)))
81 % Simple exponential arrival (Poisson)
82 lambda = sn.rates(sourceStation, classIdx);
84 aoiParams.T = -lambda;
87 [tau, T] = aoi_dist2ph(arrivalProc);
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;
97 % Automatic based on scheduling strategy
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
106 aoiParams.p = 0; % Default to FCFS behavior
110 aoiInfo.arrivalType =
'PH';
113 % SINGLE-BUFFER: M/PH/1/2 or M/PH/1/2*
114 % Need: lambda, sigma, S, r
116 % Arrival must be Poisson (exponential interarrival times)
117 aoiParams.lambda = sn.rates(sourceStation, classIdx);
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;
124 % Automatic based on scheduling strategy
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
133 aoiParams.r = 0; % Default to FCFS behavior
137 aoiInfo.arrivalType =
'M';
140% Store extracted info
141aoiInfo.aoiParams = aoiParams;