LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_get_node_arvr_from_tput.m
1%{ @file sn_get_node_arvr_from_tput.m
2 % @brief Computes average arrival rates at nodes from station throughputs
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Computes average arrival rates at nodes from station throughputs
9 %
10 % @details
11 % This function calculates the average arrival rate at each node in steady-state
12 % from the station throughputs, accounting for node-level routing and visits.
13 %
14 % @par Syntax:
15 % @code
16 % ANn = sn_get_node_arvr_from_tput(sn, TN, TH)
17 % ANn = sn_get_node_arvr_from_tput(sn, TN, TH, AN)
18 % @endcode
19 %
20 % @par Parameters:
21 % <table>
22 % <tr><th>Name<th>Description
23 % <tr><td>sn<td>Network structure
24 % <tr><td>TN<td>Average throughputs at stations
25 % <tr><td>TH<td>Throughput handles
26 % <tr><td>AN<td>(Optional) Average arrival rates at stations; computed if missing
27 % </table>
28 %
29 % @par Returns:
30 % <table>
31 % <tr><th>Name<th>Description
32 % <tr><td>ANn<td>Average arrival rates at nodes
33 % </table>
34%}
35function ANn=sn_get_node_arvr_from_tput(sn, TN, TH, AN)
36
37I = sn.nnodes;
38C = sn.nchains;
39M = sn.nstations;
40R = sn.nclasses;
41
42if nargin<4
43 AN = sn_get_arvr_from_tput(sn, TN, TH);
44end
45
46ANn = zeros(I,R);
47if ~isempty(TH) && ~isempty(TN)
48 for ist=1:M
49 ind = sn.stationToNode(ist);
50 ANn(ind,:) = AN(ist,:);
51 end
52 for ind=1:I
53 for c = 1:C
54 inchain = sn.inchain{c};
55 refstat = sn.refstat(c);
56 for r = inchain
57 if sn.nodetype(ind) ~= NodeType.Source
58 switch sn.nodetype(ind)
59 case NodeType.Cache
60 % For cache nodes, only the requesting class arrives
61 % Hit/miss classes don't arrive - they leave
62 hitclass = sn.nodeparam{ind}.hitclass;
63 missclass = sn.nodeparam{ind}.missclass;
64 if ~(any(find(r==hitclass)) || any(find(r==missclass)))
65 % This is a requesting class (e.g., ClientClass)
66 % Arrival rate = total throughput for this class
67 ANn(ind, r) = (sn.nodevisits{c}(ind,r) / sum(sn.visits{c}(sn.stationToStateful(refstat),inchain))) * sum(TN(refstat,inchain));
68 end
69 % Hit/miss classes have 0 arrival rate at cache (they only depart)
70 otherwise
71 % For station nodes, the arrival rate is already set from AN
72 % Only use nodevisits for non-station nodes (like ClassSwitch, Sink)
73 % Note: nodeToStation is NaN for non-stations like Sink, so use ~(>0) check
74 if ~(sn.nodeToStation(ind) > 0)
75 ANn(ind, r) = (sn.nodevisits{c}(ind,r) / sum(sn.visits{c}(sn.stationToStateful(refstat),inchain))) * sum(TN(refstat,inchain));
76 end
77 end
78 end
79 end
80 end
81 end
82 ANn(isnan(ANn)) = 0;
83else
84 ANn = [];
85end
86end
Definition mmt.m:92