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
17 line_debug(options,
'AUTO: using lang=python, delegating to native line_solver');
18 [QN,UN,RN,TN,AN,WN,runtime] = PYLINE.getAvg(
'SolverAuto', self.model, options);
19 self.setAvgResults(QN,UN,RN,TN,AN,WN,[],[],runtime,options.method,NaN);
23 jmodel = LINE2JLINE(self.model);
24 M = jmodel.getNumberOfStations;
25 R = jmodel.getNumberOfClasses;
26 jsolver = JLINE.SolverAuto(jmodel, options);
27 [QN, UN, RN, WN, AN, TN] = JLINE.arrayListToResults(jsolver.getAvgTable);
28 runtime = jsolver.result.runtime;
31 QN = reshape(QN
', R, M)';
32 UN = reshape(UN
', R, M)';
33 RN = reshape(RN
', R, M)';
34 TN = reshape(TN
', R, M)';
35 WN = reshape(WN
', R, M)';
36 AN = reshape(AN
', R, M)';
37 self.setAvgResults(QN, UN, RN, TN, AN, WN, CN, XN, runtime, options.method, NaN);
38 self.result.SelectedSolver = char(jsolver.result.selectedSolver);
41 % Fall through to MATLAB implementation below
44% Delegate to
the appropriate solver
45switch class(self.model)
47 % Select
the best solver
48 if length(self.candidates) > 1
49 chosenSolver = self.chooseSolver(
'getAvg');
50 if chosenSolver.supports(self.model)
51 proposedSolvers = {chosenSolver, self.candidates{:}};
53 proposedSolvers = self.candidates;
56 proposedSolvers = {self.solvers{:}};
59 % Try each proposed solver
60 line_debug(
'AUTO trying %d candidate solvers', length(proposedSolvers));
61 for s = 1:length(proposedSolvers)
63 solver = proposedSolvers{s};
64 line_debug(
'AUTO attempting solver: %s', solver.getName());
65 runtime = solver.runAnalyzer(options);
67 % Copy results from
the successful solver
68 if ~isempty(solver.result)
69 self.result = solver.result;
70 % Update
the solver name to reflect AUTO solver
71 self.result.('solver') = self.getName();
72 self.result.SelectedSolver = solver.getName();
75 if self.options.verbose
76 line_printf('AUTO solver: analysis completed successfully by %s.\n', solver.getName());
80 if self.options.verbose
81 line_printf('AUTO solver: %s failed with error: %s\n', proposedSolvers{s}.getName(), ME.message);
86 % If we get here, all
solvers failed
87 line_error(mfilename,
'All candidate solvers failed to analyze the model.');
90 % Similar logic
for LayeredNetwork
91 line_debug(
'AUTO handling LayeredNetwork model');
92 chosenSolver = self.chooseSolver(
'getAvg');
93 if chosenSolver.supports(self.model)
94 proposedSolvers = {chosenSolver, self.candidates{:}};
96 proposedSolvers = self.candidates;
99 line_debug(
'AUTO trying %d candidate solvers for LayeredNetwork', length(proposedSolvers));
100 for s = 1:length(proposedSolvers)
102 solver = proposedSolvers{s};
103 line_debug(
'AUTO attempting solver: %s', solver.getName());
104 runtime = solver.runAnalyzer(options);
106 % Copy results from
the successful solver
107 if ~isempty(solver.result)
108 self.result = solver.result;
109 % Update
the solver name to reflect AUTO solver
110 self.result.('solver') = self.getName();
111 self.result.SelectedSolver = solver.getName();
114 if self.options.verbose
115 line_printf('AUTO solver: analysis completed successfully by %s.\n', solver.getName());
119 if self.options.verbose
120 line_printf('AUTO solver: %s failed with error: %s\n', proposedSolvers{s}.getName(), ME.message);
125 % If we get here, all
solvers failed
126 line_error(mfilename,
'All candidate solvers failed to analyze the model.');