LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
fj_extract_params.m
1%{ @file fj_extract_params.m
2 % @brief Extract FJ_codes parameters from LINE network structure
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Extract FJ_codes parameters from LINE network structure
9 %
10 % @details
11 % Extracts arrival process, service process, and K value from a validated
12 % Fork-Join network structure for use with FJ_codes analysis.
13 %
14 % @par Syntax:
15 % @code
16 % [arrival, service, K, fjInfo] = fj_extract_params(sn, fjInfo)
17 % @endcode
18 %
19 % @par Parameters:
20 % <table>
21 % <tr><th>Name<th>Description
22 % <tr><td>sn<td>Network structure (after sn_nonmarkov_toph conversion)
23 % <tr><td>fjInfo<td>FJ topology info from fj_isfj (forkIdx, joinIdx, queueIdx, K)
24 % </table>
25 %
26 % @par Returns:
27 % <table>
28 % <tr><th>Name<th>Description
29 % <tr><td>arrival<td>Cell array of arrival structs (one per class) with fields: lambda, lambda0, lambda1, ma, Ia
30 % <tr><td>service<td>Cell array of service structs (one per class) with fields: mu, ST, St, tau_st, SerChoice
31 % <tr><td>K<td>Number of parallel queues
32 % <tr><td>fjInfo<td>Updated fjInfo with distribution info
33 % </table>
34 %
35 % @par Reference:
36 % Z. Qiu, J.F. Pérez, and P. Harrison, "Beyond the Mean in Fork-Join Queues:
37 % Efficient Approximation for Response-Time Tails", IFIP Performance 2015.
38 % Copyright 2015 Imperial College London
39%}
40function [arrival, service, K, fjInfo] = fj_extract_params(sn, fjInfo)
41
42% Get Fork-Join structure info
43forkIdx = fjInfo.forkIdx;
44joinIdx = fjInfo.joinIdx;
45queueIdx = fjInfo.queueIdx;
46K = fjInfo.K;
47
48% Find Source node to extract arrival process
49sourceIdx = find(sn.nodetype == NodeType.Source);
50if isempty(sourceIdx)
51 line_error(mfilename, 'No Source node found in network.');
52end
53sourceIdx = sourceIdx(1); % Take first source
54sourceStat = sn.nodeToStation(sourceIdx);
55
56% Initialize cell arrays for multi-class support
57nClasses = sn.nclasses;
58arrival = cell(1, nClasses);
59service = cell(1, nClasses);
60
61% Extract parameters for each class
62for r = 1:nClasses
63 % ===== ARRIVAL PROCESS =====
64 % Get arrival MAP from Source node
65 arrivalMAP = sn.proc{sourceStat}{r};
66
67 if isempty(arrivalMAP) || isnan(arrivalMAP{1}(1))
68 line_error(mfilename, 'Source has no valid arrival process for class %d.', r);
69 end
70
71 % Convert to FJ_codes format
72 arrival{r} = fj_dist2fj(arrivalMAP, 'arrival', sn, sourceStat, r);
73
74 % ===== SERVICE PROCESS =====
75 % Get service MAP from first queue (all queues are homogeneous)
76 firstQueue = queueIdx(1);
77 firstQueueStat = sn.nodeToStation(firstQueue);
78 serviceMAP = sn.proc{firstQueueStat}{r};
79
80 if isempty(serviceMAP) || isnan(serviceMAP{1}(1))
81 line_error(mfilename, 'Queue %d has no valid service process for class %d.', ...
82 firstQueue, r);
83 end
84
85 % Convert to FJ_codes format
86 service{r} = fj_dist2fj(serviceMAP, 'service', sn, firstQueueStat, r);
87
88 % ===== STABILITY CHECK =====
89 % System must be stable: lambda < mu for each class
90 % Each queue sees arrival rate lambda and has utilization rho = lambda/mu
91 if arrival{r}.lambda >= service{r}.mu
92 line_warning(mfilename, ...
93 'Class %d may be unstable: arrival rate (%.4f) >= service rate (%.4f). FJ_codes requires stable systems (rho = lambda/mu < 1).', ...
94 r, arrival{r}.lambda, service{r}.mu);
95 end
96end
97
98% Store distribution info in fjInfo for reference
99fjInfo.arrival = arrival;
100fjInfo.service = service;
101fjInfo.nClasses = nClasses;
102
103end