-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
feat: add fields to OverrideInit
, better nlsolve_alg
handling
#857
base: master
Are you sure you want to change the base?
Conversation
924e92b
to
66f5229
Compare
override_init_get_nlsolve
OverrideInit
, better nlsolve_alg
handling
66f5229
to
9ab1a71
Compare
src/initialization.jl
Outdated
throw(OverrideInitMissingAlgorithm()) | ||
end | ||
|
||
if initdata.update_initializeprob! !== nothing | ||
initdata.update_initializeprob!(initprob, valp) | ||
end | ||
|
||
nlsol = solve(initprob, nlsolve_alg) | ||
nlsol = solve(initprob, nlsolve_alg; abstol = alg.abstol) |
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.
it should default to using the tolerance from the solver if not supplied elsewhere.
@@ -100,7 +100,8 @@ Check if the algebraic constraints are satisfied, and error if they aren't. Retu | |||
the `u0` and `p` as-is, and is always successful if it returns. Valid only for | |||
`ODEProblem` and `DAEProblem`. Requires a `DEIntegrator` as its second argument. | |||
""" | |||
function get_initial_values(prob::ODEProblem, integrator, f, alg::CheckInit, | |||
function get_initial_values( | |||
prob::AbstractDEProblem, integrator::DEIntegrator, f, alg::CheckInit, |
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 doesn't handle DAEProblem?
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.
There's an AbstractDAEProblem
dispatch below
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.
But then this one should just be for ODEProblem?
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.
SDEProblem dispatches here too
@@ -109,7 +110,7 @@ function get_initial_values(prob::ODEProblem, integrator, f, alg::CheckInit, | |||
|
|||
algebraic_vars = [all(iszero, x) for x in eachcol(M)] | |||
algebraic_eqs = [all(iszero, x) for x in eachrow(M)] | |||
(iszero(algebraic_vars) || iszero(algebraic_eqs)) && return | |||
(iszero(algebraic_vars) || iszero(algebraic_eqs)) && return u0, p, true | |||
update_coefficients!(M, u0, p, t) | |||
tmp = _evaluate_f_ode(integrator, f, isinplace, u0, p, t) | |||
tmp .= ArrayInterface.restructure(tmp, algebraic_eqs .* _vec(tmp)) |
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.
integrator.opts.internalnorm
: This doesn't handle Sundials or ODEInterface?
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.
Hmm... I didn't know that. Makes sense that SciMLBase can't make the same assumptions OrdinaryDiffEq did
b5a156a
to
3cf6e49
Compare
src/alg_traits.jl
Outdated
""" | ||
$(TYPEDSIGNATURES) | ||
|
||
Get the `abstol` for the solve stored in the cache. Required for caches of algorithms for | ||
which `cache_stores_tolerances(alg) == true`. | ||
""" | ||
function cache_get_abstol(cache) | ||
error("Cache does not store the `abstol`.") | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
|
||
Get the `reltol` for the solve stored in the cache. Required for caches of algorithms for | ||
which `cache_stores_tolerances(alg) == true`. | ||
""" | ||
function cache_get_reltol(cache) | ||
error("Cache does not store the `reltol`.") |
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 thought we talked about passing it?
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.
Didn't you also mention having a trait and throwing an error message? Right now it takes a keyword argument and falls back to this if not provided.
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.
That said I'm more than happy to remove this trait since solvers have to individually opt-in to doing initialization anyway.
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.
Let's simplify and just make it required.
3cf6e49
to
0f41da2
Compare
0f41da2
to
436f8ab
Compare
A lot of our tests still use codecov, apparently 😅 |
This replaces
default_nlsolve
in OrdinaryDiffEq, and will have methods in NonlinearSolve which can then be leveraged by all libraries for initialization.Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.