Skip to content
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

use isfresh like mechinisim for precs #547

Merged
merged 5 commits into from
Oct 19, 2024

Conversation

oscardssmith
Copy link
Contributor

alternative to #535, fixes #527 for real this time. I don't love this answer, but I think it is the easiest way for now.

@j-fu
Copy link
Contributor

j-fu commented Oct 15, 2024

I think we could keep the reuse_cache keyword, which is the nicer API.
In common.jl L264 we could do

function SciMLBase.solve!(cache::LinearCache, args...; reuse_precs=cache.precsisfresh, kwargs...)
    cache.precsisfresh=reuse_precs
    solve!(cache, cache.alg, args...; kwargs...)
end

@j-fu
Copy link
Contributor

j-fu commented Oct 16, 2024

Or maybe this could go into reinit! ?

function SciMLBase.reinit!(cache::LinearCache;
                           A = nothing,
                           b = cache.b,
                           u = cache.u,
                           p = nothing,
                           reinit_cache = false,
                           reuse_precs = false)
    (; alg, cacheval, abstol, reltol, maxiters, verbose, assumptions, sensealg) = cache


    isfresh = isnothing(A)
    precsisfresh =  ( isfresh || isnothing(p) ) && !reuse_precs

Appears to me a bit more consistent, but not sure.

@oscardssmith
Copy link
Contributor Author

good to merge?

@j-fu
Copy link
Contributor

j-fu commented Oct 18, 2024

oscardssmith#4 adds a test for for working reuse_precs

Add test for "reuse_precs=true" + fix logic
@oscardssmith
Copy link
Contributor Author

thanks!

@j-fu
Copy link
Contributor

j-fu commented Oct 18, 2024

LGTM

@ChrisRackauckas ChrisRackauckas merged commit b7e50f0 into SciML:main Oct 19, 2024
9 of 27 checks passed
@oscardssmith oscardssmith deleted the os/precsisfresh branch October 19, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reinit! calls precs three times
3 participants