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)
17 space = State.spaceCache(sn.nodeparam{ind}.nitems,sn.nodeparam{ind}.itemcap);
21 switch sn.routing(ind,r)
22 case RoutingStrategy.RROBIN
23 % RR slot holds the destination node index — enumerate over outlinks.
24 space = State.cartesian(space, sn.nodeparam{ind}{r}.outlinks(:));
25 case RoutingStrategy.WRROBIN
26 % WRR slot holds the POSITION in weighted_outlinks (1..len) —
27 % enumerate positions; afterEventRouter advances the position
28 % cyclically and sub_wrr maps it back to a destination.
29 np = sn.nodeparam{ind}{r};
30 if isfield(np,
'weighted_outlinks') && ~isempty(np.weighted_outlinks)
31 positions = (1:length(np.weighted_outlinks))';
33 positions = (1:length(np.outlinks))';
35 space = State.cartesian(space, positions);