# HG changeset patch # User Jaroslav Hajek # Date 1233128309 -3600 # Node ID 38482007c834e3ff04149ca4786d258eb007db89 # Parent 20d23d65cc8414fb9443db8d72f180add8b1c066 relax scaling in fsolve and use class-dependent default tolerances diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2009-01-28 Jaroslav Hajek + + * optimization/fsolve.m: Use more adaptive rescaling. + Put back the default tolerances based on machine eps respecting + the used precision. Partially reflect this in the default optimset + values. + 2009-01-28 Jaroslav Hajek * miscellaneous/ordefields.m: Use indexed assignment instead of a diff --git a/scripts/optimization/fsolve.m b/scripts/optimization/fsolve.m --- a/scripts/optimization/fsolve.m +++ b/scripts/optimization/fsolve.m @@ -77,7 +77,7 @@ ## Get default options if requested. if (nargin == 1 && ischar (fcn) && strcmp (fcn, 'defaults')) x = optimset ("MaxIter", 400, "MaxFunEvals", Inf, \ - "Jacobian", "off", "TolX", 1e-7, "TolF", 1e-7, + "Jacobian", "off", "TolX", 1.5e-8, "TolF", 1.5e-8, "OutputFcn", [], "Updating", "on", "FunValCheck", "off"); return; endif @@ -111,8 +111,8 @@ macheps = eps (class (x0)); - tolx = optimget (options, "TolX", 1e-7); - tolf = optimget (options, "TolFun", 1e-7); + tolx = optimget (options, "TolX", sqrt (macheps)); + tolf = optimget (options, "TolFun", sqrt (macheps)); factor = 100; ## FIXME: TypicalX corresponds to user scaling (???) @@ -182,7 +182,19 @@ ## Rescale if necessary. if (autodg) - dg = max (dg, jcn); + ## 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); + + ## 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 nfail = 0;