1function [chains,
visits, rt,
nodevisits, rtnodes] = refreshChains(self, propagate)
2% [CHAINS, VISITS,
RT, NODEVISITS, RTNODES] = REFRESHCHAINS(PROPAGATE)
4% PROPAGATE :
true if the change needs to trigger recomputation of
visits and station capacities (
default: true)
6% Copyright (c) 2012-2026, Imperial College London
13%% obtain routing matrix
16[rt,~,rtnodes] = self.refreshRoutingMatrix(rates);
19%% determine
class switching mask
20stateful = find(sn.isstateful); stateful = stateful(:)
';
22if isempty(self.csMatrix) % only for models created without a call to link()
26 for isf=1:length(stateful) % source
27 for jsf=1:length(stateful) % source
28 if rt((isf-1)*K+r, (jsf-1)*K+s) > 0
29 % this is to ensure that we use rt, which is
30 % the stochastic complement taken over the stateful
31 % nodes, otherwise sequences of cs can produce a wrong
40 for isf=1:length(stateful) % source
41 % this is to ensure that also stateful cs like caches
43 ind = sn.statefulToNode(isf);
44 isCS = sn.nodetype(ind) == NodeType.Cache | sn.nodetype(ind) == NodeType.ClassSwitch;
50 if self.nodes{ind}.server.csFun(r,s,[],[])>0
60 % Start with csMatrix from link(), but also include any transitions
61 % that may have been created by stochastic complement through
62 % non-stateful nodes (e.g., auto-added ClassSwitch nodes)
63 csmask = self.csMatrix;
66 for isf=1:length(stateful)
67 for jsf=1:length(stateful)
68 if rt((isf-1)*K+r, (jsf-1)*K+s) > 0
78if isfield(sn,'refclass
') && length(sn.refclass)<sn.nchains
79 % if the number of chains changed dynamically, extend refclass
80 sn.refclass(end+1:sn.nchains) = 0;
87 [visits, nodevisits, sn] = sn_refresh_visits(sn, sn.chains, rt, rtnodes);
92%% call dependent capacity refresh
94 refreshCapacity(self); % capacity depends on chains and rates