-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
SciPEP: optimize: class based Optimizers #8552
base: main
Are you sure you want to change the base?
Conversation
MAINT: cleanup
doc/source/scipeps/1-Optimizer.rst
Outdated
|
||
Copyright | ||
========= | ||
Andrew Nelson and Scott Sievert, Feb 2018. |
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.
May I suggest that for all SciPEPs we use "This document has been placed in the public domain." (like for PEPs)?
File naming: I'd suggest for a filename |
doc/source/scipeps/1-Optimizer.rst
Outdated
+----------+------------------------------------------------------------------------+ | ||
| PEP: | 1 | | ||
+----------+------------------------------------------------------------------------+ | ||
| Title: | Introduction of Optimizer and Function classes for scalar minimisation | |
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.
Optimizer
makes sense as a name; it would be good to replace Function
with something more specific
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.
The #8328 is using ScalarFunction
and VectorFunction
, but not making them public. Those classes are very similar to what is proposed for this approach, but there are some technical differences in current implementation which would have to be ironed out. For example, tracking number of function evaluations, how some memoization is carried out, etc.
doc/source/scipeps/1-Optimizer.rst
Outdated
* The user wishes to halt optimization early (issues `#4384 | ||
<https://github.com/scipy/scipy/issues/4384>`_, `#7306 | ||
<https://github.com/scipy/scipy/issues/7306>`_). | ||
* This would be simply achieved in the new framework via |
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.
some more housekeeping: this doesn't render quite right in https://github.com/andyfaff/scipy/blob/8fcd7d98c5fa1fddd765b08e4426d4b493f48420/doc/source/scipeps/1-Optimizer.rst
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.
Is there a quick way of rendering the document on my computer to see if I am improving things?
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.
There is if we'd actually add it to the html docs in this PR. Although rebuilding the docs isn't really faster than pushing to Github and viewing the reST rendering. There are also tools to locally view rendered reST, but I don't use those so don't have a good recommendation.
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.
You could paste your code into an online reST editor like http://rst.ninjs.org/ if you want to quickly check for formatting & rendering errors.
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.
Something went wrong with git here @stsievert. |
Resolved, and the formatting is still fixed. |
What's the next step for this? |
Yes, it's lain fallow for a while. @rgommers, given that this is the first PEP for scipy I wonder if your experience with NEPs gives any insight in how we go about discussing and merging this? |
I have added a link to the first mailing list discussion on this proposal in the PR description. There's a couple of things to do I think:
There's probably also a few points from the previous discussion to address. For example, the proposal asserts that maintenance costs will be much reduced, however @pv argued that they may actually be increased plus a significant rewrite for reverse-communication style may be needed. |
To clarify the next two steps are:
Then discussion, etc. With respect to the maintenance costs, we discuss how the maintenance costs should change. @pv mentions that maintenance costs could increase due to reverse communication style, and that coding becomes more complex. As far as I understand 'forward communication style' means that the parameter list fully specifies the problem, and reverse communication style presumably means the opposite, i.e. some parameters are held in attributes. In my experience writing |
Yes, that's what I was suggesting. |
I believe the most recent comment about this is (from @andyfaff in gh-18742):
|
Hi @andyfaff , I've seen that this is around since a long time, and I would be willing to help to push this forward (or even create a standalone pkg, following the "specialized package" way). Overall, what the SciPEP wants seems very close to what we independently implemented in zfit, a general purpose fitting library built to be powerful enough to give the user control and separater things (plus to be fast using jitted backends). Making this design, as it is about here, available to more users would be great! I see that there has been a lack of progress recently, but if you're up to, I am gladly in to push and polish this further, so just to understand what's your take on the PR and time in the near future, not to have an asynchronous back-and-forth over a long period of time. Content wise, I think there is one thing that was not so much discussen in the whole proposal, the stopping criterion. While some minimizers have these built in, I think there should also be a certain object that handles that. Currently, minimizers are (extremely) hard to compare in their performance, as they use vastly different criteria. But something I am gladly up to discuss, such as the rest of the PR |
I think the way to go on this is would be to make a separate package. After a period of refinement the aim would be to reincorporate it into scipy. However, there's no guarantees on that, only if it was shown to have demonstrable benefit. A period of refinement would allow the class design to be polished. I don't know how much improvement could be made over the method backends for speed, that would involve quite a bit of rewriting. If that were to happen we'd be wanting that work to be already folded into the existing minimize methods. If you have some thoughts on how to improve performance we'd be willing to hear. I wasn't thinking of having a method that would do all the iteration, only exposing the next method so that the user can control how the minimisation proceeds. There could then be a |
Sounds reasonable, and also there is maybe not even a need to incorporate this back (scipy is great, but maybe rather a bit too large in terms of scope). Are you interested/have time to tackle this and see if we find common ground and a way forward?
Okay, I see! So my view on this: So iteration seems nice, but just a consistent API (one API, the class constructor, to configure the algorithm, different for each one; one API to minimize the function, the same for each one) to minimize a function seems to me the most pressing issue. Needless to say that any |
This PEP proposes that the scipy scalar minimizers are rewritten in class based form. See also #8414.
@stsievert
Mailing list discussion: https://mail.python.org/pipermail/scipy-dev/2018-February/022443.html