1classdef LINE < SolverAuto
5 % @brief Main entry point
for the LINE solver.
6 % @details Provides a unified
interface to access various solvers (CTMC, MVA, SSA, JMT, Fluid, NC, MAM).
7 % Can also be used to load models from files.
10 % Alias
for SolverAuto
12 % Copyright (c) 2012-2026, Imperial College London
13 % All rights reserved.
17 function self = LINE(model, varargin)
20 % @brief Constructor
for the LINE solver wrapper.
21 % @param model The network model (Network or LayeredNetwork).
22 % @param varargin Optional arguments passed to SolverAuto.
23 % @
return self Instance of the LINE solver.
26 % SELF = LINE(MODEL, VARARGIN)
27 self@SolverAuto(model, varargin{:});
32 function result = load(varargin)
35 % @brief Factory method to load models or instantiate solvers.
37 % Usage 1: Load a model from file.
38 % model = LINE.load(filename)
39 % model = LINE.load(filename, verbose)
40 % Supported formats: .jsim, .jsimg, .jsimw (JMT), .jmva (JMVA), .xml/lqn/lqnx (LQN), .mat (MATLAB).
42 % Usage 2: Instantiate a solver with a specific method.
43 % solver = LINE.load(method, model, options...)
45 % @param varargin Arguments
for loading a model or creating a solver.
46 % @
return result Loaded model
object or Solver instance.
50 % Flexible loading method that handles both solver and model loading
52 % Usage 1: Load a model from file
53 % model = LINE.load(filename)
54 % model = LINE.load(filename, verbose)
56 % Usage 2: Load a solver with chosen method (legacy)
57 % solver = LINE.load(method, model, options...)
59 % Check
if this is model loading (1-2 args with first arg as
string filename)
60 if nargin >= 1 && nargin <= 2 && ischar(varargin{1}) && contains(varargin{1},
'.')
61 % Check
if this is actually a filename with a supported extension
62 [~, ~, ext] = fileparts(varargin{1});
63 supported_extensions = {
'.jsim',
'.jsimg',
'.jsimw',
'.jmva',
'.xml',
'.lqn',
'.lqnx',
'.mat'};
65 if ismember(lower(ext), supported_extensions)
66 filename = varargin{1};
69 verbose = varargin{2};
72 % Determine file format and load accordingly
74 case {
'.jsim',
'.jsimg',
'.jsimw'}
76 result = JSIM2LINE(filename);
79 result = JMVA2LINE(filename);
80 case {
'.xml',
'.lqn',
'.lqnx'}
81 % Try to load as LQN model
83 result = LQN2MATLAB(filename);
85 % If LQN fails,
try as
generic XML
86 error(
'LINE:load',
'Unsupported XML format. Only LQN XML files are supported.');
89 % Load MATLAB saved model
90 data = load(filename);
91 if isfield(data,
'model')
93 elseif isfield(data, 'network')
94 result = data.network;
96 % Find first Network
object in the file
97 fields = fieldnames(data);
99 for i = 1:length(fields)
100 if isa(data.(fields{i}),
'Network')
101 result = data.(fields{i});
107 error(
'LINE:load',
'No Network model found in MAT file.');
112 fprintf(
'Loaded model "%s" from %s\n', result.name, filename);
115 error(
'LINE:load',
'Unsupported file format: %s', ext);
120 % If we get here, the
string contains a dot but
is not a supported file format
121 % Continue to solver loading logic below
124 % Otherwise,
this is solver loading (legacy behavior)
126 error(
'LINE:load',
'Solver loading requires at least method and model arguments.');
129 chosenmethod = varargin{1};
131 options_args = varargin(3:end);
133 options = Solver.parseOptions(options_args, Solver.defaultOptions);
134 options.method = chosenmethod;
135 switch options.method
136 case {
'default',
'auto'}
137 if strcmp(options.method,
'auto'), options.method=
'default'; end
138 result = LINE(model, options);
139 case {
'ctmc',
'ctmc.gpu',
'gpu',...
140 'ctmc.qrf.mmi',
'ctmc.qrf.mem',
'ctmc.qrf.mmi.ld',
'ctmc.qrf.mmi.linear',...
141 'ctmc.qrf.bas.mmi',
'ctmc.qrf.bas.mem',
'ctmc.qrf.bas',
'ctmc.qrf.rsrd'}
142 if strcmp(options.method,
'ctmc'), options.method=
'default'; end
143 options.method = erase(options.method,
'ctmc.');
144 result = SolverCTMC(model, options);
145 case {
'mva',
'mva.exact',
'amva',
'mva.amva',
'qna',
'mva.qna',
'sqrt',
'mva.sqrt' ...
146 'amva.qd',
'mva.amva.qd', ...
147 'amva.bs',
'mva.amva.bs', ...
148 'amva.qli',
'mva.amva.qli', ...
149 'amva.fli',
'mva.amva.fli', ...
150 'amva.lin',
'mva.amva.lin', ...
151 'mm1',
'mmk',
'mg1',
'gm1',
'gig1',
'gim1',
'gig1.kingman', ...
152 'gigk',
'gigk.kingman_approx', ...
153 'gig1.gelenbe',
'gig1.heyman',
'gig1.kimura',
'gig1.allen',
'gig1.kobayashi',
'gig1.klb',
'gig1.marchal', ...
154 'aba.upper',
'aba.lower',
'bjb.upper',
'bjb.lower',
'gb.upper',
'gb.lower',
'pb.upper',
'pb.lower',
'sb.upper',
'sb.lower'}
155 %
'amva.aql',
'mva.amva.aql', ...
156 %
'amva.qdaql',
'mva.amva.qdaql', ...
157 if strcmp(options.method,
'mva'), options.method=
'default'; end
158 options.method = erase(options.method,
'mva.');
159 result = SolverMVA(model, options);
160 case {
'nrm',
'ssa',
'ssa.serial',
'ssa.parallel',
'serial',
'parallel'}
161 if strcmp(options.method,
'ssa'), options.method=
'default'; end
162 options.method = erase(options.method,
'ssa.');
163 result = SolverSSA(model, options);
164 case {
'jmt',
'jsim',
'jmva',
'jmva.mva',
'jmva.recal',
'jmva.comom',
'jmva.chow',
'jmva.bs',
'jmva.aql',
'jmva.lin',
'jmva.dmlin',... %,
'jmva.ls',
'jmt.jmva.ls'
165 'jmt.jsim',
'jmt.jmva',
'jmt.jmva.mva',
'jmt.jmva.amva',
'jmva.amva',
'jmt.jmva.recal',
'jmt.jmva.comom',
'jmt.jmva.chow',
'jmt.jmva.bs',
'jmt.jmva.aql',
'jmt.jmva.lin',
'jmt.jmva.dmlin'}
166 if strcmp(options.method,
'jmt'), options.method=
'default'; end
167 options.method = erase(options.method,
'jmt.');
168 result = SolverJMT(model, options);
169 case {
'fluid',
'fluid.softmin',
'fluid.statedep',
'fluid.closing'}
170 if strcmp(options.method,
'fluid'), options.method=
'default'; end
171 options.method = erase(options.method,
'fluid.');
172 result = SolverFluid(model, options);
173 case {
'nc',
'nc.exact',
'nc.imci',
'nc.ls',
'comom',
'comomld',
'cub',
'ls',
'nc.le',
'le',
'mmint2',
'nc.panacea',
'nc.pana',
'nc.mmint2',
'nc.kt',
'nc.deterministic',
'nc.sampling',
'nc.propfair',
'nc.comom',
'nc.comomld',
'nc.mom',
'nc.cub',
'nc.brute',
'nc.rd',
'nc.nr.probit',
'nc.nr.logit',
'nc.gm'}
174 if strcmp(options.method,
'nc'), options.method=
'default'; end
175 options.method = erase(options.method,
'nc.');
176 result = SolverNC(model, options);
177 case {
'mam',
'mam.dec.source',
'mam.dec.mmap',
'mam.dec.poisson'}
178 if strcmp(options.method,
'mam'), options.method=
'default'; end
179 options.method = erase(options.method,
'mam.');
180 result = SolverMAM(model, options);
182 if strcmp(options.method,
'auto'), options.method=
'default'; end
183 result = LINE(model, options);