LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
iterate.m
1function [runtime, sruntime, results] = iterate(self, options)
2% [RUNTIME, SRUNTIME, RESULTS] = ITERATE()
3T0 = tic;
4it = 0;
5options = self.options;
6E = getNumberOfModels(self);
7results = cell(1,E);
8sruntime = zeros(1,E); % solver runtimes
9init(self);
10% nearly identical, but parfor based
11while ~self.converged(it) && it < options.iter_max
12 it = it + 1;
13 line_debug('EnsembleSolver iteration %d starting (max=%d)', it, options.iter_max);
14 self.pre(it);
15 sruntime(it,1:E) = 0;
16 T1=tic;
17 switch options.method
18 case {'parallel'}
19 parfor e = self.list(it)
20 [results{it,e}, solverTime] = self.analyze(it,e);
21 sruntime(it,e) = sruntime(it,e) + solverTime;
22 end
23 otherwise
24 for e = self.list(it)
25 line_debug('Analyzing ensemble model %d at iteration %d', e, it);
26 [results{it,e}, solverTime] = self.analyze(it,e);
27 sruntime(it,e) = sruntime(it,e) + solverTime;
28 end
29 end
30 self.results = results;
31 if options.verbose
32 Tsolve(it)=toc(T1);
33 Ttot=toc(T0);
34 line_printf('\nIter %2d. ',it);
35 end
36 T2=tic;
37 self.post(it);
38 Tsynch(it)=toc(T2);
39 if options.verbose
40 line_printf('\b Analyze time: %.3fs. Update time: %.3fs. Runtime: %.3fs. ',Tsolve(it),Tsynch(it),Ttot);
41 end
42end
43finish(self);
44runtime = toc(T0);
45if options.verbose
46 line_printf('\nSummary: Analyze avg time: %.3fs. Update avg time: %.3fs. Total runtime: %.3fs. ',mean(Tsolve),mean(Tsynch),runtime);
47end
48end