LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
findPathsCS.m
1% Finds the response times along each path leading out of start until
2% endNode taking into account class swithces
3function ri = findPathsCS(sn, P, curNode, endNode, curClass, toMerge, QN, TN, currentTime, fjclassmap, fjforkmap, nonfjmodel)
4 if curNode == endNode
5 % Add the current response time of the parallel branch to the list, but subtract the synchronisation time
6 qLen = sum(QN(sn.nodeToStation(curNode), toMerge));
7 tput = sum(TN(sn.nodeToStation(curNode), toMerge));
8 ri = currentTime - qLen / tput;
9 return
10 end
11 ri = [];
12 nfjsn = nonfjmodel.getStruct(false);
13 orignodes = length(nfjsn.rtorig{1,1});
14 for transition=find(P((curClass-1)*orignodes+curNode, :))
15 curMerge = toMerge;
16 nextClass = floor((transition - 1) / orignodes) + 1;
17 nextNode = transition-(nextClass-1) * orignodes; % new class
18 curMerge(1) = nextClass;
19 qLen = 0;
20 tput = 1;
21 if ~isnan(sn.nodeToStation(nextNode))
22 qLen = sum(QN(sn.nodeToStation(nextNode), curMerge));
23 tput = sum(TN(sn.nodeToStation(nextNode), curMerge));
24 end
25 if sn.nodetype(nextNode) == NodeType.Fork
26 joinIdx = find(sn.fj(nextNode,:));
27 s = find(fjforkmap == nextNode & fjclassmap == nextClass);
28 paths = ModelAdapter.findPathsCS(sn, P, nextNode, joinIdx, nextClass, [curMerge,s], QN, TN, 0, fjclassmap, fjforkmap, nonfjmodel);
29 lambdai = 1./paths;
30 d0 = 0;
31 parallel_branches = length(paths);
32 for pow=0:(parallel_branches - 1)
33 current_sum = sum(1./sum(nchoosek(lambdai, pow + 1),2));
34 d0 = d0 + (-1)^pow * current_sum;
35 end
36 for cls=[curMerge,s]
37 nonfjmodel.nodes{joinIdx}.setService(nonfjmodel.classes{cls}, Exp.fitMean((d0 - mean(paths))));
38 end
39 ri = [ri, ModelAdapter.findPathsCS(sn, P, joinIdx, endNode, nextClass, curMerge, QN, TN, currentTime + d0, fjclassmap, fjforkmap, nonfjmodel)];
40 else
41 ri = [ri, ModelAdapter.findPathsCS(sn, P, nextNode, endNode, nextClass, curMerge, QN, TN, currentTime + qLen/tput, fjclassmap, fjforkmap, nonfjmodel)];
42 end
43 end
44end