Mercurial > hg > octave-thorsten
changeset 8990:349d75161672
more cosmetic adjustments to fsolve
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 17 Mar 2009 13:38:16 +0100 |
parents | 46a12e3f882c |
children | c235a59d30a4 |
files | scripts/ChangeLog scripts/optimization/fsolve.m |
diffstat | 2 files changed, 16 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -7,6 +7,7 @@ unless two successful iterations have occured. * optimization/__dogleg__.m: Add missing alpha in the zero-gradient case. + * optimization/fsolve.m: Remove autodg (not used), simplify. 2009-03-14 Jaroslav Hajek <highegg@gmail.com>
--- a/scripts/optimization/fsolve.m +++ b/scripts/optimization/fsolve.m @@ -164,8 +164,6 @@ tolf = optimget (options, "TolFun", sqrt (macheps)); factor = 100; - ## FIXME: TypicalX corresponds to user scaling (???) - autodg = true; niter = 1; nfev = 1; @@ -174,6 +172,7 @@ info = 0; ## Initial evaluation. + ## Handle arbitrary shapes of x and f and remember them. fvec = fcn (reshape (x, xsiz)); fsiz = size (fvec); fvec = fvec(:); @@ -200,7 +199,6 @@ while (niter < maxiter && nfev < maxfev && ! info) ## Calculate function value and Jacobian (possibly via FD). - ## Handle arbitrary shapes of x and f and remember them. if (has_jac) [fvec, fjac] = fcn (reshape (x, xsiz)); ## If the jacobian is sparse, disable Broyden updating. @@ -231,31 +229,27 @@ ## Get column norms, use them as scaling factors. jcn = norm (fjac, 'columns').'; if (niter == 1) - if (autodg) - dg = jcn; - dg(dg == 0) = 1; - endif + dg = jcn; + dg(dg == 0) = 1; xn = norm (dg .* x); ## FIXME: something better? delta = max (factor * xn, 1); endif - ## Rescale if necessary. - if (autodg) - ## FIXME: the original minpack used the following rescaling strategy: - ## dg = max (dg, jcn); - ## but it seems not good if we start with a bad guess yielding jacobian - ## columns with large norms that later decrease, because the corresponding - ## variable will still be overscaled. So instead, we only give the old - ## scaling a small momentum, but do not honor it. + ## Rescale adaptively. + ## FIXME: the original minpack used the following rescaling strategy: + ## dg = max (dg, jcn); + ## but it seems not good if we start with a bad guess yielding jacobian + ## columns with large norms that later decrease, because the corresponding + ## variable will still be overscaled. So instead, we only give the old + ## scaling a small momentum, but do not honor it. - dg = max (0.1*dg, jcn); + dg = max (0.1*dg, jcn); - ## It also seems that in the case of fast (and inhomogeneously) changing - ## jacobian, the Broyden updates are of little use, so maybe we could - ## skip them if a big disproportional change is expected. The question is, - ## of course, how to define the above terms :) - endif + ## It also seems that in the case of fast (and inhomogeneously) changing + ## jacobian, the Broyden updates are of little use, so maybe we could + ## skip them if a big disproportional change is expected. The question is, + ## of course, how to define the above terms :) lastratio = 0; nfail = 0;