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 DEP{inc} = mmap_super({MMAP{ist,1:R}});
54 else
55 DEP{inc} = MMAP{ist,1};
56 end
57 Psplit = zeros(R,Inc*R);
58 for r=1:R % superpose all classes
59 for jnd = 1:I %to
60 if isNCS(jnd)
61 jnc = nodeToNCS(jnd);
62 for s=1:R %to
63 Psplit(r,(jnc-1)*R+s) = rtncs((inc-1)*R+r, (jnc-1)*R+s);
64 end
65 end
66 end
67 end
68
69 [Fsplit{1:Inc}] = npfqn_traffic_split_cs(DEP{inc}, Psplit, config);
70 for jnc=1:Inc
71 LINKS{inc,jnc} = Fsplit{jnc};
72 LINKS{inc,jnc} = mmap_normalize(LINKS{inc,jnc});
73 end
74 end
75 end
76end
77% then we determine all incoming flows from all stations
78for ind=1:I
79 FLOWS={};
80 if isNCS(ind) && sn.nodetype(ind) ~= NodeType.Source
81 inc = nodeToNCS(ind);
82 for jnd=1:Inc
83 if ~isempty(LINKS{jnd,inc}) && sum(mmap_lambda(LINKS{jnd,inc}))> GlobalConstants.FineTol
84 FLOWS{end+1} = LINKS{jnd,inc};
85 end
86 end
87 if length(FLOWS)>1
88 ARV{ind} = npfqn_traffic_merge(FLOWS, config);
89 elseif length(FLOWS)==1
90 ARV{ind} = FLOWS{1};
91 else %length(FLOWS)==0
92 ARV{ind} = LINKS{jnd,1}; % all links are zeros, take one
93 end
94 else
95 ARV{ind} = [];
96 end
97end
98end
Definition mmt.m:92