LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
kpcfit_sub_acfit_outfun.m
1function stop = kpcfit_sub_acfit_outfun(x,optimValues,state,MaxIterAC,MaxTimeAC,tstart,f_best)
2global lgkx;
3global stagnval;
4global stagniter;
5stop = false;
6if strcmpi(state,'iter')
7 if mod(optimValues.iteration,MaxIterAC)==0 && optimValues.iteration>1
8 if ( optimValues.fval >f_best)
9 stop = true;
10 end
11 end
12 telapsed = toc(tstart);
13 if ( telapsed>MaxTimeAC && optimValues.iteration > MaxIterAC)
14 fprintf(1,'acfit: time limit reached in autocorrelation fitting\n');
15 stop = true;
16 end
17end
18if ~isnan(optimValues.fval) & sum(isnan(x)) == 0
19 lgkx = x; % last good known solution
20else
21 stop = true;
22 %fprintf(' optimization halted: numerical difficulties\n')
23end
24if stagnval == 0
25 stagnval = optimValues.fval;
26end
27delta = abs(optimValues.fval-stagnval)/stagnval;
28if delta < 0.01
29 stagniter = stagniter + 1;
30 if stagniter == 100
31 %fprintf(' optimization halted: stagnation ')
32 stop = true;
33 end
34else
35 stagniter = 0;
36end
37stagnval = optimValues.fval;
38end