LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
refreshRates.m
1function [rates, scv, hasRateChanged, hasSCVChanged] = refreshRates(self, statSet, classSet)
2% [RATES, SCV] = REFRESHRATES()
3
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7hasRateChanged = false;
8hasSCVChanged = false;
9M = getNumberOfStations(self);
10K = getNumberOfClasses(self);
11if nargin<2
12 statSet = 1:M;
13 classSet = 1:K;
14 rates = zeros(M,K);
15 scv = nan(M,K);
16 hasRateChanged = true;
17 hasSCVChanged = true;
18elseif nargin==2
19 classSet = 1:K;
20 if isempty(self.sn) || isempty(self.sn.rates)
21 rates = zeros(M,K);
22 scv = nan(M,K);
23 hasRateChanged = true;
24 hasSCVChanged = true;
25 else
26 rates = self.sn.rates;
27 scv = self.sn.scv;
28 rates_orig = self.sn.rates;
29 scv_orig = self.sn.scv;
30 end
31elseif nargin==3 % this is used only to update self.sn
32 % we are only updating selected stations and classes so use the
33 % existing ones for the others
34 rates = self.sn.rates;
35 scv = self.sn.scv;
36 rates_orig = self.sn.rates;
37 scv_orig = self.sn.scv;
38end
39hasOpenClasses = self.hasOpenClasses;
40
41stations = self.stations;
42% determine rates
43for i=statSet
44 station_i = stations{i};
45 for r=classSet
46 switch station_i.server.className
47 case 'ServiceTunnel'
48 % do nothing
49 switch class(station_i)
50 case 'Source'
51 if isempty(station_i.input.sourceClasses{r})
52 rates(i,r) = NaN;
53 scv(i,r) = NaN;
54 else
55 distr = station_i.input.sourceClasses{r}{end};
56 if isa(distr,'MarkedMAP') && ~isempty(station_i.markedClasses) && ismember(r, station_i.markedClasses)
57 % Marked arrival: class r receives only the
58 % mark-k stream; its marginal MAP moves the
59 % other marks' transitions into the hidden part
60 % (MarkedMAP.toMAPs).
61 k = find(station_i.markedClasses == r, 1);
62 marginals = distr.toMAPs(k);
63 rates(i,r) = marginals{1}.getRate();
64 scv(i,r) = marginals{1}.getSCV();
65 else
66 rates(i,r) = distr.getRate();
67 scv(i,r) = distr.getSCV();
68 end
69 end
70 case 'Join'
71 rates(i,r) = Inf;
72 scv(i,r) = 0;
73 case 'Place'
74 rates(i,r) = NaN;
75 scv(i,r) = NaN;
76 %Draft SPN code:
77 %rates(i,r) = 1;
78 %scv(i,r) = 0;
79 end
80 otherwise
81 if ~hasOpenClasses || i ~= self.getIndexSourceStation
82 if isempty(station_i.server.serviceProcess{r})
83 rates(i,r) = NaN;
84 scv(i,r) = NaN;
85 else
86 distr = station_i.server.serviceProcess{r}{end};
87 rates(i,r) = distr.getRate();
88 scv(i,r) = distr.getSCV();
89 end
90 end
91 end
92 end
93end
94
95if ~hasRateChanged
96 if any((abs(rates-rates_orig)>0))
97 hasRateChanged = true;
98 end
99end
100
101if ~hasSCVChanged
102 if any((abs(scv-scv_orig)>0))
103 hasSCVChanged = true;
104 end
105end
106
107%if ~isempty(self.sn)
108 if hasRateChanged
109 self.sn.rates = rates;
110 end
111 if hasSCVChanged
112 self.sn.scv = scv;
113 end
114%end
115
116end
Definition Station.m:245