LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
spaceLocalVars.m
1function space = spaceLocalVars(sn, ind)
2% SPACE = SPACELOCALVARS(QN, IND)
3
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7% Generate state space for local state variables
8
9%ind: node index
10%ist = sn.nodeToStation(ind);
11%isf = sn.nodeToStateful(ind);
12
13space = [];
14
15switch sn.nodetype(ind)
16 case NodeType.Cache
17 space = State.spaceCache(sn.nodeparam{ind}.nitems,sn.nodeparam{ind}.itemcap);
18end
19
20for r=1:sn.nclasses
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))';
32 else
33 positions = (1:length(np.outlinks))';
34 end
35 space = State.cartesian(space, positions);
36 end
37end
38end