-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5.x: Parameter limits in the Fit Page are not respected. #1999
Comments
This seems related to #965, though, that ticket does say this issue is resolved in 5.x. |
This seems to pop up not infrenquently from what I recollect but not sure we've ever succeeded in tracking it down. It seems however that it must be either in the way the fitting object is prepared and sent to bumps or in bumps itself? Perhaps @pkienzle has more recollection of this? |
Bumps is using a penalty function for values outside the bounds in Levenberg-Marquardt which does not guarantee that values will stay in range. The simple solution is to use to use "mp" instead of "lm" for least squares optimization:
and remove "lm" from the available fitters:
|
Forgive my ignorance, but what is "mp"? |
MPFit ("mp") is an alternative L-M fitter that supports bounds. I don't know if it is in version of bumps used by sasview. I see that it is missing from the bumps docs. |
I propose modifying bumps to use MPFit instead of scipy.leastsq for L-M fitting. The results will be slightly different due to differences in calculation of the Jacobian and general numerical noise, but it should not impact results significantly. A test of a simple fit gives a difference on the order of 1e-8 in the resulting parameter values. |
Test with bumps/bumps#89 to see if it fixes the problem. |
Thanks @pkienzle I was about to ask about LMFIT, which seems to be an extension of sipy, vs MPFIT which is based on MINPACK but I see you already have it? mp is not listed in the docs for bumps 0.8.1 as an option? was that one of those "hidden" options? |
FYI from scipy v1.7.1 manual for
So the manual explicitly states that |
Bumps quickly hacked in a L-M fitter so that sasview only needed to support one optimizer infrastructure. The author (me) didn't necessarily do a good job of it. IIRC, I was using arctan to map [-∞, ∞] into [-1, 1] to handle bounds prior to Bumps; I don't know why I decided that simple penalty function would be good enough. |
Fixed in 5.0.5 by upgrading bumps version |
I've reopened this issue because I'm seeing some concerning behaviour in Release 5.0.5 using the (new) L-M optimizer. Run 5.0.5 I'm getting this:
We should fix this for 5.0.6. |
You do not get these errors if you only change the Max limit of a parameter. And you do not get these errors if you switch to a different optimizer. It is specific to the L-M. |
I just tested this and was able to reproduce the error @smk78 is noting. If you set a range with the starting value outside the fit range, this error happens. This happens when either the |
Latest bug now fixed by PR #2422 |
This defect was originally reported by User AdrianR using 5.0.3 on 28 Dec 2020 but I cannot find a corresponding issue (@krzywon might...). However, User GregS has now reported the same issue using 5.0.4 which suggests no fix was implemented. So am logging the issue here.
Adrian said:
Greg says:
The text was updated successfully, but these errors were encountered: