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

Serialization of ODEProblemExpr based models broke in 5.7 #841

Closed
andreasnoack opened this issue Mar 1, 2021 · 1 comment · Fixed by #857
Closed

Serialization of ODEProblemExpr based models broke in 5.7 #841

andreasnoack opened this issue Mar 1, 2021 · 1 comment · Fixed by #857

Comments

@andreasnoack
Copy link
Contributor

The code below works in version 5.6 but not in 5.7 (and more recent versions).

using ModelingToolkit, SciMLBase, Serialization

@parameters t
@variables x(t)
D = Differential(t)

sys = ODESystem([D(x) ~ -0.5*x])
prob = eval(ModelingToolkit.ODEProblemExpr{false}(sys, nothing, nothing, SciMLBase.NullParameters()))

_fn = tempname()

open(_fn, "w") do f
    serialize(f, prob)
end

_cmd = "using ModelingToolkit, Serialization; deserialize(\"$_fn\")"

run(`$(Base.julia_cmd()) -e $(_cmd)`)

The failure is

ERROR: UndefVarError: ###f#261 not defined
Stacktrace:
  [1] deserialize_datatype(s::Serializer{IOStream}, full::Bool)
    @ Serialization ~/julia/usr/share/julia/stdlib/v1.6/Serialization/src/Serialization.jl:1278
...

which is the type of the ODE closure

julia> typeof(prob.f.f)
var"###f#261"

Notice that if I construct the problem via the ODEProblem constructor then I don't get the error and the closure type is different

julia> typeof(prob.f.f)
ModelingToolkit.var"#f#251"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##arg#273"), Symbol("##arg#274"), :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xcfab6c31, 0x4234d024, 0xc8d24f26, 0x00e8741b, 0xdef727f3)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#275"), Symbol("##arg#273"), Symbol("##arg#274"), :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x1649a627, 0x3083de65, 0x3aff2680, 0x103a1319, 0xebfbfbe8)}}
@ChrisRackauckas
Copy link
Member

This looks like it's likely an upstream issue with build_function due to #764 (upstream as this is now in Symbolics.jl)

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 a pull request may close this issue.

2 participants