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

feat: add implementations of CheckInit and OverrideInit #845

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

AayushSabharwal
Copy link
Member

@TorkelE @isaacsas this should make it so that your rebuild function is something along the lines of:

function rebuild(prob; u0, p)
   newprob = remake(prob; u0, p)
   u0, p, success = SciMLBase.get_initial_values(newprob, newprob, newprob.f, OverrideInit(), Val(SciMLBase.isinplace(newprob.f); nlsolve_alg = ...)
   @assert success
   newprob = remake(newprob; u0, p)
   return newprob
end

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@AayushSabharwal AayushSabharwal force-pushed the as/move-initalgs branch 2 times, most recently from 3e213af to e79b906 Compare November 4, 2024 14:58
@isaacsas
Copy link
Member

isaacsas commented Nov 4, 2024

OK, awesome! Thanks for sticking with this.

If you feel this is at a point where it would be helpful to test against Catalyst let me know. We have master capped right now to SciMLBase 2.57.1 as that was the last time tests passed (and we wanted to be able to work / merge other PRs).

Project.toml Outdated Show resolved Hide resolved
Comment on lines +110 to +111
algebraic_vars = [all(iszero, x) for x in eachcol(M)]
algebraic_eqs = [all(iszero, x) for x in eachrow(M)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use a cached one from the integrator?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cached what, exactly? 😅 I copied almost all of this from the existing implementation

(iszero(algebraic_vars) || iszero(algebraic_eqs)) && return
update_coefficients!(M, u0, p, t)
tmp = _evaluate_f_ode(integrator, f, isinplace, u0, p, t)
tmp .= ArrayInterface.restructure(tmp, algebraic_eqs .* _vec(tmp))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allocates

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow changing this to tmp = algebraic_eqs .* _vec(tmp) allocates more

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least, according to @allocated/@allocations

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.

3 participants