-
Notifications
You must be signed in to change notification settings - Fork 41
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
Introduce Aqua.jl-based checks #379
Conversation
I think I found something. This was fun and I removed a few ambiguities already. The remaining ones I might think about, but they are a bit tricky, when we allow both |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #379 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 74 73 -1
Lines 7241 7243 +2
=======================================
+ Hits 7224 7226 +2
Misses 17 17 ☔ View full report in Codecov by Sentry. |
I will rewrite it
This may be a bit hard to resolve. |
You would also usually not mix them up, because that would basically require to provide ab objective, a problem and another problem or such, so I am even fine with keeping the high-level interfaces on ignore. |
Oh a very nice rewrite dispatching on that again :) Well-done. |
I checked both the For the high level ones, I neither feel that would be easy to do nor that it might be a problem that there is an ambiguity. One would basically have to really mix two of the documented forms and provide two sub problem solvers, one in closed form , one as a problem, and not provide a state. |
…nopt.jl into kellertuer/adding-aqua
005db33
to
beb2c50
Compare
M = Circle()
f(::Circle, p) = p * 2 * p
swarm = [-π / 4, 0, π / 4]
s = particle_swarm(M, ManifoldCostObjective(f), swarm)
@test s ≈ 0.0 I will take a look at other ones too. EDIT: |
|
Ah I See the point with particle swarm, the main tricky thing seems really to be that we aim to cover single-number-cases as well, but it should be fine with just one extra case each hopefully then. for the last stepsize I agree; I would consider that function more internal though, but currently its signatures are a bitt all-obver-the.place and should be minimised / unified, I can check whether I see a way without breaking (too much). |
I fixed last stepsize. There were a few too many interims dispatches that caused trouble, so I removed an unneccesary interims one, that was also only explicitly called in a test but nowhere else used. I documented the remaining ones more carefully and added an entry to the changelog about this |
I've taken a look at
where for the first we have a method that also works if the swarm is a vector of numbers. For the second we do not do this, which leads to an ambiguity. the problem is here, that while Long story short, I can only resolve this, by writing a |
|
I see, that's indeed rather unfixable. I'd suggest adding an error hint like here: |
I am not sure what to do about these, since we usually do not type If both a function am the initial point are optional, how to best distinguish the? For best of cases I would prefer to keep both positional, since that is “nice to use”, but hard to get unambiguous, probably. |
I have no clue how to write such a hint, but something like “doing PSO with a objective and a swarm consisting of numbers is not supported” – one could of course also just start such an algorithm, assuming that “A user providing an objective” knows what they do and it will be the right one already, so one would just generate the “array swarm”. |
Ah, one thing that might help (but maybe that is also a bit silly interface-wise) is to for example make the initial point always a tuple, so one would call
which would remove the ambiguity with the Hessian, though not with the f-vs-objective (or grad-h-vs-objective) one. |
I will write that hint then.
OK, could you mention it in a comment in the test file for Aqua?
I would suggest making Hessian a keyword argument, and keeping the rest positional. 7 different calls signatures in a docstring is a bit much, and it doesn't have the "no Hessian, no p" variant there which should probably also work? |
That we should check carefully and introduce then for all solvers that need a hessian but are fine with an approximation (or maybe even more general: all solvers that require objective-parts that are optional / can be “filled” with a good default). |
Making initial point a tuple looks awful to me, and since it's I think the most important optional parameter of every solver, I would try to avoid making it a keyword argument.
Sure, that sounds like a good idea. |
Ah to be precise But I do agree 7 signatures might be a few too much. |
There is such signature there (the third one): truncated_conjugate_gradient_descent(M, f, grad_f, Hess_f; kwargs...) |
I fully agree that that would be quite ugly, and I feel the idea “ Then we should check for the next breaking release to make things like an optional hessian a keyword argument. Some solvers already have |
I first thought this might just be a reasonable check to add, turns out, it even improves stability / reliability rethinking a few choices that lead to the ambiguities. |
Is it ok if we do the rework of the interface (and their unification) in a new PR? I can also open an issue (and add that to the 1.0 roadmap) that sketches how to unify the high level interfaces and how they accept functions |
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.
Yes, sure, that's fine.
I added tests with
Aqua.jl
.While we have a few ambiguity warnings that I for now ignored, they appear in different variants of the high-level solvers, that usually should not be a problem.
But there is one case of unbounded parameters that I could not resolve. Maybe @mateuszbaran you can take a look? The problem with
Manopt.jl/src/plans/solver_state.jl
Lines 415 to 437 in f546183
is that in case it is a vector of symbols, the two parameters
TTS, TPS
are declared but not use; I tried to localise them to but them into the union (the trick that otherwise helped), but then the code usesTPS
andTTS
and that is not possible if they are local to the union. Is there any other good way to access the parameters you need?I will keep this open for a while and maybe work a bit on the ambiguities, but maybe that would require a breaking change as well. At least for the last step size I will try to resolve that.