LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
solver_mam_traffic.m
1function ARV = solver_mam_traffic(sn, DEP, config)
2% ARV = SOLVER_MAM_ESTFLOWS(QN, DEP, CONFIG)
3% DEP{i,r} is the departure process of class r from i in (D0,D1) format
4
5I = sn.nnodes;
6C = sn.nchains;
7R = sn.nclasses;
8
9% In this function we use indexing over all non-ClassSwitch nodes
10non_cs_classes = [];
11isNCS = zeros(1,I);
12nodeToNCS = zeros(1,I);
13for ind=1:I
14 if sn.nodetype(ind) ~= NodeType.ClassSwitch
15 non_cs_classes(end+1:end+R)= ((ind-1)*R+1):(ind*R);
16 isNCS(ind) = true;
17 nodeToNCS(ind) = sum(isNCS);
18 else
19 isNCS(ind) = false;
20 end
21end
22
23% Hide the nodes that are not class switches
24rtncs = dtmc_stochcomp(sn.rtnodes,non_cs_classes);
25Inc = I - sum(sn.nodetype == NodeType.ClassSwitch);
26
27MMAP = DEP; % PH renewal process initially in (D0,D1) format
28
29% We now bring into MMAP format with a single class
30for ist=1:size(MMAP,1)
31 for r=1:size(MMAP,2)
32 if isempty(MMAP{ist,r}) || any(any(isnan(MMAP{ist,r}{1})))
33 MMAP{ist,r} = {[0],[0],[0]}; % no arrivals from this class
34 else
35 MMAP{ist,r}{3} = MMAP{ist,r}{2};
36 end
37 end
38end
39
40ARV = cell(Inc,1);
41DEP = cell(Inc,R);
42LINKS = cell(Inc,Inc);
43% first we determine all outgoing flows from all stations
44for ind=1:I
45 if isNCS(ind)
46 inc = nodeToNCS(ind);
47 switch sn.nodetype(ind)
48 case {NodeType.Source, NodeType.Delay, NodeType.Queue}
49 ist = sn.nodeToStation(ind);
50
51 % obtain departure maps
52 if R>1
53 % Order-preserving bounded superposition: superpose the
54 % per-class departures in class order, compressing the phase
55 % dimension back to config.space_max whenever it is exceeded,
56 % so the raw Kronecker product cannot exhaust memory (cf. the
57 % FJ variant solver_mam_traffic_mmap). The arrival is compressed
58 % to config.space_max downstream (solver_mam) regardless.
59 DEP{inc} = MMAP{ist,1};
60 for rr=2:R
61 DEP{inc} = mmap_super(DEP{inc}, MMAP{ist,rr});
62 if length(DEP{inc}{1}) > config.space_max
63 DEP{inc} = mmap_compress(DEP{inc}, config);
64 end
65 end
66 else
67 DEP{inc} = MMAP{ist,1};
68 end
69 Psplit = zeros(R,Inc*R);
70 for r=1:R % superpose all classes
71 for jnd = 1:I %to
72 if isNCS(jnd)
73 jnc = nodeToNCS(jnd);
74 for s=1:R %to
75 Psplit(r,(jnc-1)*R+s) = rtncs((inc-1)*R+r, (jnc-1)*R+s);
76 end
77 end
78 end
79 end
80
81 [Fsplit{1:Inc}] = npfqn_traffic_split_cs(DEP{inc}, Psplit, config);
82 for jnc=1:Inc
83 LINKS{inc,jnc} = Fsplit{jnc};
84 LINKS{inc,jnc} = mmap_normalize(LINKS{inc,jnc});
85 end
86 end
87 end
88end
89% then we determine all incoming flows from all stations
90for ind=1:I
91 FLOWS={};
92 if isNCS(ind) && sn.nodetype(ind) ~= NodeType.Source
93 inc = nodeToNCS(ind);
94 for jnd=1:Inc
95 if ~isempty(LINKS{jnd,inc}) && sum(mmap_lambda(LINKS{jnd,inc}))> GlobalConstants.FineTol
96 FLOWS{end+1} = LINKS{jnd,inc};
97 end
98 end
99 if length(FLOWS)>1
100 ARV{ind} = npfqn_traffic_merge(FLOWS, config);
101 elseif length(FLOWS)==1
102 ARV{ind} = FLOWS{1};
103 else %length(FLOWS)==0
104 ARV{ind} = LINKS{jnd,1}; % all links are zeros, take one
105 end
106 else
107 ARV{ind} = [];
108 end
109end
110end
Definition mmt.m:124