LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
lsn_max_multiplicity.m
1%{ @file lsn_max_multiplicity.m
2 % @brief Computes the maximum multiplicity of nodes in a Layered Software Network
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Computes maximum multiplicity (concurrency level) for LSN nodes
9 %
10 % @details
11 % This function computes the maximum multiplicity (throughput capacity) for
12 % each node in a Layered Software Network (LSN). Uses Kahn's algorithm for
13 % topological sorting to propagate constraints through the network.
14 %
15 % @par Syntax:
16 % @code
17 % outflow = lsn_max_multiplicity(lsn)
18 % @endcode
19 %
20 % @par Parameters:
21 % <table>
22 % <tr><th>Name<th>Description
23 % <tr><td>lsn<td>Layered Software Network structure
24 % </table>
25 %
26 % @par Returns:
27 % <table>
28 % <tr><th>Name<th>Description
29 % <tr><td>outflow<td>Maximum multiplicity (throughput capacity) for each node
30 % </table>
31%}
32function outflow = lsn_max_multiplicity(lsn)
33ag = lsn.dag > 0;
34mult = lsn.mult;
35type = lsn.type;
36isref = lsn.isref;
37n = size(ag, 1);
38
39% Manual topological sort (Kahn's algorithm)
40order = kahn(ag);
41
42% initially load ref task multiplicity
43inflow = zeros(n,1);
44for i = 1:n
45 if type(i) == LayeredNetworkElement.TASK && isref(i)
46 inflow(i) = mult(i);
47 % Also account for entries with open arrivals
48 elseif type(i) == LayeredNetworkElement.ENTRY
49 if isfield(lsn, 'arrival') && ~isempty(lsn.arrival) && ...
50 iscell(lsn.arrival) && i <= length(lsn.arrival) && ...
51 ~isempty(lsn.arrival{i})
52 % Entry has open arrival - needs at least 1 thread of its parent task
53 inflow(i) = 1;
54 end
55 end
56end
57outflow = zeros(n,1);
58
59if length(mult) < n
60 mult(end+1:n) = Inf;
61end
62
63for k = 1:n
64 i = order(k);
65 outflow(i) = min(inflow(i), mult(i));
66 for j = [1:i-1,i+1:n]
67 if ag(i,j)
68 inflow(j) = inflow(j) + outflow(i);
69 end
70 end
71end
72%inflow(type > LayeredNetworkElement.TASK )=0;
73for i = 1:n
74 if type(i) == LayeredNetworkElement.TASK && mult(i)==Inf && ~isref(i)
75 outflow(i) = Inf;
76 end
77end
78end
Definition mmt.m:92