-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
BUG: fix convergence tolerance in _lsq.check_termination
#13806
Conversation
_lsq.check_termination
Thanks @FFroehlich. Did you find this problem when using one of the optimization functions? And can you construct a regression test (i.e. a unit test that fails before this fix, and works after it)? Also note that tests are failing right now. |
I found this in the context of an optimizer comparison where I looked at convergence criteria of multiple optimizers. So it's not a practical issue I encountered, but more of a conceptual one. As this effectively results in less stringent (but theoretically more sound) convergence criteria, I find it difficult to provide a good regression test for this, especially since the optimizers do not store the optimization history. The best I could come up with checking the iteration number. With the previos implementation, optimization for |
It looks to me like @nmayorov you wrote this code, could you have a look? |
But is it theoretically justified? For me this is strikes me as a rather unconventional tolerance check.
I am not sure whether I would agree with this line of argument. I could simply multiply tolerances by 1e-2 or some other constant to ensure that test pass, but that wouldn't improve quality of the change. You could also argue that the optimization now terminates with 4 fewer steps (almost 10%) and just barely doesn't meet the already pretty stringent tolerance of 1e-14. |
It's tricky. I believe I definitely saw it implemented like this somewhere, but I agree it looks unconventional. Here are my thoughts on it. It is common wisdom that for large enough floating point numbers the correct measure of accuracy is relative tolerance, because computational algorithms will have errors proportional to the target value they estimate (not the best explanation, but I think it's more or less true and correct). The situation changes as the target value goes down to zero. And I wish there was some universal guidance and explanation on what to do in this situation, but as far as I know there is none. The most correct advice seems to be to specify "problem specific" absolute tolerance in this case. But having At first glance this formula has the following properties (assuming the final x is very close to the true value):
My conclusion is that the implemented formula will basically try to find more accurate solution if All in all, maybe it was better to go with the more standard formula, but now I guess it's probably better to keep the algorithm intact, because it was around for some time. Also you are not complaining about its performance, only about this conceptual thing (important, but in practice I have the old |
Reference issue
What does this implement/fix?
The implemented convergence check is quite unusual and I believe this was not intended. This changes the tolerance check such that xtol is a canonical absolute + relative tolerance
Additional information