LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_pn_avg_rates.m
1%{ @file sn_pn_avg_rates.m
2 % @brief Converts Place throughputs from firing events to tokens and derives
3 % the matching arrival and response times
4 %
5 % @author LINE Development Team
6%}
7
8%{
9 % @brief Place throughput, arrival rate and response time in tokens
10 %
11 % @details
12 % A Place is a station and a token is the job it holds, so a firing that
13 % consumes two tokens is two departures, not one. The CTMC and SSA analyzers
14 % count firing events instead, which for unit arc multiplicities is the same
15 % number and for weighted arcs is not: the reported throughput is then not a
16 % token rate, and QLen over it is not a sojourn time. On a net where a Place
17 % is drained by an arc of weight 2 and another of weight 3, the event count
18 % gave RespT 1.6243 where Little's law on tokens gives 0.7119, which is the
19 % value SolverJMT measures.
20 %
21 % This function rescales the Place rows to tokens:
22 %
23 % TN(p,k) tokens consumed from the Place per unit time
24 % AN(p,k) tokens produced into the Place per unit time
25 % RN(p,k) QN(p,k) / TN(p,k), Little's law over the Place
26 %
27 % Rows that do not belong to a Place are returned untouched, so a mixed
28 % Queue/Place model keeps its queueing metrics. When the firing rates cannot
29 % be recovered from the throughputs the inputs are returned unchanged rather
30 % than replaced by a guess.
31 %
32 % @par Syntax:
33 % @code
34 % [TN, AN, RN] = sn_pn_avg_rates(sn, QN, TN, AN, RN)
35 % @endcode
36 %
37 % @par Parameters:
38 % <table>
39 % <tr><th>Name<th>Description
40 % <tr><td>sn<td>Network structure
41 % <tr><td>QN<td>Average queue lengths, i.e. mean token counts at the Places
42 % <tr><td>TN<td>Average throughputs at stations, counting firing events
43 % <tr><td>AN<td>Average arrival rates at stations, as computed by the caller
44 % <tr><td>RN<td>Average response times at stations, as computed by the caller
45 % </table>
46 %
47 % @par Returns:
48 % <table>
49 % <tr><th>Name<th>Description
50 % <tr><td>TN<td>Throughputs, with the Place rows counting tokens
51 % <tr><td>AN<td>Arrival rates, with the Place rows counting tokens
52 % <tr><td>RN<td>Response times, with the Place rows following Little's law
53 % </table>
54%}
55function [TN, AN, RN] = sn_pn_avg_rates(sn, QN, TN, AN, RN)
56
57if isempty(TN) || ~any(sn.nodetype == NodeType.Place)
58 return
59end
60
61% The analyzers hand over event counts, hence the false.
62[x, consumed, produced, placeNodes] = sn_pn_firing_rates(sn, TN, false);
63if isempty(x)
64 return
65end
66
67R = sn.nclasses;
68for pp = 1:length(placeNodes)
69 ist = sn.nodeToStation(placeNodes(pp));
70 if ~(ist > 0)
71 continue
72 end
73 for k = 1:R
74 TN(ist, k) = consumed(:, pp, k)' * x;
75 if ~isempty(AN)
76 AN(ist, k) = produced(:, pp, k)' * x;
77 end
78 if ~isempty(RN)
79 if TN(ist, k) > 0
80 RN(ist, k) = QN(ist, k) / TN(ist, k);
81 else
82 RN(ist, k) = 0;
83 end
84 end
85 end
86end
87end