-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
remake
ignores u0
updates when the initialization is trivial
#3318
Comments
I have an even simpler MWE: ps = @parameters k = missing [guess = 2]
sts = @variables x(t) = 1.5
eqs = [
D(x) ~ -k * x
]
model = structural_simplify(ODESystem(eqs, t, sts, ps; name=:model, initialization_eqs=[k ~ 2]))
prob0 = ODEProblem(model, [], (0., 1))
setk = setsym_oop(prob0, [x])
(u0, p) = setk(prob0, [1.])
prob1 = remake(prob0; u0, p)
integ = init(prob1, DefaultODEAlgorithm())
integ.u == [1] The fact that we had duals was not relevant, simply any update to |
remake
with dual numbers resets values to floats when the initialization is trivialremake
ignores u0
updates when the initialization is trivial
In terms of the simple MWE, this is because @parameters x0
model = structural_simplify(ODESystem(eqs, t, sts, [ps..., x0]; name=:model, defaults = [x => x0], initialization_eqs=[k ~ 2]))
prob0 = ODEProblem(model, [], (0., 1), [x0 => 1.5])
setk = setsym_oop(prob0, [x0]) # note: x0 not x
(u0, p) = setk(prob0, [1.])
prob1 = remake(prob0; u0, p)
integ = init(prob1, DefaultODEAlgorithm())
integ.u[1] == 1 |
Describe the bug 🐞
Edit: The issue is more general that I initially described, the fact that we have dual numbers is not relevant, see the next post for a simpler MWE.
Passing
Vector{ForwardDiff.Dual}
toremake
leads to an internal type promotion byupdated_u0_p
, but by the end of the function the values are back to floats. Furthermore, if this is anODEProblem
,init
also also promotes theu0
internally, but it then usesremake
to update the values in the problem and the duals are dropped again, leading to method errors in the problem function.Expected behavior
remake
should not drop the duals.Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
I can reproduce this with
SCCNonlinearProblem
too, but it needs SciML/SciMLBase.jl#904The text was updated successfully, but these errors were encountered: