-
Notifications
You must be signed in to change notification settings - Fork 224
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
abstract DifferentiableFunction #128
Conversation
- df.f(x) syntax in the long run should be replaced by evalf(df, x) - SimpleDifferentiableFunction is the Function-based implementation that gets used by default and is compatible with the df.f(x) syntax used for the old DifferentiableFunction - df.f(x) is replaced in linesearch algorithms (interpolating linesearch has come minor optimizations of calling evalfg!() instead of separate calls to f() and g!()) - TwiceDifferentiableFunction also made abstract
I'm not really sold on this change. In general, I think we should exploit attempts to optimize closures in Base Julia rather than try to work around it. I also would like to see us move away from the |
It might be regarded as a closure performance workaround, but the intention is to allow callable objects be used with Optim package. |
I'm hoping to move in the opposite direction as we redesign the API, so closing out. |
Is there some document that outlines the new design of |
In the long term, I'd like to move towards an API that takes in arbitrary callables and uses only the number of arguments and the types of the trailing arguments to do dispatch. For a concrete example, something like We could also adopt a more complex API like that used by NLopt. For now, I mostly want to remove the gap between the |
I think this PR implements the very API you're talking about. Reopen? |
This is related to #53, #94, #102 etc.
With the current implementation of
DifferentiableFunction
it's not very convenient to implement functions that require external data for evaluation. It always ends up writing something likebefore every optimizer invocation.
This PR turns
DifferentiableFunction
into an abstract type, and calls likedf.f(x)
are supposed to be replaced byevalf(df, x)
.The old
DifferentiableFunction
is renamed intoSimpleDifferentiableFunction
. SinceSimpleDifferentiableFunction
is used when one wants to convert 3 functions intoDifferentiableFunction
object, the current Optim code does not require any modifications.