Skip to content

Trivial initialization problem isn't solved when creating ODEProblem #3290

@AayushSabharwal

Description

@AayushSabharwal
@variables Y(t)
@parameters d p = Y [guess = 1.0]
eqs = [D(Y) ~ p - d*Y]
@mtkbuild osys = ODESystem(eqs, t)
u0 = [Y => 1.0]
p = [d => 0.2]
oprob = ODEProblem(osys, u0, (0.0, 1.0), p)

In the REPL:

julia> oprob[osys.Y]
1.0
julia> oprob.ps[osys.p]
0.0

This is because while the initialization is trivial:

julia> oprob.f.initialization_data.initializeprob
NonlinearProblem with uType Nothing. In-place: true
u0: nothing

julia> oprob.f.initialization_data.initializeprob.f.sys |> observed
2-element Vector{Equation}:
 Y(t) ~ 1.0
 p ~ Y(t)

MTK doesn't utilize this the way remake does and solve the problem on the spot. We can fix this by simply calling remake(prob) before returning.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions