1classdef SolverLN < EnsembleSolver
2 % SolverLN Layered network solver
for hierarchical performance models
4 % SolverLN implements analysis of layered queueing networks (LQNs) which model
5 % hierarchical software systems with clients, application servers, and resource
6 % layers. It uses iterative decomposition to solve multi-layer models by
7 % analyzing each layer separately and propagating service demands between layers.
9 % @brief Layered network solver
for hierarchical software performance models
11 % Key characteristics:
12 % - Multi-layer hierarchical model analysis
13 % - Iterative decomposition between layers
14 % - Software performance modeling support
15 % - Client-server architecture analysis
16 % - Task and entry modeling capabilities
17 % - Convergence-based iterative solution
20 % - Layered model decomposition
21 % - Service time propagation between layers
22 % - Utilization and throughput analysis per layer
23 % - Entry-level performance metrics
24 % - Think time and residence time computation
25 % - Interlocking analysis
for dependencies
27 % SolverLN
is ideal
for:
28 % - Software performance modeling
29 % - Multi-tier application analysis
30 % - Client-server system evaluation
31 % - Hierarchical resource modeling
32 % - Service-oriented architectures
36 % solver = SolverLN(layered_model,
'maxIter', 100);
37 % solver.runAnalyzer(); % Iterative layer analysis
38 % metrics = solver.getEnsembleAvg(); % Layer performance metrics
41 % Copyright (c) 2012-2026, Imperial College London
42 % All rights reserved.
44 properties %(Hidden) % registries of quantities to update at every iteration
45 nlayers; % number of model layers
46 lqn; % lqn data structure
47 hasconverged; %
true if last iteration converged,
false otherwise
48 averagingstart; % iteration at which result averaging started
49 idxhash; % ensemble model associated to host or task
50 servtmatrix; % auxiliary matrix to determine entry servt
51 ptaskcallers; % probability that a task
is called by a given task, directly or indirectly (remotely)
52 ptaskcallers_step; % probability that a task
is called by a given task, directly or indirectly (remotely) up to a given step distance
53 ilscaling; % interlock scalings
54 njobs; % number of jobs
for each caller in a given submodel
55 njobsorig; % number of jobs
for each caller at layer build time
56 routereset; % models that require hard reset of service chains
57 svcreset; % models that require hard reset of service process
58 maxitererr; % maximum error at current iteration over all layers
59 % Under-relaxation state for convergence improvement
60 relax_omega; % Current relaxation factor
61 relax_err_history; % Error history
for adaptive mode
62 servt_prev; % Previous service times
for relaxation
63 residt_prev; % Previous residence times
for relaxation
64 tput_prev; % Previous throughputs
for relaxation
65 thinkt_prev; % Previous think times
for relaxation
66 callservt_prev; % Previous call service times
for relaxation
67 % MOL (Method of Layers) properties
for hierarchical iteration
68 hostLayerIndices; % Indices of host (processor) layers in ensemble
69 taskLayerIndices; % Indices of task layers in ensemble
70 util_prev_host; % Previous processor utilizations (
for delta computation)
71 util_prev_task; % Previous task utilizations (
for delta computation)
72 mol_it_host_outer; % MOL host outer iteration counter
73 mol_it_task_inner; % MOL task inner iteration counter
76 properties %(Hidden) % performance metrics and related processes
78 util_ilock; % interlock matrix (ntask x ntask), element (i,j) says how much the utilization of task i
is imputed to task j
81 servt; %
this is the mean service time of an activity, which
is the response time at the lower layer (
if applicable)
82 residt; %
this is the residence time at the lower layer (
if applicable)
83 servtproc; %
this is the service time process with mean fitted to the servt value
84 servtcdf; %
this is the cdf of the service time process
94 ignore; % elements to be ignored (e.g., components disconnected from a REF node)
97 properties %(Access =
protected, Hidden) % registries of quantities to update at every iteration
98 arvproc_classes_updmap; % [modelidx, actidx, node, class]
99 thinkt_classes_updmap; % [modelidx, actidx, node, class]
100 actthinkt_classes_updmap; % [modelidx, actidx, node, class]
for activity think-times
101 servt_classes_updmap; % [modelidx, actidx, node, class]
102 call_classes_updmap; % [modelidx, callidx, node, class]
103 route_prob_updmap; % [modelidx, actidxfrom, actidxto, nodefrom, nodeto, classfrom, classto]
104 unique_route_prob_updmap; % auxiliary cache of unique route_prob_updmap rows
105 solverFactory; % function handle to create layer solvers
109 function self = SolverLN(lqnmodel, solverFactory, varargin)
110 % SELF = SOLVERLN(MODEL,SOLVERFACTORY,VARARGIN)
111 self@EnsembleSolver(lqnmodel, mfilename);
113 if any(cellfun(@(s) strcmpi(s,
'java'), varargin))
114 self.obj = JLINE.SolverLN(JLINE.from_line_layered_network(lqnmodel));
115 self.obj.options.verbose = jline.VerboseLevel.SILENT;
117 % Default solver factory: Use JMT
for open networks, MVA
for closed networks
118 defaultSolverFactory = @(m) adaptiveSolverFactory(m, self.options);
120 if nargin == 1 %
case SolverLN(model)
121 solverFactory = defaultSolverFactory;
122 self.setOptions(SolverLN.defaultOptions);
123 elseif nargin>1 && isstruct(solverFactory)
124 options = solverFactory;
125 self.setOptions(options);
126 solverFactory = defaultSolverFactory;
127 elseif nargin>2 %
case SolverLN(model,
'opt1',...)
128 if ischar(solverFactory)
129 inputvar = {solverFactory,varargin{:}}; %#ok<CCAT>
130 solverFactory = defaultSolverFactory;
131 else %
case SolverLN(model, solverFactory,
'opt1',...)
134 self.setOptions(Solver.parseOptions(inputvar, SolverLN.defaultOptions));
135 else %case SolverLN(model,solverFactory)
136 self.setOptions(SolverLN.defaultOptions);
138 self.lqn = lqnmodel.getStruct();
140 for e=1:self.getNumberOfModels
141 if numel(find(self.lqn.isfunction == 1))
142 if ~isempty(self.ensemble{e}.stations{2}.setupTime)
143 solverFactory = @(m) SolverMAM(m,
'verbose',
false,
'method',
'dec.poisson');
145 solverFactory = @(m) SolverAuto(m,
'verbose',
false);
147 self.setSolver(solverFactory(self.ensemble{e}),e);
149 self.setSolver(solverFactory(self.ensemble{e}),e);
152 self.solverFactory = solverFactory; % Store
for later use
156 function runtime = runAnalyzer(self, options) %#ok<INUSD> %
generic method to run the solver
157 line_error(mfilename,
'Use getEnsembleAvg instead.');
160 function sn = getStruct(self)
163 % Get data structure summarizing the model
164 sn = self.model.getStruct();
167 function construct(self)
168 % mark down to ignore unreachable disconnected components
169 self.ignore =
false(self.lqn.nidx,1);
170 [~,wccs] = weaklyconncomp(self.lqn.graph
'+self.lqn.graph);
171 uwccs = unique(wccs);
173 % the model has disconnected submodels
174 wccref = false(1,length(uwccs));
175 for t=1:self.lqn.ntasks
176 tidx = self.lqn.tshift+t;
177 if self.lqn.sched(tidx) == SchedStrategy.REF
178 wccref(wccs(tidx)) = true;
181 if any(wccref==false)
182 for dw=find(wccref==false) % disconnected component
183 self.ignore(find(wccs==dw)) = true;
188 % initialize internal data structures
189 self.entrycdfrespt = cell(length(self.lqn.nentries),1);
190 self.hasconverged = false;
192 % initialize svc and think times
193 self.servtproc = self.lqn.hostdem;
194 self.thinkproc = self.lqn.think;
195 self.callservtproc = cell(self.lqn.ncalls,1);
196 for cidx = 1:self.lqn.ncalls
197 self.callservtproc{cidx} = self.lqn.hostdem{self.lqn.callpair(cidx,2)};
201 self.njobs = zeros(self.lqn.tshift + self.lqn.ntasks, self.lqn.tshift + self.lqn.ntasks);
202 buildLayers(self); % build layers
203 self.njobsorig = self.njobs;
204 self.nlayers = length(self.ensemble);
206 % initialize data structures for interlock correction
207 self.ptaskcallers = zeros(self.lqn.nhosts+self.lqn.ntasks, self.lqn.nhosts+self.lqn.ntasks);
208 self.ptaskcallers_step = cell(1,self.nlayers+1);
209 for step=1:self.nlayers % upper bound on maximum dag height
210 self.ptaskcallers_step{step} = zeros(self.lqn.nhosts+self.lqn.ntasks, self.lqn.nhosts+self.lqn.ntasks);
213 % layering generates update maps that we use here to cache the elements that need reset
214 self.routereset = unique(self.idxhash(self.route_prob_updmap(:,1)))';
215 self.svcreset = unique(self.idxhash(self.thinkt_classes_updmap(:,1)))
';
216 self.svcreset = union(self.svcreset,unique(self.idxhash(self.call_classes_updmap(:,1)))');
219 function self = reset(self)
223 bool = converged(self, it); % convergence test at iteration it
225 function init(self) % operations before starting to iterate
226 % INIT() % OPERATIONS BEFORE STARTING TO ITERATE
227 self.unique_route_prob_updmap = unique(self.route_prob_updmap(:,1))
';
228 self.tput = zeros(self.lqn.nidx,1);
229 self.tputproc = cell(self.lqn.nidx,1);
230 self.util = zeros(self.lqn.nidx,1);
231 self.servt = zeros(self.lqn.nidx,1);
232 self.servtmatrix = getEntryServiceMatrix(self);
234 for e= 1:self.nlayers
235 self.solvers{e}.enableChecks=false;
238 % Initialize under-relaxation state
239 relax_mode = self.options.config.relax;
242 self.relax_omega = 1.0; % Start without relaxation
243 case {'fixed
', 'adaptive
'}
244 self.relax_omega = self.options.config.relax_factor;
245 otherwise % 'none
' or unrecognized
246 self.relax_omega = 1.0; % No relaxation
248 self.relax_err_history = [];
249 self.servt_prev = NaN(self.lqn.nidx, 1);
250 self.residt_prev = NaN(self.lqn.nidx, 1);
251 self.tput_prev = NaN(self.lqn.nidx, 1);
252 self.thinkt_prev = NaN(self.lqn.nidx, 1);
253 self.callservt_prev = NaN(self.lqn.ncalls, 1);
255 % Initialize MOL-specific state
256 self.mol_it_host_outer = 0;
257 self.mol_it_task_inner = 0;
258 self.util_prev_host = zeros(self.lqn.nhosts, 1);
259 self.util_prev_task = zeros(self.lqn.ntasks, 1);
263 function pre(self, it) %#ok<INUSD> % operations before an iteration
264 % PRE(IT) % OPERATIONS BEFORE AN ITERATION
268 function [result, runtime] = analyze(self, it, e) %#ok<INUSD>
269 % [RESULT, RUNTIME] = ANALYZE(IT, E)
273 if e==1 && self.solvers{e}.options.verbose
277 % Protection for unstable queues during LN iterations
278 % If a solver fails (e.g., due to queue instability with open arrivals),
279 % use results from previous iteration if available and continue
281 [result.QN, result.UN, result.RN, result.TN, result.AN, result.WN] = self.solvers{e}.getAvg();
283 if it > 1 && ~isempty(self.results) && size(self.results, 1) >= (it-1) && size(self.results, 2) >= e
284 if self.solvers{e}.options.verbose
285 warning('LINE:SolverLN:Instability
', ...
286 'Layer %d at iteration %d encountered instability (possibly due to high service demand with open arrivals). Using previous iteration values and continuing.
', ...
289 % Use results from previous iteration
290 prevResult = self.results{it-1, e};
291 result.QN = prevResult.QN;
292 result.UN = prevResult.UN;
293 result.RN = prevResult.RN;
294 result.TN = prevResult.TN;
295 result.AN = prevResult.AN;
296 result.WN = prevResult.WN;
298 % First iteration or no previous results, re-throw the exception
299 error('LINE:SolverLN:FirstIterationFailure
', ...
300 'Layer %d failed at iteration %d with no previous iteration to fall back on: %s
', ...
307 function post(self, it) % operations after an iteration
308 % POST(IT) % OPERATIONS AFTER AN ITERATION
309 % convert the results of QNs into layer metrics
311 self.updateMetrics(it);
313 % recompute think times
314 self.updateThinkTimes(it);
316 if self.options.config.interlocking
317 % recompute layer populations
318 self.updatePopulations(it);
321 % update the model parameters
322 self.updateLayers(it);
324 % update entry selection and cache routing probabilities within callers
325 self.updateRoutingProbabilities(it);
327 % reset all layers with routing probability changes
328 for e= self.routereset
329 self.ensemble{e}.refreshChains();
330 self.solvers{e}.reset();
333 % refresh visits and network model parameters
335 switch self.solvers{e}.name
336 case {'SolverMVA
', 'SolverNC
'} %leaner than refreshProcesses, no need to refresh phases
337 % note: this does not refresh the sn.proc field, only sn.rates and sn.scv
338 switch self.options.method
340 self.ensemble{e}.refreshRates();
342 self.ensemble{e}.refreshProcesses();
345 self.ensemble{e}.refreshProcesses();
347 self.solvers{e}.reset(); % commenting this out des not seem to produce a problem, but it goes faster with it
350 % this is required to handle population changes due to interlocking
351 if self.options.config.interlocking
353 self.ensemble{e}.refreshJobs();
358 % now disable all solver support checks for future iterations
359 for e=1:length(self.ensemble)
360 self.solvers{e}.setChecks(false);
366 function finish(self) % operations after iterations are completed
367 % FINISH() % OPERATIONS AFTER INTERATIONS ARE COMPLETED
368 E = size(self.results,2);
374 self.model.ensemble = self.ensemble;
377 function [QNlqn_t, UNlqn_t, TNlqn_t] = getTranAvg(self)
384 [crows, ccols] = size(QNlqn_t);
385 [QNclass_t{e}, UNclass_t{e}, TNclass_t{e}] = self.solvers{e}.getTranAvg();
386 QNlqn_t(crows+1:crows+size(QNclass_t{e},1),ccols+1:ccols+size(QNclass_t{e},2)) = QNclass_t{e};
387 UNlqn_t(crows+1:crows+size(UNclass_t{e},1),ccols+1:ccols+size(UNclass_t{e},2)) = UNclass_t{e};
388 TNlqn_t(crows+1:crows+size(TNclass_t{e},1),ccols+1:ccols+size(TNclass_t{e},2)) = TNclass_t{e};
392 function varargout = getAvg(varargin)
393 % [QN,UN,RN,TN,AN,WN] = GETAVG(SELF,~,~,~,~,USELQNSNAMING)
394 [varargout{1:nargout}] = getEnsembleAvg( varargin{:} );
397 function [cdfRespT] = getCdfRespT(self)
398 if isempty(self.entrycdfrespt{1})
399 % save user-specified method to temporary variable
400 curMethod = self.getOptions.method;
402 self.options.method = 'moment3
';
404 % restore user-specified method
405 self.options.method = curMethod;
407 cdfRespT = self.entrycdfrespt;
410 function [AvgTable,QT,UT,RT,WT,AT,TT] = getAvgTable(self)
411 % [AVGTABLE,QT,UT,RT,WT,TT] = GETAVGTABLE(USELQNSNAMING)
412 if (GlobalConstants.DummyMode)
413 [AvgTable, QT, UT, RT, TT, WT] = deal([]);
417 if ~isempty(self.obj)
418 avgTable = self.obj.getEnsembleAvg();
419 [QN,UN,RN,WN,AN,TN] = JLINE.arrayListToResults(avgTable);
421 [QN,UN,RN,TN,AN,WN] = getAvg(self);
424 % attempt to sanitize small numerical perturbations
425 variables = {QN, UN, RN, TN, AN, WN}; % Put all variables in a cell array
426 for i = 1:length(variables)
427 rVar = round(variables{i} * 10);
428 toRound = abs(variables{i} * 10 - rVar) < GlobalConstants.CoarseTol * variables{i} * 10;
429 variables{i}(toRound) = rVar(toRound) / 10;
430 variables{i}(variables{i}<=GlobalConstants.FineTol) = 0;
432 [QN, UN, RN, TN, AN, WN] = deal(variables{:}); % Assign the modified values back to the original variables
435 Node = label(self.lqn.names);
437 NodeType = label(O,1);
439 switch self.lqn.type(o)
440 case LayeredNetworkElement.PROCESSOR
441 NodeType(o,1) = label({'Processor
'});
442 case LayeredNetworkElement.TASK
444 NodeType(o,1) = label({'RefTask
'});
446 NodeType(o,1) = label({'Task
'});
448 case LayeredNetworkElement.ENTRY
449 NodeType(o,1) = label({'Entry
'});
450 case LayeredNetworkElement.ACTIVITY
451 NodeType(o,1) = label({'Activity
'});
452 case LayeredNetworkElement.CALL
453 NodeType(o,1) = label({'Call
'});
457 QT = Table(Node,QLen);
459 UT = Table(Node,Util);
461 RT = Table(Node,RespT);
463 TT = Table(Node,Tput);
465 %ST = Table(Node,SvcT);
467 %PT = Table(Node,ProcUtil);
469 WT = Table(Node,ResidT);
471 AT = Table(Node,ArvR);
472 AvgTable = Table(Node, NodeType, QLen, Util, RespT, ResidT, ArvR, Tput);%, ProcUtil, SvcT);
477 [QN,UN,RN,TN,AN,WN] = getEnsembleAvg(self);
479 function [bool, featSupported] = supports(model)
480 % [BOOL, FEATSUPPORTED] = SUPPORTS(MODEL)
481 % This method cannot be static as otherwise it cannot access self.solvers{e}
482 ensemble = model.getEnsemble;
483 featSupported = cell(length(ensemble),1);
485 for e = 1:length(ensemble)
486 [solverSupports,featSupported{e}] = self.solvers{e}.supports(ensemble{e});
487 bool = bool && solverSupports;
493 buildLayers(self, lqn, resptproc, callservtproc);
494 buildLayersRecursive(self, idx, callers, ishostlayer);
495 updateLayers(self, it);
496 updatePopulations(self, it);
497 updateThinkTimes(self, it);
498 updateMetrics(self, it);
499 updateRoutingProbabilities(self, it);
500 svcmatrix = getEntryServiceMatrix(self)
502 function delta = computeTaskDelta(self)
503 % COMPUTETASKDELTA Compute max queue-length change for task layers (MOL inner loop)
505 % Returns the maximum queue-length change across task layers,
506 % normalized by total jobs, similar to converged.m logic.
507 results = self.results;
508 it = size(results, 1);
515 for e = self.taskLayerIndices
516 metric = results{it, e}.QN;
517 metric_1 = results{it-1, e}.QN;
518 N = sum(self.ensemble{e}.getNumberOfJobs);
521 iterErr = max(abs(metric(:) - metric_1(:))) / N;
525 delta = max(delta, iterErr);
530 function delta = computeHostDelta(self)
531 % COMPUTEHOSTDELTA Compute max queue-length change for host layers (MOL outer loop)
533 % Returns the maximum queue-length change across host layers,
534 % normalized by total jobs, similar to converged.m logic.
535 results = self.results;
536 it = size(results, 1);
543 for e = self.hostLayerIndices
544 metric = results{it, e}.QN;
545 metric_1 = results{it-1, e}.QN;
546 N = sum(self.ensemble{e}.getNumberOfJobs);
549 iterErr = max(abs(metric(:) - metric_1(:))) / N;
553 delta = max(delta, iterErr);
558 function postTaskLayers(self, it)
559 % POSTTASKLAYERS Post-iteration updates for task layers only (MOL inner loop)
561 % Updates think times, layer parameters, and routing probabilities
562 % after task layer analysis, then resets task layer solvers.
564 self.updateThinkTimes(it);
565 if self.options.config.interlocking
566 self.updatePopulations(it);
568 self.updateLayers(it);
569 self.updateRoutingProbabilities(it);
571 % Reset task layer solvers
572 for e = self.taskLayerIndices
573 switch self.solvers{e}.name
574 case {'SolverMVA
', 'SolverNC
'}
575 switch self.options.method
577 self.ensemble{e}.refreshRates();
579 self.ensemble{e}.refreshRates();
582 self.ensemble{e}.refreshProcesses();
584 self.solvers{e}.reset();
587 if self.options.config.interlocking
588 for e = self.taskLayerIndices
589 self.ensemble{e}.refreshJobs();
594 function postHostLayers(self, it)
595 % POSTHOSTLAYERS Post-iteration updates for host layers (MOL outer loop)
597 % Updates think times, layer parameters, and routing probabilities
598 % after host layer analysis, then resets host layer solvers.
600 self.updateThinkTimes(it);
601 if self.options.config.interlocking
602 self.updatePopulations(it);
604 self.updateLayers(it);
605 self.updateRoutingProbabilities(it);
607 % Reset host layer solvers
608 for e = self.hostLayerIndices
609 switch self.solvers{e}.name
610 case {'SolverMVA
', 'SolverNC
'}
611 self.ensemble{e}.refreshRates();
613 self.ensemble{e}.refreshProcesses();
615 self.solvers{e}.reset();
618 if self.options.config.interlocking
619 for e = self.hostLayerIndices
620 self.ensemble{e}.refreshJobs();
627 function state = get_state(self)
628 % GET_STATE Export current solver state for continuation
630 % STATE = GET_STATE() returns a struct containing the current
631 % solution state, which can be used to continue iteration with
632 % a different solver via set_state().
634 % The exported state includes:
635 % - Service time processes (servtproc)
636 % - Think time processes (thinktproc)
637 % - Call service time processes (callservtproc)
638 % - Throughput processes (tputproc)
639 % - Performance metrics (util, tput, servt, residt, etc.)
641 % - Last iteration results
644 % solver1 = SolverLN(model, @(m) SolverMVA(m));
645 % solver1.getEnsembleAvg();
646 % state = solver1.get_state();
648 % solver2 = SolverLN(model, @(m) SolverJMT(m));
649 % solver2.set_state(state);
650 % solver2.getEnsembleAvg(); % Continues from MVA solution
654 % Service/think time processes
655 state.servtproc = self.servtproc;
656 state.thinktproc = self.thinktproc;
657 state.callservtproc = self.callservtproc;
658 state.tputproc = self.tputproc;
659 state.entryproc = self.entryproc;
661 % Performance metrics
662 state.util = self.util;
663 state.tput = self.tput;
664 state.servt = self.servt;
665 state.residt = self.residt;
666 state.thinkt = self.thinkt;
667 state.callresidt = self.callresidt;
668 state.callservt = self.callservt;
671 state.relax_omega = self.relax_omega;
672 state.servt_prev = self.servt_prev;
673 state.residt_prev = self.residt_prev;
674 state.tput_prev = self.tput_prev;
675 state.thinkt_prev = self.thinkt_prev;
676 state.callservt_prev = self.callservt_prev;
678 % Results from last iteration
679 state.results = self.results;
682 state.njobs = self.njobs;
683 state.ptaskcallers = self.ptaskcallers;
684 state.ilscaling = self.ilscaling;
687 function set_state(self, state)
688 % SET_STATE Import solution state for continuation
690 % SET_STATE(STATE) initializes the solver with a previously
691 % exported state, allowing iteration to continue from where
692 % a previous solver left off.
694 % This enables hybrid solving schemes where fast solvers (MVA)
695 % provide initial estimates and accurate solvers (JMT, DES)
696 % refine the solution.
699 % solver1 = SolverLN(model, @(m) SolverMVA(m));
700 % solver1.getEnsembleAvg();
701 % state = solver1.get_state();
703 % solver2 = SolverLN(model, @(m) SolverJMT(m));
704 % solver2.set_state(state);
705 % solver2.getEnsembleAvg(); % Continues from MVA solution
707 % Service/think time processes
708 self.servtproc = state.servtproc;
709 self.thinktproc = state.thinktproc;
710 self.callservtproc = state.callservtproc;
711 self.tputproc = state.tputproc;
712 if isfield(state, 'entryproc
')
713 self.entryproc = state.entryproc;
716 % Performance metrics
717 self.util = state.util;
718 self.tput = state.tput;
719 self.servt = state.servt;
720 if isfield(state, 'residt
')
721 self.residt = state.residt;
723 if isfield(state, 'thinkt
')
724 self.thinkt = state.thinkt;
726 if isfield(state, 'callresidt
')
727 self.callresidt = state.callresidt;
729 if isfield(state, 'callservt
')
730 self.callservt = state.callservt;
734 if isfield(state, 'relax_omega
')
735 self.relax_omega = state.relax_omega;
737 if isfield(state, 'servt_prev
')
738 self.servt_prev = state.servt_prev;
740 if isfield(state, 'residt_prev
')
741 self.residt_prev = state.residt_prev;
743 if isfield(state, 'tput_prev
')
744 self.tput_prev = state.tput_prev;
746 if isfield(state, 'thinkt_prev
')
747 self.thinkt_prev = state.thinkt_prev;
749 if isfield(state, 'callservt_prev
')
750 self.callservt_prev = state.callservt_prev;
754 if isfield(state, 'results
')
755 self.results = state.results;
759 if isfield(state, 'njobs
')
760 self.njobs = state.njobs;
762 if isfield(state, 'ptaskcallers
')
763 self.ptaskcallers = state.ptaskcallers;
765 if isfield(state, 'ilscaling
')
766 self.ilscaling = state.ilscaling;
769 % Update layer models with imported state
771 if ~isempty(self.results)
772 it = size(self.results, 1);
774 self.updateLayers(it);
776 % Refresh all layer solvers with new parameters
777 for e = 1:self.nlayers
778 self.ensemble{e}.refreshChains();
779 switch self.solvers{e}.name
780 case {'SolverMVA
', 'SolverNC
'}
781 self.ensemble{e}.refreshRates();
783 self.ensemble{e}.refreshProcesses();
785 self.solvers{e}.reset();
789 function update_solver(self, solverFactory)
790 % UPDATE_SOLVER Change the solver for all layers
792 % UPDATE_SOLVER(FACTORY) replaces all layer solvers with
793 % new solvers created by the given factory function.
795 % This allows switching between different solving methods
796 % (e.g., from MVA to JMT/DES) while preserving the current
800 % solver = SolverLN(model, @(m) SolverMVA(m));
801 % solver.getEnsembleAvg(); % Fast initial solution
803 % solver.update_solver(@(m) SolverJMT(m, 'samples
', 1e5));
804 % solver.getEnsembleAvg(); % Refine with simulation
806 self.solverFactory = solverFactory;
808 % Replace all layer solvers
809 for e = 1:self.nlayers
810 self.setSolver(solverFactory(self.ensemble{e}), e);
814 function [allMethods] = listValidMethods(self)
815 sn = self.model.getStruct();
816 % allMethods = LISTVALIDMETHODS()
817 % List valid methods for this solver
818 allMethods = {'default
','moment3
','mol
'};
823 function options = defaultOptions()
824 % OPTIONS = DEFAULTOPTIONS()
825 options = SolverOptions('LN
');
830function solver = adaptiveSolverFactory(model, parentOptions)
831 % ADAPTIVESOLVERFACTORY - Select appropriate solver based on model characteristics
832 % Use JMT for models with open classes, MVA for pure closed networks
836 verbose = parentOptions.verbose;
839 if model.hasOpenClasses()
840 solver = SolverJMT(model, 'verbose
', verbose);
842 solver = SolverMVA(model, 'verbose
', verbose);