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

fix: remake initialization problem during DAE initialization #2209

Closed

Conversation

AayushSabharwal
Copy link
Member

@AayushSabharwal AayushSabharwal commented May 22, 2024

Close SciML/ModelingToolkit.jl#2717

Requires

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.

Comment on lines +137 to +145
if initializeprob.f.sys !== nothing && prob.f.sys !== nothing
initu0vars = variable_symbols(initializeprob)
initu0order = variable_index.((initializeprob,), initu0vars)
# Variable symbols are not guaranteed to be in order
invpermute!(initu0vars, initu0order)
initu0 = getu(prob.f.initializeprob, initu0vars)(prob)
initp = remake_buffer(initializeprob, parameter_values(initializeprob),
Dict(sym => getu(prob, sym)(prob) for sym in parameter_symbols(initializeprob)))
initializeprob = remake(initializeprob; u0 = initu0, p = initp)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this all makes sense. First of all, it shouldn't come from prob since you can have callback reinitialization, so it should come from integrator.u. But also, this is just very heavy and dynamic: can't we just add a initializeprobsetu in the ODEFunction which sets up the initalizeprob based on integrator.u, and then also have one for p that updates based on any p updates (and also this should update t, which is a psuedo-parameter of the initialization)

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense. Since this involves SciMLBase changes (changing ODEFunction and DAEFunction fields) I'll merge this PR with #2228 since that depends on this PR and modifies those structs anyway.

@AayushSabharwal
Copy link
Member Author

Superseded by #2228

@AayushSabharwal AayushSabharwal deleted the as/initprob-params branch May 28, 2024 13:41
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.

Updated ODEProblem parameters don't propagate to initializeprob
2 participants