LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_get_buffer_size.m
1%{ @file sn_get_buffer_size.m
2 % @brief Physical buffer size of a station, in jobs
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Returns the number of jobs a station can hold, in service included
9 %
10 % @details
11 % Kendall's K: the total occupancy bound of station IST, obtained as the
12 % tighter of the station capacity sn.cap(ist) and the per-class capacities
13 % sn.classcap(ist,:). Returns Inf when the station is unbounded. Both
14 % fields are populated by refreshCapacity, which already folds setCapacity,
15 % setClassCapacity, a finite orbit and the closed-chain population into
16 % them, so this is the single place that decides whether a buffer BINDS.
17 %
18 % Only a buffer that can actually BIND is reported. refreshCapacity derives
19 % a FINITE classcap (the chain population) for EVERY closed model, so a
20 % plain finiteness test would report a buffer at every station of every
21 % closed model; a capacity at least as large as the total population can
22 % never refuse a job and is returned as Inf. sum(njobs) is Inf as soon as
23 % one class is open, so any finite capacity reachable by an open class
24 % binds.
25 %
26 % @par Syntax:
27 % @code
28 % N = sn_get_buffer_size(sn, ist)
29 % @endcode
30 %
31 % @par Parameters:
32 % <table>
33 % <tr><th>Name<th>Description
34 % <tr><td>sn<td>Network structure
35 % <tr><td>ist<td>Station index
36 % </table>
37 %
38 % @par Returns:
39 % <table>
40 % <tr><th>Name<th>Description
41 % <tr><td>N<td>Buffer size in jobs, Inf if unbounded
42 % </table>
43%}
44function N = sn_get_buffer_size(sn, ist)
45N = Inf;
46if isfield(sn, 'cap') && ~isempty(sn.cap) && numel(sn.cap) >= ist
47 if sn.cap(ist) >= 0
48 N = min(N, sn.cap(ist));
49 end
50end
51if isfield(sn, 'classcap') && ~isempty(sn.classcap) && size(sn.classcap, 1) >= ist
52 ccap = sn.classcap(ist, :);
53 ccap = ccap(ccap > 0); % a zero marks a class that is not served here
54 if ~isempty(ccap)
55 N = min(N, sum(ccap));
56 end
57end
58if isfield(sn, 'njobs') && ~isempty(sn.njobs)
59 totalJobs = sum(sn.njobs(:));
60 if N >= totalJobs
61 N = Inf; % declared but unreachable: the buffer can never refuse a job
62 end
63end
64end