1%{ @file sn_refresh_process_fields.m
2 % @brief Refreshes process fields based on rate and SCV values
4 % @author LINE Development Team
8 % @brief Refreshes process fields
for a station-
class pair
11 % Updates mu, phi, proc, pie, phases based on current rate and SCV values.
12 % - SCV = 1.0: Exponential (1 phase)
13 % - SCV < 1.0: Erlang approximation
14 % - SCV > 1.0: Hyperexponential(2) approximation
18 % sn = sn_refresh_process_fields(sn, stationIdx, classIdx)
23 % <tr><th>Name<th>Description
24 % <tr><td>sn<td>Network structure
25 % <tr><td>stationIdx<td>Station index (1-based)
26 % <tr><td>classIdx<td>Class index (1-based)
31 % <tr><th>Name<th>Description
32 % <tr><td>sn<td>Modified network structure
35function sn = sn_refresh_process_fields(sn, stationIdx, classIdx)
37rate = sn.rates(stationIdx, classIdx);
38scv = sn.scv(stationIdx, classIdx);
40% Skip if rate
is invalid
41if isnan(rate) || rate <= 0 || isinf(rate)
47% Determine process type and create MAP based on SCV
48if isnan(scv) || abs(scv - 1.0) < 1e-10
50 MAP = map_exponential(mean);
52 procType = ProcessType.EXP;
54 % Erlang: k = ceil(1/scv)
55 k = max(1, ceil(1.0 / scv));
56 MAP = map_erlang(mean, k);
58 procType = ProcessType.ERLANG;
60 % Hyperexponential (scv > 1)
61 MAP = map_hyperexp(mean, scv);
64 procType = ProcessType.HYPEREXP;
66 % Fallback to exponential
67 MAP = map_exponential(mean);
69 procType = ProcessType.EXP;
73% Update process fields
78sn.proc{stationIdx, classIdx} = MAP;
81sn.procid(stationIdx, classIdx) = procType;
84sn.phases(stationIdx, classIdx) = nPhases;
87sn.phasessz(stationIdx, classIdx) = max(nPhases, 1);
89% Recompute phaseshift
for this station
91sn.phaseshift(stationIdx, 1) = 0;
93 cumSum = cumSum + sn.phasessz(stationIdx, c);
94 if c + 1 <= size(sn.phaseshift, 2)
95 sn.phaseshift(stationIdx, c + 1) = cumSum;
99% Update mu (rates from -diag(D0))
101sn.mu{stationIdx, classIdx} = muVec;
103% Update phi (completion probabilities)
104phiVec = zeros(nPhases, 1);
106 d1RowSum = sum(D1(i, :));
109 phiVec(i) = d1RowSum / d0Diag;
112sn.phi{stationIdx, classIdx} = phiVec;
114% Update pie (initial phase distribution)
115sn.pie{stationIdx, classIdx} = map_pie(MAP);