LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_rtnodes_to_rtorig.m
1%{ @file sn_rtnodes_to_rtorig.m
2 % @brief Converts node routing matrix to the original routing matrix format
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Converts node routing matrix to the original routing matrix format
9 %
10 % @details
11 % This function converts the node-level routing matrix to the original
12 % routing matrix format, excluding class-switching nodes.
13 %
14 % @par Syntax:
15 % @code
16 % [rtorigcell, rtorig] = sn_rtnodes_to_rtorig(sn)
17 % @endcode
18 %
19 % @par Parameters:
20 % <table>
21 % <tr><th>Name<th>Description
22 % <tr><td>sn<td>Network structure
23 % </table>
24 %
25 % @par Returns:
26 % <table>
27 % <tr><th>Name<th>Description
28 % <tr><td>rtorigcell<td>Cell array representation of the routing matrix
29 % <tr><td>rtorig<td>Sparse matrix representation of the routing matrix
30 % </table>
31%}
32function [rtorigcell,rtorig] = sn_rtnodes_to_rtorig(sn)
33K = sn.nclasses;
34rtnodes = sn.rtnodes;
35
36csshift = sn.nnodes;
37for ind = 1:sn.nnodes
38 if startsWith(sn.nodenames{ind}, 'CS_')
39 csshift = ind-1;
40 break
41 end
42end
43
44colToKeep=[];
45for ind = 1:csshift
46 for k = 1:K
47 colToKeep(end+1) = (ind-1)*K+k;
48 end
49end
50
51rtorig = dtmc_stochcomp(rtnodes, colToKeep);
52rtorigcell = cellzeros(K,K,csshift,csshift);
53
54% for cache rt, replace NaNs for unknown probabilities with 0
55rtorig(isnan(rtorig)) = 0;
56
57for ind = 1:csshift
58 if sn.nodetype(ind) ~= NodeType.Sink
59 for jnd = 1:csshift
60 for r = 1:K
61 for s = 1:K
62 rtorigcell{r,s}(ind,jnd) = rtorig((ind-1)*K+r,(jnd-1)*K+s);
63 end
64 end
65 end
66 end
67end
68
69end
Definition mmt.m:92