-
-
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: add differential-evolution to minimize #10778
Conversation
@mdhaber, you seem to be an RST expert. Can you tell from inspecting the changes I made to |
scipy/optimize/_minimize.py
Outdated
@@ -77,6 +78,7 @@ def minimize(fun, x0, args=(), method=None, jac=None, hess=None, | |||
- 'trust-ncg' :ref:`(see here) <optimize.minimize-trustncg>` | |||
- 'trust-exact' :ref:`(see here) <optimize.minimize-trustexact>` | |||
- 'trust-krylov' :ref:`(see here) <optimize.minimize-trustkrylov>` | |||
- 'differential-evolution' :ref:`(see here) <`scipy.optimize.differential_evolution`>` |
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.
Maybe here?
- 'differential-evolution' :ref:`(see here) <`scipy.optimize.differential_evolution`>` | |
- 'differential-evolution' :ref:`(see here) <optimize.differential_evolution>` |
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.
Hmm that might not be all:
/home/circleci/repo/build/testenv/lib/python3.7/site-packages/scipy/optimize/_minimize.py:docstring of scipy.optimize.minimize:41: WARNING: undefined label: (see here) <`scipy.optimize.differential_evolution (if the link has no caption the label must precede a section header)
/home/circleci/repo/build/testenv/lib/python3.7/site-packages/scipy/optimize/_minimize.py:docstring of scipy.optimize.minimize:309: WARNING: undefined label: scipy.optimize.differential_evolution (if the link has no caption the label must precede a section header)
/home/circleci/repo/build/testenv/lib/python3.7/site-packages/scipy/optimize/optimize.py:docstring of scipy.optimize.show_options:51: WARNING: undefined label: scipy.optimize.differential_evolution (if the link has no caption the label must precede a section header)
I'll look into it but hah I'm no expert. I just had the misfortune of fighting with it a lot when working on the contributor guide.
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.
Following https://github.com/scipy/scipy/pull/8328/files as an example of all the changes made to add a method to minimize
, it looks like you might need to add a file analogous to:
scipy/doc/source/optimize.minimize-trustconstr.rst
That file seems to define the reference like:
.. _optimize.minimize-trustconstr:
that is referred to like:
:ref:
(see here) <optimize.minimize-trustconstr>`
I should update the contributor guide with this stuff.
scipy/optimize/_minimize.py
Outdated
@@ -326,6 +330,9 @@ def minimize(fun, x0, args=(), method=None, jac=None, hess=None, | |||
used to solve the subproblems with increasing levels of accuracy | |||
as the iterate gets closer to a solution. | |||
|
|||
Method :ref:`differential-evolution <scipy.optimize.differential_evolution>` uses |
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.
Method :ref:`differential-evolution <scipy.optimize.differential_evolution>` uses | |
Method :ref:`differential-evolution <optimize.differential_evolution>` uses |
scipy/optimize/optimize.py
Outdated
@@ -3008,6 +3008,7 @@ def show_options(solver=None, method=None, disp=True): | |||
- :ref:`SLSQP <optimize.minimize-slsqp>` | |||
- :ref:`dogleg <optimize.minimize-dogleg>` | |||
- :ref:`trust-ncg <optimize.minimize-trustncg>` | |||
- :ref:`differential-evolution <scipy.optimize.differential_evolution>` |
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.
- :ref:`differential-evolution <scipy.optimize.differential_evolution>` | |
- :ref:`differential-evolution <optimize.differential_evolution>` |
It looks like there is usually an addition to |
Let's see if this works. I added the extra rst file. However, in this form the documentation for |
All green. I'll can add dual_annealing, etc, in a subsequent PR. |
@andyfaff was this discussed somewhere? I haven't followed this, but intuitively it seems a little odd to add a global optimization as one of the methods in the interface for local optimization. |
@rgommers, no it wasn't discussed, putting it on the mailing list is probably a good idea. I guess I don't really see them as local vs global minimizers as such. To me they're all do the same thing, multivariate scalar minimisation, just with different flavours for finding the minimum. basinhopping/differential_evolution/shgo/dual_annealing all use the same kind of input as the 'local' minimizers. I thought it would be nice if they could use the same Perhaps the local <--> global distinction in the docs doesn't need to be as pronounced as it is. There could be a reorg of the page to have 'local' minimize methods and 'global' minimize methods. I've got no particular axe to grind here, apart from thinking it would be nice to use them through the minimize function. |
Hmm, at a very high level perhaps. There's a reason that the global optimizers call local ones to improve the results once an approximate minimum has been found. I think it's quite an important distinction for users to understand. Let's see what others think. |
I think it's an important distinction for users to understand, but I don't think we need to artificially enforce it by avoiding a unified interface. The problems are specified in the same way, and the global solvers could use a unified interface, so I wouldn't mind bringing them into minimize. |
@andyfaff please feel free to push this forward, if others think it's a good idea or at least are not -1 then it's fine with me. I would suggest to mention it on the mailing list as I said above. |
Force pushed to resolve merge conflicts |
What about having 3 functions:
This would allow to keep the logical separation between the two classes (which is paramount IMO) and still provide the end user with a simple interface. You could even have a flag to call local or global, etc. |
@andyfaff You closed because you don't want that we do this anymore or you just don't want to do this yourself? |
I think it would work well in minimize, but it didnt seem there was much groundswell for it. |
As pointed out it would be good to discuss this further with others, so going through the mailing list. |
This PR adds a 'differential-evolution' method to
minimize
.