Skip to content

fix: copy initials to u0 if u0 not provided to remake #3572

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No 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? No Sign in to your account

Merged
merged 10 commits into from
Apr 29, 2025

Conversation

AayushSabharwal
Copy link
Member

Close #3570

@AayushSabharwal AayushSabharwal force-pushed the as/remake-copy-initials branch from 7aa8c0c to 8a19a49 Compare April 21, 2025 07:38
@@ -658,6 +659,18 @@ function SciMLBase.late_binding_update_u0_p(
prob, sys::AbstractSystem, u0, p, t0, newu0, newp)
supports_initialization(sys) || return newu0, newp
u0 === missing && return newu0, (p === missing ? copy(newp) : newp)
# If the user passes `p` to `remake` but not `u0` and `u0` isn't empty,
# and if the system supports initialization (so it has initial parameters),
# and if the initialization solves for `u0`,
Copy link
Member

Choose a reason for hiding this comment

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

you don't know this.

Copy link
Member Author

Choose a reason for hiding this comment

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

We do. Initialization solves for unknowns if initializeprobmap !== nothing

Copy link
Member

Choose a reason for hiding this comment

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

You don't know what the initialization will be until solve is called.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have all the information about the initialization in the ODEProblem?

Copy link
Member

Choose a reason for hiding this comment

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

We don't know which initialization method will be used until later. CheckInit and NoInit don't solve for u0.

@AayushSabharwal AayushSabharwal force-pushed the as/remake-copy-initials branch from ddc22ca to c385c11 Compare April 23, 2025 14:45
@AayushSabharwal
Copy link
Member Author

Waiting for SciML/DiffEqBase.jl#1143

@AayushSabharwal AayushSabharwal force-pushed the as/remake-copy-initials branch from f788eeb to 0aa0d8b Compare April 24, 2025 17:30
getter = if meta isa InitializationMetadata
meta.get_initial_unknowns
else
getu(sys, Initial.(unknowns(sys)))
Copy link
Member

Choose a reason for hiding this comment

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

I assume this will get the guesses too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why would the guesses come into the picture here?

Copy link
Member

Choose a reason for hiding this comment

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

It's the same reason as https://github.com/SciML/SciMLSensitivity.jl/pull/1168/files#diff-76127b1004a68143584d305e1c9ee36126238fd5a05ddeff5985f5b5450ed2c2R92, the u0 vector on DAEs is canonically interpreted as either the initial value or the guess for u0, depending on the choice of initialization and which one exists.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. That's a little more annoying, but not difficult to do. I'll fix it so this propagates guesses.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed now

@AayushSabharwal AayushSabharwal force-pushed the as/remake-copy-initials branch from 0aa0d8b to 1450a5f Compare April 25, 2025 13:50
@AayushSabharwal
Copy link
Member Author

Cancelled CI because I forgot to add a test

@AayushSabharwal AayushSabharwal force-pushed the as/remake-copy-initials branch from a611042 to 997da8d Compare April 28, 2025 06:53
@AayushSabharwal
Copy link
Member Author

SciMLBase/Downstream failure is SciML/SciMLBase.jl#1006. pre seems to be failing because NonlinearSolve doesn't precompile

@ChrisRackauckas ChrisRackauckas merged commit ba0807d into SciML:master Apr 29, 2025
34 of 44 checks passed
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setting Initials is ignorred when using BrownFullBasicInit
2 participants