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
differential_evolution: make callback receive fun(xk) #6878
Comments
see #6890 |
This change would break any current usage of It is not easy to add an extra argument without breaking backwards compat, would need:
It is possible, and I can see the benefit, but the implementation would be ugly. Any other opinions? |
I'd rather have the "internal" iteration loop exposed in an API so that users would be free to invoke a "callback" as they want. Something like:
Just a thought... |
I'm not keen to change the callback signature because there are so many
attributes that could be useful to expose. If they're all sent to the
callback function then the callback function will get less and less like
the callback functions for the other minimizers.
I think the way that Denis displayed (i.e. using `next`) is much preferable
as all the innards are available from the solver object. Indeed, the whole
idea of __next__ was for the user to do something like this.
Denis, I'm not quite sure what you meant by exposing the iteration loop in
an API.
Adding a context manager is a really good idea.
|
Andrew Nelson a écrit :
Denis, I'm not quite sure what you meant by exposing the iteration loop in
an API.
I just meant what I illustrated in the example code ;)
That would mean making the DifferentialEvolutionSolver part of the
public API and have its `__next__` method return a "step" object
instance with all information bits about current iteration status
attached so that it can later be eventually extended without breaking bw
compat.
In general, it seems to me that with complex solvers like DE we should
try to expose a reasonably flexible API rather than trying to make all
use cases fit into the functional API with callbacks and friends. Giving
control on the iteration loop is probably the first step towards this.
|
Hm, I'm giving up for now. But creating custom termination functions would still be useful... |
#6905 exposes |
#6907 now the diff is displayed correctly |
@dlax's suggestion sounds good to me... |
ZacDiggum a écrit :
@dlax <https://github.com/dlax>'s suggestion sounds good to me...
Okay, I'll try to scratch an initial implementation of this idea soon so
we can discuss further.
|
It sounds like the preferred approach would be a different interface with more control (rather than adding more information to the callbacks), so I'll go ahead and close this. Feel free to reopen if I've missed something. |
In
differential_evolution
thecallback
function receives the current best parameter setxk
andconvergence
but not the current function valuefun(xk)
. For implementing a function value driven termination one needs to evaluate the function once more insidecallback
with the help ofxk
. Especially with small poplation sizes this creates an unnecessary overhead.Could
callback
be altered so that it receivesxk, fun(xk), convergence
? Please?The text was updated successfully, but these errors were encountered: