1function space = spaceLocalVars(sn, ind)
2% SPACE = SPACELOCALVARS(QN, IND)
4% Copyright (c) 2012-2026, Imperial College London
7% Generate state space
for local state variables
10%ist = sn.nodeToStation(ind);
11%isf = sn.nodeToStateful(ind);
15switch sn.nodetype(ind)
18 if isfield(sn.nodeparam{ind},
'retrievalSystemCapacity')
19 rsCap = sn.nodeparam{ind}.retrievalSystemCapacity;
21 space = State.spaceCache(sn.nodeparam{ind}.nitems, sn.nodeparam{ind}.itemcap, rsCap);
25 switch sn.routing(ind,r)
26 case RoutingStrategy.RROBIN
27 % RR slot holds the destination node index — enumerate over outlinks.
28 space = State.cartesian(space, sn.nodeparam{ind}{r}.outlinks(:));
29 case RoutingStrategy.WRROBIN
30 % WRR slot holds the POSITION in weighted_outlinks (1..len) —
31 % enumerate positions; afterEventRouter advances the position
32 % cyclically and sub_wrr maps it back to a destination.
33 np = sn.nodeparam{ind}{r};
34 if isfield(np,
'weighted_outlinks') && ~isempty(np.weighted_outlinks)
35 positions = (1:length(np.weighted_outlinks))';
37 positions = (1:length(np.outlinks))';
39 space = State.cartesian(space, positions);