1classdef SolverJMT < NetworkSolver
2 % SolverJMT Java Modelling Tools
interface for simulation analysis
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.
9 % @brief Interface to Java Modelling Tools
for simulation and analysis
13 % solver = SolverJMT(model,
'samples', 10000,
'seed', 1);
14 % solver.getAvg(); % Run simulation via JMT
17 % Copyright (c) 2012-2026, Imperial College London
18 % All rights reserved.
21 properties %(GetAccess = 'private', SetAccess='private')
31 xmlParser; % JMTIO instance
for XML generation
36 xsiNoNamespaceSchemaLocation =
'Archive.xsd';
45 function self = SolverJMT(model, varargin)
46 % SOLVERJMT Create a JMT solver instance
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
53 % An auxiliary solver passed as first optional argument requests a
54 % warm start: its steady-state solution decides
the station
55 % preload of
the simulation (see NetworkSolver.initFromSolver).
57 if ~isempty(varargin) && isa(varargin{1},
'NetworkSolver')
58 initSolver = varargin{1};
61 self@NetworkSolver(model, mfilename);
62 self.setOptions(Solver.parseOptions(varargin, self.defaultOptions));
64 if ~Solver.isJavaAvailable
65 line_error(mfilename,
'SolverJMT requires the java command to be available on the system path.\n');
67 if ~SolverJMT.isAvailable
68 line_warning(mfilename,
'SolverJMT cannot locate JMT.jar in the common folder.\n');
70 % Set confidence interval from options (
default: 0.99 for 99% confidence)
71 [confintEnabled, confintLevel] = Solver.parseConfInt(self.options.confint);
73 self.simConfInt = confintLevel;
75 self.simConfInt = 0.99; %
default when disabled
77 self.simMaxRelErr = 0.03;
79 self.setJMTJarPath(jmtGetPath);
80 % Initialize XML parser
for model serialization
81 self.xmlParser = JMTIO(model, self.options);
82 if ~isempty(initSolver)
83 self.initFromSolver(initSolver);
87 % XML generation delegated to JMTIO (see @JMTIO/)
88 % Use self.xmlParser.writeJSIM()
for JSIM model generation
90 fileName = getFileName(self)
93 self = setJMTJarPath(self, path)
96 out = getJMTJarPath(self)
98 out = getFilePath(self)
99 jsimwView(self, options)
100 jsimgView(self, options)
103 [outputFileName] = writeJSIM(self, sn, outputFileName)
104 [result, parsed] = getResults(self)
105 [result, parsed] = getResultsJSIM(self)
106 [result, parsed] = getResultsJMVA(self)
108 function sn = getStruct(self)
111 % Get data structure summarizing
the model
112 sn = self.model.getStruct(
true);
117 methods (Access =
'private')
118 out = getJSIMTempPath(self)
119 out = getJMVATempPath(self)
123 methods (Access = 'protected')
124 bool = hasAvgResults(self)
128 methods (Access = 'public')
129 getProbNormConstAggr(self); % jmva
131 Pr = getProbAggr(self, node, state_a);
132 [Pi_t, SSnode_a] = getTranProbAggr(self, node);
133 probSysStateAggr = getProbSysAggr(self);
134 tranNodeStateAggr = sampleAggr(self, node, numEvents, markActivePassive);
135 tranSysStateAggr = sampleSysAggr(self, numEvents, markActivePassive);
138 [
RD,log] = getCdfRespT(self, R);
139 RD = getTranCdfRespT(self, R);
140 RD = getTranCdfPassT(self, R);
142 function [allMethods] = listValidMethods(self)
143 % allMethods = LISTVALIDMETHODS()
144 % List valid methods for this solver
145 sn = self.model.getStruct();
146 allMethods = {
'default',
'jsim',
'replication',
'jmva',
'jmva.amva',
'jmva.mva',
'jmva.recal',...
147 'jmva.comom',
'jmva.chow',
'jmva.bs',
'jmva.aql',...
148 'jmva.lin',
'jmva.dmlin'};
151 function
bool = isStochasticMethod(self, method) %#ok<INUSL>
152 % BOOL = ISSTOCHASTICMETHOD(METHOD)
153 % Simulation-based methods (default, jsim, replication) return
154 % stochastic estimates. The analytical JMVA methods do not,
155 % except for its sampling-based variants (e.g. jmva.ls).
156 tokens = regexp(lower(method), '[./]', 'split');
157 if any(strcmp(tokens,
'jmva'))
158 bool = any(ismember(tokens, {
'ls',
'mci',
'imci',
'sampling'}));
163 function featSupported = getMethodFeatureSet(self, method) %#ok<INUSD>
164 % All JMT methods share
the solver-level feature envelope.
166 % Defining this
is what lets NetworkSolver.supportsModelMethod name
167 %
the offending features: with no method feature set it falls back
168 % to the coarse supports(model), which returns an empty reason, so
169 % the gate could only report "features not supported" without
172 % A non-Network model (e.g. a LayeredNetwork) has no
173 % getUsedLangFeatures, so it keeps the coarse path and any
174 % structural checks or redirects that operate on such models.
175 if ~isa(self.model, 'Network')
179 featSupported = SolverJMT.getFeatureSet();
187 function
bool = isAvailable()
188 % BOOL = ISAVAILABLE()
192 jmt_path = jmtGetPath();
193 jmt_jar = fullfile(jmt_path, 'JMT.jar');
194 if ~exist(jmt_jar, 'file')
202 function featSupported = getFeatureSet()
203 % FEATSUPPORTED = GETFEATURESET()
205 featSupported = SolverFeatureSet;
206 featSupported.setTrue({
'Sink',...
235 'StatelessClassSwitcher',...
254 'SchedStrategy_INF',...
255 'SchedStrategy_PS',...
256 'SchedStrategy_DPS',...
257 'SchedStrategy_FCFS',...
258 'SchedStrategy_GPS',...
259 'SchedStrategy_SIRO',...
260 'SchedStrategy_HOL',...
261 'SchedStrategy_PSPRIO',...
262 'SchedStrategy_DPSPRIO',...
263 'SchedStrategy_GPSPRIO',...
264 'SchedStrategy_LCFS',...
265 'SchedStrategy_LCFSPR',...
266 'SchedStrategy_LCFSPRIO',...
267 'SchedStrategy_LCFSPRPRIO',...
268 'SchedStrategy_SEPT',...
269 'SchedStrategy_SRPT',...
270 'SchedStrategy_SRPTPRIO',...
271 'SchedStrategy_LEPT',...
272 'SchedStrategy_SJF',...
273 'SchedStrategy_LJF',...
274 'SchedStrategy_LPS',...
275 'SchedStrategy_POLLING',...
276 'RoutingStrategy_PROB',...
277 'RoutingStrategy_RAND',...
278 'RoutingStrategy_RROBIN',...
279 'RoutingStrategy_WRROBIN',...
280 'RoutingStrategy_JSQ',...
281 'RoutingStrategy_KCHOICES',...
282 'SchedStrategy_EXT',...
283 'ClosedClass',
'SelfLoopingClass',...
285 'Cache',
'CacheClassSwitcher', ...
286 'ReplacementStrategy_RR',
'ReplacementStrategy_FIFO', ...
287 'ReplacementStrategy_SFIFO',
'ReplacementStrategy_LRU', ...
288 'SetupDelayOff', ... % exported as delayOffTime/setUpTime (saveDelayOffStrategy)
289 'Reneging', ... % exported as an Impatience/Reneging strategy (saveImpatience)
290 'Balking'}); % exported as an Impatience/Balking strategy (saveImpatience)
293 function [bool, featSupported] = supports(model)
294 % [BOOL, FEATSUPPORTED] = SUPPORTS(MODEL)
296 featUsed = model.getUsedLangFeatures();
297 featSupported = SolverJMT.getFeatureSet();
298 bool = SolverFeatureSet.supports(featSupported, featUsed);
301 function jsimgOpen(filename)
302 % JSIMGOPEN(FILENAME)
304 [path] = fileparts(filename);
306 filename=[pwd,filesep,filename];
308 runtime = java.lang.Runtime.getRuntime();
309 cmd = ['java -cp "',jmtGetPath,filesep,'JMT.jar" jmt.commandline.Jmt jsimg "',filename,'"'];
314 function jsimwOpen(filename)
315 % JSIMWOPEN(FILENAME)
317 runtime = java.lang.Runtime.getRuntime();