| Line | |
|---|
| 1 | function convergence=controlconvergence(J,fit,eps_cm,n)
|
|---|
| 2 | %CONTROLCONVERGENCE - determine the convergence of control_core solution
|
|---|
| 3 | %
|
|---|
| 4 | % Usage:
|
|---|
| 5 | % converged=controlconvergence(J,fit,eps_cm,n);
|
|---|
| 6 |
|
|---|
| 7 | convergence=false;
|
|---|
| 8 | if ~isnan(eps_cm),
|
|---|
| 9 | i=n-2;
|
|---|
| 10 | %go through the previous misfits(starting from n-2)
|
|---|
| 11 | while (i>=1),
|
|---|
| 12 | if (fit(i)==fit(n)),
|
|---|
| 13 | %convergence test only if we have the same misfits
|
|---|
| 14 | if ((c(i).J-c(n).J)/c(n).J <= eps_cm),
|
|---|
| 15 | %convergence if convergence criteria fullfilled
|
|---|
| 16 | convergence=true;
|
|---|
| 17 | displaystring(verbose,'\n%s%g%s%g\n',' Convergence criterion: dJ/J = ',(c(i).J-c(n).J)/c(n).J,'<',eps_cm);
|
|---|
| 18 | else
|
|---|
| 19 | displaystring(verbose,'\n%s%g%s%g\n',' Convergence criterion: dJ/J = ',(c(i).J-c(n).J)/c(n).J,'>',eps_cm);
|
|---|
| 20 | end
|
|---|
| 21 | break;
|
|---|
| 22 | end
|
|---|
| 23 | i=i-1;
|
|---|
| 24 | end
|
|---|
| 25 | end
|
|---|
| 26 |
|
|---|
| 27 | end %end function
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.