-
-
Notifications
You must be signed in to change notification settings - Fork 114
Put utilities for solve in SciMLBase #1110
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
Put utilities for solve in SciMLBase #1110
Conversation
| themselves, for an example of how this can be confusing to a user see | ||
| https://discourse.julialang.org/t/typeerror-in-julia-turing-when-sampling-for-a-forced-differential-equation/82937 | ||
| """ | ||
| @generated function anyeltypedual(x, ::Type{Val{counter}}) where {counter} |
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.
Why is this needed in SciMLBase?
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.
anyeltypedual is used in promote_u0, which is used by get_concrete_problem for NonlinearProblem and also differential equations. So it's needed for both. So this either needs to be in SciMLBase, or it needs to be in both DiffEqBase and NonlinearSolveBase.
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.
why would nonlinearproblem need it? It should use implicit diff, and it requires p as an array for that just like linearproblem?
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.
Well promote_u0 is also used for a few other things, like Tracker, ReverseDiff, Measurements, and Montecarlo measurements. So we still need to use promote_u0 for NonlinearProblems in those cases.
Also,
Current behavior:
using NonlinearSolve
using ForwardDiff
f(u, p) = u .* u .- p
u0 = [1.0, 1.0]
p = ForwardDiff.Dual(2.0, 1.0)
prob = NonlinearProblem(f, u0, p)
sol = solve(prob)in the solve call u0 does get promoted to Dual through promote_u0 and the problem passed to solve_call actually does have a dual u0. Of course it ends up being stripped in the overloads, but I didn't really want to mess with the current behavior.
So we could put anyeltypedual back in to DiffEqBase, but we would also need to put promote_u0 back in that case because it uses anyeltypedual. We would just need each FooBase package to define it's own implementation or variation of promote_u0 in that case.
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
This time for real and without Static