LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getResultsJMVA.m
1function [result, parsed] = getResultsJMVA(self)
2% [RESULT, PARSED] = GETRESULTSJMVA()
3
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7try
8 fileName = [getFileName(self),'.jmva-result.jmva'];
9 filePath = [getFilePath(self),filesep,fileName];
10 if exist(filePath,'file')
11 Pref.Str2Num = 'always';
12 parsed = xml_read(filePath,Pref);
13 else
14 line_error(mfilename,'JMT did not output a result file, the analysis has likely failed.');
15 end
16catch ME
17 line_error(mfilename,'Unknown error upon parsing JMT result file. ');
18end
19self.result.('solver') = getName(self);
20self.result.('model') = parsed.ATTRIBUTE;
21self.result.('metric') = {};
22self.result.('Prob') = struct();
23try
24 % older JMVA versions do not have the logValue field and will throw an
25 % exception
26 switch class(parsed.solutions.algorithm.normconst.ATTRIBUTE.logValue)
27 case 'double'
28 self.result.Prob.logNormConstAggr = parsed.solutions.algorithm.normconst.ATTRIBUTE.logValue;
29 otherwise
30 self.result.Prob.logNormConstAggr = NaN;
31 end
32catch
33 self.result.Prob.logNormConstAggr = NaN;
34end
35
36sn = self.getStruct;
37%%%
38M = sn.nstations; %number of stations
39S = sn.nservers;
40NK = sn.njobs'; % initial population per class
41C = sn.nchains;
42SCV = sn.scv;
43
44% determine service times
45ST = 1./sn.rates;
46ST(isnan(sn.rates))=0;
47SCV(isnan(SCV))=1;
48
49[~,STchain,Vchain,alpha,~,~] = sn_get_demands_chain(sn);
50%%%
51statres = parsed.solutions.algorithm.stationresults;
52
53for k=1:sn.nclasses
54 for i=1:sn.nstations
55 switch sn.nodetype(self.getStruct.stationToNode(i))
56 case NodeType.Source
57 s = struct();
58 s.('alfa') = NaN;
59 s.('analyzedSamples') = Inf;
60 s.('class') = sn.classnames{k};
61 s.('discardedSamples') = 0;
62 s.('lowerLimit') = sn.rates(i,k);
63 s.('maxSamples') = Inf;
64 s.('meanValue') = sn.rates(i,k);
65 s.('measureType') = MetricType.toText(MetricType.Tput);
66 s.('nodeType') = 'station';
67 s.('precision') = Inf;
68 s.('station') = sn.nodenames{self.getStruct.stationToNode(i)};
69 s.('successful') = 'true';
70 s.('upperLimit') = sn.rates(i,k);
71 self.result.metric{end+1} = s;
72
73 s = struct();
74 s.('alfa') = NaN;
75 s.('analyzedSamples') = Inf;
76 s.('class') = sn.classnames{k};
77 s.('discardedSamples') = 0;
78 s.('lowerLimit') = 0;
79 s.('maxSamples') = Inf;
80 s.('meanValue') = 0;
81 s.('measureType') = MetricType.toText(MetricType.QLen);
82 s.('nodeType') = 'station';
83 s.('precision') = Inf;
84 s.('station') = sn.nodenames{self.getStruct.stationToNode(i)};
85 s.('successful') = 'true';
86 s.('upperLimit') = 0;
87 self.result.metric{end+1} = s;
88
89 s = struct();
90 s.('alfa') = NaN;
91 s.('analyzedSamples') = Inf;
92 s.('class') = sn.classnames{k};
93 s.('discardedSamples') = 0;
94 s.('lowerLimit') = 0;
95 s.('maxSamples') = Inf;
96 s.('meanValue') = 0;
97 s.('measureType') = MetricType.toText(MetricType.RespT);
98 s.('nodeType') = 'station';
99 s.('precision') = Inf;
100 s.('station') = sn.nodenames{self.getStruct.stationToNode(i)};
101 s.('successful') = 'true';
102 s.('upperLimit') = 0;
103 self.result.metric{end+1} = s;
104
105 s = struct();
106 s.('alfa') = NaN;
107 s.('analyzedSamples') = Inf;
108 s.('class') = sn.classnames{k};
109 s.('discardedSamples') = 0;
110 s.('lowerLimit') = 0;
111 s.('maxSamples') = Inf;
112 s.('meanValue') = 0;
113 s.('measureType') = MetricType.toText(MetricType.Util);
114 s.('nodeType') = 'station';
115 s.('precision') = Inf;
116 s.('station') = sn.nodenames{self.getStruct.stationToNode(i)};
117 s.('successful') = 'true';
118 s.('upperLimit') = 0;
119 self.result.metric{end+1} = s;
120 end
121 end
122end
123
124%%
125%Rchain
126%Xchain
127%Tchain
128% for c=1:sn.nchains
129% inchain = sn.inchain{c};
130% for k=inchain(:)'
131% X(k) = Xchain(c) * alpha(sn.refstat(k),k);
132% for i=1:sn.nstations
133% if isinf(S(i))
134% U(i,k) = ST(i,k) * (Xchain(c) * Vchain(i,c) / Vchain(sn.refstat(k),c)) * alpha(i,k);
135% else
136% U(i,k) = ST(i,k) * (Xchain(c) * Vchain(i,c) / Vchain(sn.refstat(k),c)) * alpha(i,k) / S(i);
137% end
138% if Lchain(i,c) > 0
139% Q(i,k) = Rchain(i,c) * ST(i,k) / STchain(i,c) * Xchain(c) * Vchain(i,c) / Vchain(sn.refstat(k),c) * alpha(i,k);
140% T(i,k) = Tchain(i,c) * alpha(i,k);
141% R(i,k) = Q(i,k) / T(i,k);
142% else
143% T(i,k) = 0;
144% R(i,k)=0;
145% Q(i,k)=0;
146% end
147% end
148% C(k) = sn.njobs(k) / X(k);
149% end
150% end
151% Q=abs(Q); R=abs(R); X=abs(X); U=abs(U); T=abs(T); C=abs(C);
152% T(~isfinite(T))=0; U(~isfinite(U))=0; Q(~isfinite(Q))=0; R(~isfinite(R))=0; X(~isfinite(X))=0; C(~isfinite(C))=0;
153%%
154
155for i=1:length(statres)
156 classres = statres(i).classresults;
157 for c=1:length(classres)
158 inchain = sn.inchain{c};
159 for m=1:length(classres(c).measure)
160 for k=inchain(:)'
161 s = struct();
162 s.('alfa') = NaN;
163 s.('analyzedSamples') = Inf;
164 s.('class') = sn.classnames{k};
165 s.('discardedSamples') = 0;
166 s.('meanValue') = classres(c).measure(m).ATTRIBUTE.meanValue;
167 if strcmp(s.meanValue,'NaN')
168 s.meanValue = NaN;
169 end
170 s.('maxSamples') = Inf;
171 s.('measureType') = classres(c).measure(m).ATTRIBUTE.measureType;
172 switch classres(c).measure(m).ATTRIBUTE.measureType
173 case 'Utilization'
174 if isinf(sn.nservers(i))
175 s.meanValue = ST(i,k) * (s.meanValue / STchain(i,c)) * Vchain(i,c) / Vchain(sn.refstat(k),c) * alpha(i,k);
176 else
177 s.meanValue = ST(i,k) * (s.meanValue / STchain(i,c)) / Vchain(sn.refstat(k),c) * alpha(i,k) * min(sum(NK(isfinite(NK))), sn.nservers(i)) / sn.nservers(i);
178 end
179 s.('measureType') = classres(c).measure(m).ATTRIBUTE.measureType;
180 case 'Throughput'
181 s.meanValue = s.meanValue * alpha(i,k);
182 case 'Number of Customers'
183 % Q(i,k) = Rchain(i,c) * ST(i,k) / STchain(i,c) * Xchain(c) * Vchain(i,c) / Vchain(sn.refstat(k),c) * alpha(i,k);
184 s.meanValue = s.meanValue * ST(i,k) / STchain(i,c) / Vchain(sn.refstat(k),c) * alpha(i,k);
185 case 'Residence time'
186 s.('measureType') = 'Response Time';
187 s.meanValue = s.meanValue / sn.visits{c}(i,k); % this is to convert from JMVA's residence into LINE's response time per visit
188 if isinf(sn.nservers(i))
189 s.meanValue = s.meanValue * ST(i,k) / STchain(i,c) / Vchain(sn.refstat(k),c) * alpha(i,k);
190 else
191 s.meanValue = s.meanValue * ST(i,k) / STchain(i,c) / Vchain(sn.refstat(k),c) * alpha(i,k);
192 end
193 otherwise
194 s.('measureType') = classres(c).measure(m).ATTRIBUTE.measureType;
195 end
196 s.('lowerLimit') = s.meanValue;
197 s.('upperLimit') = s.meanValue;
198 s.('nodeType') = 'station';
199 s.('precision') = Inf;
200 s.('station') = statres(i).ATTRIBUTE.station;
201 s.('successful') = classres(c).measure(m).ATTRIBUTE.successful;
202 self.result.metric{end+1} = s;
203 end
204 end
205 end
206end
207result = self.result;
208end