LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
SolverJMT.m
1classdef SolverJMT < NetworkSolver
2 % SolverJMT Java Modelling Tools interface for simulation analysis
3 %
4 % SolverJMT provides an interface to the Java Modelling Tools (JMT) suite
5 % for discrete event simulation of queueing networks. It handles model
6 % translation, simulation execution, and results parsing for both JMVA
7 % (analytical) and JSIM (simulation) engines within JMT.
8 %
9 % @brief Interface to Java Modelling Tools for simulation and analysis
10 %
11 % Example:
12 % @code
13 % solver = SolverJMT(model, 'samples', 10000, 'seed', 1);
14 % solver.getAvg(); % Run simulation via JMT
15 % @endcode
16 %
17 % Copyright (c) 2012-2026, Imperial College London
18 % All rights reserved.
19
20 %Private properties
21 properties %(GetAccess = 'private', SetAccess='private')
22 jmtPath;
23 filePath;
24 fileName;
25 maxSimulatedTime;
26 maxSamples;
27 maxEvents;
28 seed;
29 simConfInt;
30 simMaxRelErr;
31 xmlParser; % JMTIO instance for XML generation
32 end
33
34 %Constants
35 properties (Constant)
36 xsiNoNamespaceSchemaLocation = 'Archive.xsd';
37 fileFormat = 'jsimg';
38 jsimgPath = '';
39 end
40
41 % PUBLIC METHODS
42 methods
43
44 %Constructor
45 function self = SolverJMT(model, varargin)
46 % SOLVERJMT Create a JMT solver instance
47 %
48 % @brief Creates a Java Modelling Tools solver for the given model
49 % @param model Network model to be analyzed via JMT
50 % @param varargin Optional parameters (samples, seed, maxSimulatedTime, etc.)
51 % @return self SolverJMT instance configured for JMT simulation
52
53 self@NetworkSolver(model, mfilename);
54 self.setOptions(Solver.parseOptions(varargin, self.defaultOptions));
55 self.setLang();
56 if ~Solver.isJavaAvailable
57 line_error(mfilename,'SolverJMT requires the java command to be available on the system path.\n');
58 end
59 if ~SolverJMT.isAvailable
60 line_warning(mfilename,'SolverJMT cannot locate JMT.jar in the common folder.\n');
61 end
62 % Set confidence interval from options (default: 0.99 for 99% confidence)
63 [confintEnabled, confintLevel] = Solver.parseConfInt(self.options.confint);
64 if confintEnabled
65 self.simConfInt = confintLevel;
66 else
67 self.simConfInt = 0.99; % default when disabled
68 end
69 self.simMaxRelErr = 0.03;
70 self.maxEvents = -1;
71 self.setJMTJarPath(jmtGetPath);
72 % Initialize XML parser for model serialization
73 self.xmlParser = JMTIO(model, self.options);
74 end
75
76 % XML generation delegated to JMTIO (see @JMTIO/)
77 % Use self.xmlParser.writeJSIM() for JSIM model generation
78
79 fileName = getFileName(self)
80
81 %Setter
82 self = setJMTJarPath(self, path)
83
84 % Getters
85 out = getJMTJarPath(self)
86
87 out = getFilePath(self)
88 jsimwView(self, options)
89 jsimgView(self, options)
90 view(self, options)
91
92 [outputFileName] = writeJSIM(self, sn, outputFileName)
93 [result, parsed] = getResults(self)
94 [result, parsed] = getResultsJSIM(self)
95 [result, parsed] = getResultsJMVA(self)
96
97 function sn = getStruct(self)
98 % QN = GETSTRUCT()
99
100 % Get data structure summarizing the model
101 sn = self.model.getStruct(true);
102 end
103 end
104
105 %Private methods.
106 methods (Access = 'private')
107 out = getJSIMTempPath(self)
108 out = getJMVATempPath(self)
109 end
110
111 %Private methods.
112 methods (Access = 'protected')
113 bool = hasAvgResults(self)
114 end
115
116
117 methods (Access = 'public')
118 getProbNormConstAggr(self); % jmva
119 %% StateAggr methods
120 Pr = getProbAggr(self, node, state_a);
121 [Pi_t, SSnode_a] = getTranProbAggr(self, node);
122 probSysStateAggr = getProbSysAggr(self);
123 tranNodeStateAggr = sampleAggr(self, node, numSamples, markActivePassive);
124 tranSysStateAggr = sampleSysAggr(self, numSamples, markActivePassive);
125
126 %% Cdf methods
127 [RD,log] = getCdfRespT(self, R);
128 RD = getTranCdfRespT(self, R);
129 RD = getTranCdfPassT(self, R);
130
131 function [allMethods] = listValidMethods(self)
132 % allMethods = LISTVALIDMETHODS()
133 % List valid methods for this solver
134 sn = self.model.getStruct();
135 allMethods = {'default','jsim','replication','jmva','jmva.amva','jmva.mva','jmva.recal',...
136 'jmva.comom','jmva.chow','jmva.bs','jmva.aql',...
137 'jmva.lin','jmva.dmlin'};
138 end
139 end
140
141 methods (Static)
142
143 function bool = isAvailable()
144 % BOOL = ISAVAILABLE()
145
146 bool = true;
147 try
148 jmt_path = jmtGetPath();
149 jmt_jar = fullfile(jmt_path, 'JMT.jar');
150 if ~exist(jmt_jar, 'file')
151 bool = false;
152 end
153 catch
154 bool = false;
155 end
156 end
157
158 function featSupported = getFeatureSet()
159 % FEATSUPPORTED = GETFEATURESET()
160
161 featSupported = SolverFeatureSet;
162 featSupported.setTrue({'Sink',...
163 'Source',...
164 'Router',...
165 'ClassSwitch',...
166 'Delay',...
167 'DelayStation',...
168 'Queue',...
169 'Fork',...
170 'Join',...
171 'Forker',...
172 'Joiner',...
173 'Logger',...
174 'Coxian',...
175 'Cox2',...
176 'APH',...
177 'Erlang',...
178 'Exp',...
179 'HyperExp',...
180 'Det',...
181 'Gamma',...
182 'Lognormal',...
183 'MAP',...
184 'MMPP2',...
185 'Normal',...
186 'PH',...
187 'Pareto',...
188 'Weibull',...
189 'Replayer',...
190 'Uniform',...
191 'StatelessClassSwitcher',...
192 'InfiniteServer',...
193 'SharedServer',...
194 'Buffer',...
195 'Dispatcher',...
196 'Server',...
197 'JobSink',...
198 'RandomSource',...
199 'ServiceTunnel',...
200 'LogTunnel',...
201 'Buffer', ...
202 'Linkage',...
203 'Enabling', ...
204 'Timing', ...
205 'Firing', ...
206 'Storage', ...
207 'Place', ...
208 'Transition', ...
209 'SchedStrategy_INF',...
210 'SchedStrategy_PS',...
211 'SchedStrategy_DPS',...
212 'SchedStrategy_FCFS',...
213 'SchedStrategy_GPS',...
214 'SchedStrategy_SIRO',...
215 'SchedStrategy_HOL',...
216 'SchedStrategy_LCFS',...
217 'SchedStrategy_LCFSPR',...
218 'SchedStrategy_SEPT',...
219 'SchedStrategy_SRPT',...
220 'SchedStrategy_LEPT',...
221 'SchedStrategy_SJF',...
222 'SchedStrategy_LJF',...
223 'SchedStrategy_LPS',...
224 'SchedStrategy_POLLING',...
225 'RoutingStrategy_PROB',...
226 'RoutingStrategy_RAND',...
227 'RoutingStrategy_RROBIN',...
228 'RoutingStrategy_WRROBIN',...
229 'RoutingStrategy_KCHOICES',...
230 'SchedStrategy_EXT',...
231 'ClosedClass','SelfLoopingClass',...
232 'OpenClass',...
233 'Cache', 'CacheClassSwitcher', ...
234 'ReplacementStrategy_RR', 'ReplacementStrategy_FIFO', ...
235 'ReplacementStrategy_SFIFO', 'ReplacementStrategy_LRU'});
236 end
237
238 function [bool, featSupported] = supports(model)
239 % [BOOL, FEATSUPPORTED] = SUPPORTS(MODEL)
240
241 featUsed = model.getUsedLangFeatures();
242 featSupported = SolverJMT.getFeatureSet();
243 bool = SolverFeatureSet.supports(featSupported, featUsed);
244 end
245
246 function jsimgOpen(filename)
247 % JSIMGOPEN(FILENAME)
248
249 [path] = fileparts(filename);
250 if isempty(path)
251 filename=[pwd,filesep,filename];
252 end
253 runtime = java.lang.Runtime.getRuntime();
254 cmd = ['java -cp "',jmtGetPath,filesep,'JMT.jar" jmt.commandline.Jmt jsimg "',filename,'"'];
255 system(cmd);
256 %runtime.exec(cmd);
257 end
258
259 function jsimwOpen(filename)
260 % JSIMWOPEN(FILENAME)
261
262 runtime = java.lang.Runtime.getRuntime();
263 cmd =