2 % @brief Convert LINE PH/MAP distribution to FJ_codes format
4 % @author LINE Development Team
8 % @brief Convert LINE PH/MAP distribution to FJ_codes format
11 % Converts LINE
's MAP representation {D0, D1} to FJ_codes format.
12 % For arrivals: returns (lambda, lambda0, lambda1, ma, Ia)
13 % For service: returns (mu, ST, St, tau_st, SerChoice)
15 % Supported distributions:
17 % - 2-phase Hyperexponential (HyperExp with 2 phases)
18 % - 2-phase Erlang (Erlang with 2 phases)
19 % - 2-phase MAP (MAP with 2 states)
23 % fjDist = fj_dist2fj(lineMAP, distType, sn, ist, r)
28 % <tr><th>Name<th>Description
29 % <tr><td>lineMAP<td>LINE MAP representation {D0, D1}
30 % <tr><td>distType<td>'arrival
' or 'service
'
31 % <tr><td>sn<td>Network structure (for getting rate and process type)
32 % <tr><td>ist<td>Station index
33 % <tr><td>r<td>Class index
38 % <tr><th>Name<th>Description
39 % <tr><td>fjDist<td>FJ_codes compatible structure
43 % Z. Qiu, J.F. Pérez, and P. Harrison, "Beyond the Mean in Fork-Join Queues:
44 % Efficient Approximation for Response-Time Tails", IFIP Performance 2015.
45 % Copyright 2015 Imperial College London
47function fjDist = fj_dist2fj(lineMAP, distType, sn, ist, r)
51% Get process type and mean rate
52procType = sn.procid(ist, r);
53mean_rate = sn.rates(ist, r);
55% Extract D0 and D1 from LINE MAP format
60% Check number of phases
62 line_error(mfilename, 'FJ_codes only supports distributions with at most 2 phases. Found %d phases.
', nPhases);
65% Compute mean arrival/service rate (lambda or mu)
66lambda = map_lambda(lineMAP);
67mean_time = 1 / lambda;
69if strcmp(distType, 'arrival
')
70 % ===== ARRIVAL PROCESS =====
71 fjDist.lambda = lambda;
75 fjDist.Ia = eye(nPhases);
77 % Determine arrival choice for logging/debugging
78 if procType == ProcessType.EXP
79 fjDist.ArrChoice = 1; % Exp
80 elseif procType == ProcessType.HYPEREXP && nPhases == 2
81 fjDist.ArrChoice = 2; % HE2
82 elseif procType == ProcessType.ERLANG && nPhases == 2
83 fjDist.ArrChoice = 3; % ER2
84 elseif procType == ProcessType.MAP && nPhases == 2
85 fjDist.ArrChoice = 4; % MAP2
87 line_error(mfilename, 'Unsupported arrival distribution type: %s with %d phases.
', ...
88 ProcessType.toText(procType), nPhases);
92 % ===== SERVICE PROCESS =====
93 % Convert MAP to PH representation for service
94 % PH is represented as (tau_st, ST) where:
95 % - tau_st is initial probability vector
96 % - ST is the rate matrix
97 % - St is the exit vector (computed as -ST * ones)
99 % For service, we need to compute the PH representation from MAP
100 % The initial distribution for service is the stationary distribution
101 pie = map_pie(lineMAP);
103 fjDist.mu = lambda; % Mean service rate
104 fjDist.ST = D0; % Rate matrix
105 fjDist.St = -D0 * ones(nPhases, 1); % Exit vector
106 fjDist.tau_st = pie(:)'; % Initial probability (as row vector)
108 % Determine service choice
for logging/debugging
109 if procType == ProcessType.EXP
110 fjDist.SerChoice = 1; % Exp
111 elseif procType == ProcessType.HYPEREXP && nPhases == 2
112 fjDist.SerChoice = 2; % HE2
113 elseif procType == ProcessType.ERLANG && nPhases == 2
114 fjDist.SerChoice = 3; % ER2
116 line_error(mfilename,
'Unsupported service distribution type: %s with %d phases.', ...
117 ProcessType.toText(procType), nPhases);