1function runtime = runAnalyzer(self, options)
2% RUNTIME = RUNANALYZER(OPTIONS)
6 options = self.options;
10Solver.resetRandomGeneratorSeed(options.seed);
12line_debug(
'AUTO solver starting: method=%s, lang=%s, model=%s', options.method, options.lang,
class(self.model));
14% Check
if using Java backend
18 jmodel = LINE2JLINE(self.model);
19 M = jmodel.getNumberOfStations;
20 R = jmodel.getNumberOfClasses;
21 jsolver = JLINE.SolverAuto(jmodel, options);
22 [QN, UN, RN, WN, AN, TN] = JLINE.arrayListToResults(jsolver.getAvgTable);
23 runtime = jsolver.result.runtime;
26 QN = reshape(QN
', R, M)';
27 UN = reshape(UN
', R, M)';
28 RN = reshape(RN
', R, M)';
29 TN = reshape(TN
', R, M)';
30 WN = reshape(WN
', R, M)';
31 AN = reshape(AN
', R, M)';
32 self.setAvgResults(QN, UN, RN, TN, AN, WN, CN, XN, runtime, options.method, NaN);
33 self.result.SelectedSolver = char(jsolver.result.selectedSolver);
36 % Fall through to MATLAB implementation below
39% Delegate to the appropriate solver
40switch class(self.model)
42 % Select the best solver
43 if length(self.candidates) > 1
44 chosenSolver = self.chooseSolver(
'getAvg');
45 if chosenSolver.supports(self.model)
46 proposedSolvers = {chosenSolver, self.candidates{:}};
48 proposedSolvers = self.candidates;
51 proposedSolvers = {self.solvers{:}};
54 % Try each proposed solver
55 line_debug(
'AUTO trying %d candidate solvers', length(proposedSolvers));
56 for s = 1:length(proposedSolvers)
58 solver = proposedSolvers{s};
59 line_debug(
'AUTO attempting solver: %s', solver.getName());
60 runtime = solver.runAnalyzer(options);
62 % Copy results from the successful solver
63 if ~isempty(solver.result)
64 self.result = solver.result;
65 % Update the solver name to reflect AUTO solver
66 self.result.('solver') = self.getName();
67 self.result.SelectedSolver = solver.getName();
70 if self.options.verbose
71 line_printf('AUTO solver: analysis completed successfully by %s.\n', solver.getName());
75 if self.options.verbose
76 line_printf('AUTO solver: %s failed with error: %s\n', proposedSolvers{s}.getName(), ME.message);
81 % If we get here, all solvers failed
82 line_error(mfilename,
'All candidate solvers failed to analyze the model.');
85 % Similar logic
for LayeredNetwork
86 line_debug(
'AUTO handling LayeredNetwork model');
87 chosenSolver = self.chooseSolver(
'getAvg');
88 if chosenSolver.supports(self.model)
89 proposedSolvers = {chosenSolver, self.candidates{:}};
91 proposedSolvers = self.candidates;
94 line_debug(
'AUTO trying %d candidate solvers for LayeredNetwork', length(proposedSolvers));
95 for s = 1:length(proposedSolvers)
97 solver = proposedSolvers{s};
98 line_debug(
'AUTO attempting solver: %s', solver.getName());
99 runtime = solver.runAnalyzer(options);
101 % Copy results from the successful solver
102 if ~isempty(solver.result)
103 self.result = solver.result;
104 % Update the solver name to reflect AUTO solver
105 self.result.('solver') = self.getName();
106 self.result.SelectedSolver = solver.getName();
109 if self.options.verbose
110 line_printf('AUTO solver: analysis completed successfully by %s.\n', solver.getName());
114 if self.options.verbose
115 line_printf('AUTO solver: %s failed with error: %s\n', proposedSolvers{s}.getName(), ME.message);
120 % If we get here, all solvers failed
121 line_error(mfilename,
'All candidate solvers failed to analyze the model.');