-
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
[WIP] Replace method symbols with abstract types #149
Conversation
I like it. Should we deprecate choosing the algorithms via symbols? |
Super sweet! Should |
I don't know. I simply assumed so for some reason. Personally, I'm neutral to it.
yes, good catch! old habits... |
callback = nothing, | ||
show_every = 1, | ||
linesearch!::Function = hz_linesearch!, | ||
nargs...) |
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.
What's this? Let's avoid passing around things that aren't strictly necessary.
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.
what do you mean?
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.
What's the purpose of nargs...
?
This looks really great. Two concerns:
|
initial_x::Array, | ||
method::Optimizer; | ||
autodiff::Bool = false, | ||
nargs...) |
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.
I pass around nargs...
to not break this design choice using autodiff
as a KW args. This is because now this method is a generic fall-back.
See my last comment. I'm not sure how to solve this without breaking the
ok will do |
A question about |
Yes, we can't merge code that uses When I have some time free, I will figure out how to avoid the use of |
This makes sense to me. I'll give it a shot. |
Let me know what you think of this. Basically I put the general optimization options in |
👍 |
@Evizero, any plans to finish this up? It would be a very welcome contribution. |
I got sidetracked because the approach of optimizing Julia-functions directly turned out to be somewhat inconvenient for what I was working on at the time. Be that as it may, I do think the main bulk of work is done already. So if you're still interested in this, then I'll see to it that I finish this up within the next couple weeks. I'm currently drowning in work for an overdue project, but I do try to get a little Julia coding done each day. |
Definitely interested, I promise a quick review on my part |
Some progress. Still need to add the old methods back and deprecate them (e.g. |
Should |
Either is good by me if it helps you. |
Looks good to me. |
All right then! Tomorrow morning I will go over the code again to see if I missed something (like a test here or there) and then I'll resolve the merge conflicts with master so we can merge this! |
Just a quick question, do we need to export |
no, good point. I guess there is no benefit for the end user in having |
Conflicts: src/cg.jl src/nelder_mead.jl src/nnls.jl test/brent.jl test/callbacks.jl test/nelder_mead.jl test/newton.jl test/simulated_annealing.jl
So, I think this should be ok now as far as the API is concerned. I undid some commits here and there, since the
|
@@ -1,6 +1,14 @@ | |||
|
|||
for method in (:nelder_mead, | |||
:simulated_annealing) | |||
function cb(tr::OptimizationTrace) |
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.
This function and the one below should be removed. They got accidentally added in your rebase.
After removing those, tests pass on 0.5.
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.
Oh, I see. Well If I remove those then there is no test anymore that checks if the callback got called
Maybe an anonymous function will do the trick
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.
I am only talking about the two most upper ones. They seem completely unused since they get overwritten immediately.
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 are right, I saw them too and removed them.
Essentially, lgtm. Looking down over the |
@johnmyleswhite sorry to ping, but do you have any comments ? Besides a pre-merge squash maybe. |
I will review this tonight and make sure this gets merged unless there turns out to be an issue I don't expect -- which I think is extremely unlikely. |
@@ -52,36 +30,55 @@ optimize(f, [0.0, 0.0]) | |||
Optim will default to using the Nelder-Mead method in this case. We can specify the Nelder-Mead method explicitly using the `method` keyword: | |||
|
|||
```jl | |||
optimize(f, [0.0, 0.0], method = :nelder_mead) | |||
optimize(f, [0.0, 0.0], method = NelderMead()) |
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.
Should we encourage people to use keywords in the docs? I would think one of the main gains of the switch to types is the chance for completely static dispatch, which I would assume want to promote, although that's obviously a complex issue.
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.
I agree that it should go away most places, and it is my fault it is still in there. As mentioned above, in my latest comment, I figured it could get changed when some of the other API changes are made.
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.
Works for me.
Made some comments that could be up for discussion, but I'm happy with this and think it's ready to merge unless anyone wants to make changes. It's an impressively thorough body of high-quality work. Well done, @Evizero. |
Removed method keywords, clarified the reasons for use of user provided gradients, and clarified a dispatch comment.
Okay, so I created https://github.com/Evizero/Optim.jl/pull/5 . It is up to you @Evizero if you want to merge it. If you'd rather not, I'll just commit it after this merges. I agree this is solid work, and I really think it moves the package forwards. |
Fix README.md once more.
Thanks for the review and kind comments. I am glad that I could contribute something useful and will hopefully find myself in this position again. |
[WIP] Replace method symbols with abstract types
🎉 🎈 |
Thanks @Evizero, this is the biggest change to Optim in quite a while. |
By the way, regarding the lowercase letters in Edit: We can certain notify julia-opt, but we should probably note that this is the api for optimization, and that the api for accessing the results will also change soon. |
As discussed in #145 .
This works right now although the tests still need some clean-up.I thought this would be a good point to gather feedback