-
-
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
ENH: scipy.optimize - adding differential_evolution #3446
Conversation
Some benchmarking results. |
@andyfaff there's some merge conflict already. Can you rebase on current master? That'll make the tests on TravisCI run. And test coverage will be reported. |
For future commits, commit messages in the form described at http://docs.scipy.org/doc/numpy-dev/dev/gitwash/development_workflow.html#writing-the-commit-message would be good to have. |
Also, you have a bunch of commit messages that are (almost) exact duplicates of each other. Would be good to squash those. |
|
||
__all__ = ['differential_evolution'] | ||
|
||
MACHEPS = 2.22e-16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np.finfo(np.float64).eps
is less magical.
I made some initial comments based on a quick read. Will try to play with this later, kind of low on bandwidth now. Anyway looks promising. |
Thanks for comments, a large proportion are due to newness to git... |
Eliminates another local variables.
…nitial comment for the source file.
@dlax, I don't know why the Travis is failing on the Python2.6 machine.
Here is my remote list:
origin https://github.com/andyfaff/scipy.git (fetch) When I look at gitk the code was rebased onto scipy/master On 15 May 2014 18:29, Denis Laxalde notifications@github.com wrote:
Dr. Andrew Nelson |
The failing test is in code that I wrote which looks completely unrelated. It looks like a NaN sneaked into a test matrix, and earlier versions of python/numpy do not appreciate taking abs of NaN? |
So why aren't other recent Travis tests failing? On 16 May 2014 11:38, argriffing notifications@github.com wrote:
Dr. Andrew Nelson |
I have no idea. The failing test uses random numbers, but it sets a seed. |
This PR involves a lot of random numbers and initialising of On Friday, May 16, 2014, argriffing notifications@github.com wrote:
Dr. Andrew Nelson |
NaNs popping out from nowhere can be a symptom of mismatching C prototypes (e.g. This cannot be due to this PR, as it only touches Python code. However, if this is the cause, the error can be anywhere in Scipy codebase (including any libraries we use --- there were bugs like this in the SuperLU code). One typical pattern is that the failure disappears if you run only a part of the test suite. Another possibility is that this is something Numpy 1.5.1 related. |
This commit is pure python.
|
Yes, this class of bugs is exactly one that can be exposed by unrelated changes that do not actually cause the issue. |
OTOH, now that I think of it, these issues were previously always specific to i386, (cf eg 4796e0d) whereas the failing build bot is 64-bit. I don't recall if this can occur on 64-bit platforms as the calling convention is IIRC different... The reason why the NaN appears should be traced to resolve this. |
Unfortunately I don't know enough about the scipy/numpy code base to go
|
This seems likely to me. If your PR is changing the random numbers in unrelated tests, then the failing |
The failing test sets the seed of the random generator, so it seems unlikely to me that this is due to differences in the random sequence. Anyway, in my opinion this does not block merging, since it's clearly not something introduced by this PR. I'm also not able to reproduce the issue on my machine. |
ENH: scipy.optimize - adding differential_evolution
Ok, merged. Thanks @andyfaff and everyone involved in the review. |
@andyfaff The description of this new global optimization feature could be added to https://github.com/scipy/scipy/blob/master/doc/release/0.15.0-notes.rst if you want to write a blurb? |
I tried to debug the failing One problem is that I can't find the TravisCI traceback anymore, but I vaguely remember it was an abs failure in the exact one-norm in one of the scaled expm_multiply tests. I've instrumented the exact one-norm by checking that it doesn't have nans and I've increased the number of scaled tests from 10 to 1000 but I still haven't seen any weirdness of the kind that would have triggered that test failure. |
Sure.
|
Differential evolution (DE) is an algorithm that is widely used for minimizing functions that have multiple global minima. As such it is widely used in curvefitting applications. This pull request adds the differential_evolution function to scipy.optimize, and will complement basinhopping.
[1] Storn, R and Price, K, Differential Evolution - a Simple and
Efficient Heuristic for Global Optimization over Continuous Spaces,
Journal of Global Optimization, 1997, 11, 341 - 359.
[2] http://en.wikipedia.org/wiki/Differential_evolution