LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_get_arvr_from_tput.m
1%{ @file sn_get_arvr_from_tput.m
2 % @brief Computes average arrival rates at stations from throughputs
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Computes average arrival rates at stations from throughputs
9 %
10 % @details
11 % This function calculates the average arrival rate at each station
12 % in steady-state from the station throughputs and routing matrix.
13 %
14 % @par Syntax:
15 % @code
16 % AN = sn_get_arvr_from_tput(sn, TN, TH)
17 % @endcode
18 %
19 % @par Parameters:
20 % <table>
21 % <tr><th>Name<th>Description
22 % <tr><td>sn<td>Network structure
23 % <tr><td>TN<td>Average throughputs at stations
24 % <tr><td>TH<td>Throughput handles (optional)
25 % </table>
26 %
27 % @par Returns:
28 % <table>
29 % <tr><th>Name<th>Description
30 % <tr><td>AN<td>Average arrival rates at stations
31 % </table>
32%}
33function AN=sn_get_arvr_from_tput(sn, TN, TH)
34
35M = sn.nstations;
36R = sn.nclasses;
37if ~isempty(TH) && ~isempty(TN)
38 AN = zeros(M,R);
39
40 % Build mapping from stateful nodes to their position in rt matrix
41 % rt is indexed by stateful nodes, not stations
42 statefulNodes = find(sn.isstateful);
43 nStateful = length(statefulNodes);
44
45 % Build throughput vector for all stateful nodes (stations have TN, others need computation)
46 TN_stateful = zeros(nStateful, R);
47 for sf = 1:nStateful
48 ind = statefulNodes(sf);
49 ist = sn.nodeToStation(ind);
50 if ist > 0
51 % This stateful node is a station - use station throughput
52 TN_stateful(sf, :) = TN(ist, :);
53 else
54 % This stateful node is not a station (e.g., Cache)
55 % Compute throughput from routing and reference station throughput
56 if sn.nodetype(ind) == NodeType.Cache
57 % For Cache nodes, compute hit/miss class throughputs
58 % from the reference station throughput and hit/miss probabilities
59 hitclass = sn.nodeparam{ind}.hitclass;
60 missclass = sn.nodeparam{ind}.missclass;
61
62 % Get actual hit/miss probabilities if available
63 if isfield(sn.nodeparam{ind}, 'actualhitprob') && ~isempty(sn.nodeparam{ind}.actualhitprob)
64 actualHitProb = sn.nodeparam{ind}.actualhitprob;
65 actualMissProb = sn.nodeparam{ind}.actualmissprob;
66 else
67 % Actual probabilities not yet computed - skip this cache
68 % Arrival rates will be computed later when probabilities are available
69 continue;
70 end
71
72 % Find the chain and reference station for this cache
73 for c = 1:sn.nchains
74 inchain = sn.inchain{c};
75 refstat = sn.refstat(c);
76 totalTput = sum(TN(refstat, inchain));
77
78 % Set throughput for hit/miss classes
79 for origClass = 1:length(hitclass)
80 if hitclass(origClass) > 0 && hitclass(origClass) <= R
81 TN_stateful(sf, hitclass(origClass)) = totalTput * actualHitProb(origClass);
82 end
83 if missclass(origClass) > 0 && missclass(origClass) <= R
84 TN_stateful(sf, missclass(origClass)) = totalTput * actualMissProb(origClass);
85 end
86 end
87 end
88 end
89 end
90 end
91
92 % Propagate throughputs to non-station, non-Cache stateful nodes
93 % (e.g., Router) using already-known station throughputs and the rt matrix
94 for sf = 1:nStateful
95 ind = statefulNodes(sf);
96 ist = sn.nodeToStation(ind);
97 if ~(ist > 0) && sn.nodetype(ind) ~= NodeType.Cache
98 % Compute throughput from upstream stateful nodes
99 for sf_src = 1:nStateful
100 for k = 1:R
101 for r = 1:R
102 TN_stateful(sf, k) = TN_stateful(sf, k) + TN_stateful(sf_src, r) * sn.rt((sf_src-1)*R+r, (sf-1)*R+k);
103 end
104 end
105 end
106 end
107 end
108
109 % Compute arrival rates using stateful node throughputs and rt matrix
110 for ist=1:M
111 ind_ist = sn.stationToNode(ist);
112 if sn.nodetype(ind_ist)==NodeType.Source
113 AN(ist,:) = 0;
114 else
115 % Find the position of this station in the stateful node list
116 sf_ist = find(statefulNodes == ind_ist);
117 if isempty(sf_ist)
118 continue;
119 end
120
121 for sf_jst = 1:nStateful
122 for k=1:R
123 for r=1:R
124 AN(ist,k) = AN(ist,k) + TN_stateful(sf_jst,r)*sn.rt((sf_jst-1)*R+r, (sf_ist-1)*R+k);
125 end
126 end
127 end
128 end
129 end
130else
131 AN = [];
132end
133
134if any(sn.fj(:))
135 ANn = sn_get_node_arvr_from_tput(sn, TN, TH, AN);
136 for ist=1:M
137 AN(ist,:) = ANn(sn.stationToNode(ist),:);
138 end
139end
140
141end
Definition mmt.m:92