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

Cannot remake problems if not providing full u0 and the first version did not require an initialization problem #3295

Open
TorkelE opened this issue Jan 8, 2025 · 1 comment · May be fixed by #3301
Assignees
Labels
bug Something isn't working

Comments

@TorkelE
Copy link
Member

TorkelE commented Jan 8, 2025

Catalyst tests are failing again, seems to be some new MTK issue related to remake:

using ModelingToolkit, OrdinaryDiffEq
using ModelingToolkit: t_nounits as t, D_nounits as D

# Make system.
@variables X(t) Y(t)
@parameters p d
eqs = [
    D(X) ~ p - d*X,
    D(Y) ~ p - d*Y
]
@mtkbuild osys = ODESystem(eqs, t)

# Make problem.
u0_vals = [X => 4, Y => 5.0]
tspan = (0.0, 10.0)
p_vals = [p => 1.0, d => 0.1]
oprob = ODEProblem(osys, u0_vals, tspan, p_vals)

# Attempt to `remake`.
rp = remake(oprob; u0 = [Y => 7]) 

gives

ERROR: Initialization incomplete. Not all of the state variables of the
DAE system can be determined by the initialization. Missing
variables:

Any[X(t)]

Some additional issues related to the latest MTK version have appeared as well, see SciML/Catalyst.jl#1159. But cannot make minimal examples for these until this one is solved.

@TorkelE TorkelE added the bug Something isn't working label Jan 8, 2025
@ChrisRackauckas ChrisRackauckas changed the title Regression: Cannot remake problems if not providing full u0. Cannot remake problems if not providing full u0 and the first version did not require an initialization problem Jan 9, 2025
@ChrisRackauckas
Copy link
Member

Changed the title here since it doesn't seem to be a regression and it seems to be more specific. u0_vals = [X => 4, Y => 5.0] on the ODE, which is a specific case where no initialization system is needed since it's an explicit ODE. Then that means the reinitialization passes does have the prior information stored about u0_vals = [X => 4, Y => 5.0] because that's usually grabbed from the initialization system. The previous variant also didn't store this information, just the values, which made the case somewhat work if you were careful but for example would fail to update on parameter expressions, so the newer variant is still quite a bit more robust than the previous one already just with this caveat edge case.

The proposed fix here is to always build the initialization system so that we have the information in the system, and instead just smartly discard it in the ODEProblem generation if we recognize that (a) we have non-lazily applied the update to u0 (which we do in any case the initialization system is trivial) and (b) it's a pure ODE where the u0 is sufficient information for the initial value designation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants