-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
find_minimum_on_interval() uses the wrong scipy function #2607
Comments
comment:3
It seems that there are two global optimizers in scipy: scipy.optimize.anneal and scipy.optimize.brute. Does anybody more experienced in numerics know, which one is better for including into Sage? |
comment:5
Robert, that sounds like a great question for either sage-devel or the scipy list. |
comment:7
This Scipy tutorial page should be relevant. I will try to resolve this soon. |
Changed keywords from none to sd31 |
comment:8
#5960 was a dup. Here are the examples from there.
|
comment:9
The
Which is not the same as constrained minimization, for us. |
comment:10
It seems like finding a local minimum might be the best you can hope for with a general function. Wouldn't finding an absolute minimum (on an interval) be intractable unless you can exploit some special structure of the function? |
comment:11
Answering the question first... Sure, but it would be nice if we at least got the 'right' answer for 'easy' functions. That's all I'm looking for here, not things like finding a minimum on a set of measure zero... I think we can fix Brent to use this. Compare:
This shows that brent does give the 'right' answer in this case. So when does it give a 'wrong' answer?
Well, of course - there IS no calculus-style minimum of sin between 0 and pi! Only a minimum relative to the interval itself. Interesting that it goes all the way to 7/2pi, rather than 3/2pi, but oh well! So the fix is to switch to Brent, and then if it gives an answer outside the interval, pick the 'lower' endpoint. This would need lots of testing with well-behaved functions to make sure they actually work correctly. |
comment:12
But how will you explain to users which functions are 'easy', and when they should expect to get the 'right' answer? I think it's better design to just change the contract of this function to admit that it is only looking for local minima. |
comment:13
It doesn't matter. Or, at worst, we add some documentation to clarify that. The reason it doesn't matter is that this is still better than the other. Unless you can produce some (natural) examples where optimize.brent does the same. The Scipy documentation is not 100% clear on what is done, and it's conceivable they are the same. It's certainly possible that in fact using optimize.brent in the way I'm suggesting would be just as 'bad' as the previous one, or even essentially equivalent. But it would be nice to have an explicit example of this before we resort to that. |
comment:14
Here's another example where
Of course, this does cause problems for my supposed algorithm to then go back to an endpoint, since it's just outside of it... |
comment:17
Suggestions in person about how to further enhance the messages in documentation. Thank you so much for doing this - don't forget to open a followup ticket. |
Reviewer: Karl-Dieter Crisman |
comment:21
Needs work for sentence that doesn't end and |
comment:23
should Paul |
comment:24
after applying both patches on Sage 5.0, I still get:
Did I something wrong? Paul |
comment:25
The patch doesn't change the behaviour, it only warns the user that it only returns some local minimum. |
Changed dependencies from sage-5.1.beta2 to #13109 |
comment:61
Added patch to switch the deprecation to the new syntax. |
Updated patch |
comment:62
Attachment: trac_2607_update_deprecation.patch.gz |
Changed author from Dan Drake, Andrey Novoseltsev, Andrzej Giniewicz to Dan Drake, Andrey Novoseltsev, Andrzej Giniewicz, Volker Braun |
This comment has been minimized.
This comment has been minimized.
comment:64
Deprecation changes look good to me. |
comment:65
(and all tests still pass) |
Merged: sage-5.3.beta0 |
This was reported by Dean Moore on sage-support. Consider:
So find_minimum_on_interval() returns a local minimum as opposed to the global one. (The same issue applies to find_maximum_on_interval.) This is due to the fact that the function wraps scipy.optimize.fminbound, which is only a local optimizer (Carl Witty pointed this out). We should instead use one of the global optimizers, i.e. scipy.optimize.anneal or scipy.optimize.brute.
Apply:
Depends on #13109
CC: @robert-marik @kcrisman
Component: calculus
Keywords: sd31, sd40.5
Author: Dan Drake, Andrey Novoseltsev, Andrzej Giniewicz, Volker Braun
Reviewer: Karl-Dieter Crisman, Mike Hansen, Andrey Novoseltsev
Merged: sage-5.3.beta0
Issue created by migration from https://trac.sagemath.org/ticket/2607
The text was updated successfully, but these errors were encountered: