Skip to content

use isfresh like mechinisim for precs#547

Merged
ChrisRackauckas merged 5 commits intoSciML:mainfrom
oscardssmith:os/precsisfresh
Oct 19, 2024
Merged

use isfresh like mechinisim for precs#547
ChrisRackauckas merged 5 commits intoSciML:mainfrom
oscardssmith:os/precsisfresh

Conversation

@oscardssmith
Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

good to merge?

@j-fu
Copy link
Copy Markdown
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
Copy Markdown
Member Author

thanks!

@j-fu
Copy link
Copy Markdown
Contributor

j-fu commented Oct 18, 2024

LGTM

@ChrisRackauckas ChrisRackauckas merged commit b7e50f0 into SciML:main Oct 19, 2024
@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