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 % Compute arrival rates using stateful node throughputs and rt matrix
93 for ist=1:M
94 ind_ist = sn.stationToNode(ist);
95 if sn.nodetype(ind_ist)==NodeType.Source
96 AN(ist,:) = 0;
97 else
98 % Find the position of this station in the stateful node list
99 sf_ist = find(statefulNodes == ind_ist);
100 if isempty(sf_ist)
101 continue;
102 end
103
104 for sf_jst = 1:nStateful
105 for k=1:R
106 for r=1:R
107 AN(ist,k) = AN(ist,k) + TN_stateful(sf_jst,r)*sn.rt((sf_jst-1)*R+r, (sf_ist-1)*R+k);
108 end
109 end
110 end
111 end
112 end
113else
114 AN = [];
115end
116
117if any(sn.fj(:))
118 ANn = sn_get_node_arvr_from_tput(sn, TN, TH, AN);
119 for ist=1:M
120 AN(ist,:) = ANn(sn.stationToNode(ist),:);
121 end
122end
123
124end
Definition mmt.m:92