I have been trying through the day to get this to work, however I have had problems with non-trivial types. Typically what I want to save are solutions to Ordinary Differential Equations or Stochastic Differential Equations. I run this code
using JLD2
using DifferentialEquations
f(u,p,t) = 1.01*u
u0=1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob,Tsit5(),reltol=1e-8,abstol=1e-8);
@lsave "tmpfile.jld"
and then turns the kernel off (I do everything in Jupyter by the way). So far everything is fine. Now I run:
using JLD2
using DifferentialEquations
using Plots
@load "tmpfile.jld"
This time I get this warning:
WARNING: type #f does not exist in workspace; reconstructing
WARNING: some parameters could not be resolved for type DiffEqBase.ODEProblem{Float64,Float64,false,Void,#f,Void,Void,UniformScaling{Int64},DiffEqBase.StandardODEProblem}; reconstructing
WARNING: some parameters could not be resolved for type OrdinaryDiffEq.InterpolationData{#f,Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}; reconstructing
which seems ominous. Finally I try
plot(sol)
and gets this plain error
type ##DiffEqBase.ODEProblem{Float64,Float64,false,Void,#f,Void,Void,UniformScaling{Int64},DiffEqBase.StandardODEProblem}#666 has no field p
Stacktrace:
[1] macro expansion at /home/Torkel.Loman/.julia/v0.6/DiffEqBase/src/solutions/solution_interface.jl:99 [inlined]
[2] apply_recipe(::Dict{Symbol,Any}, ::DiffEqBase.ODESolution{Float64,1,Array{Float64,1},Void,Void,Array{Float64,1},Array{Array{Float64,1},1},JLD2.ReconstructedTypes.##DiffEqBase.ODEProblem{Float64,Float64,false,Void,#f,Void,Void,UniformScaling{Int64},DiffEqBase.StandardODEProblem}#666,OrdinaryDiffEq.Tsit5,JLD2.ReconstructedTypes.##OrdinaryDiffEq.InterpolationData{#f,Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}#667}) at /home/Torkel.Loman/.julia/v0.6/RecipesBase/src/RecipesBase.jl:291
[3] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{DiffEqBase.ODESolution{Float64,1,Array{Float64,1},Void,Void,Array{Float64,1},Array{Array{Float64,1},1},JLD2.ReconstructedTypes.##DiffEqBase.ODEProblem{Float64,Float64,false,Void,#f,Void,Void,UniformScaling{Int64},DiffEqBase.StandardODEProblem}#666,OrdinaryDiffEq.Tsit5,JLD2.ReconstructedTypes.##OrdinaryDiffEq.InterpolationData{#f,Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}#667}}) at /home/Torkel.Loman/.julia/v0.6/Plots/src/pipeline.jl:81
[4] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{DiffEqBase.ODESolution{Float64,1,Array{Float64,1},Void,Void,Array{Float64,1},Array{Array{Float64,1},1},JLD2.ReconstructedTypes.##DiffEqBase.ODEProblem{Float64,Float64,false,Void,#f,Void,Void,UniformScaling{Int64},DiffEqBase.StandardODEProblem}#666,OrdinaryDiffEq.Tsit5,JLD2.ReconstructedTypes.##OrdinaryDiffEq.InterpolationData{#f,Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}#667}}) at /home/Torkel.Loman/.julia/v0.6/Plots/src/plot.jl:179
[5] plot(::DiffEqBase.ODESolution{Float64,1,Array{Float64,1},Void,Void,Array{Float64,1},Array{Array{Float64,1},1},JLD2.ReconstructedTypes.##DiffEqBase.ODEProblem{Float64,Float64,false,Void,#f,Void,Void,UniformScaling{Int64},DiffEqBase.StandardODEProblem}#666,OrdinaryDiffEq.Tsit5,JLD2.ReconstructedTypes.##OrdinaryDiffEq.InterpolationData{#f,Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}#667}) at /home/Torkel.Loman/.julia/v0.6/Plots/src/plot.jl:52
Further more, I repeat my test but using another special type, the reaction networks produced by the DiffEqBiological package. I use this code
using JLD2
using DifferentialEquations
rn_model = @reaction_network rnType begin
1.0, X --> 0
end
@save "tmpfile.jld"
and get this response:
WARNING: skipping rn_model because it contains a pointer
How limited is JLD2 in what parts of the works pace I can actually successfully save? I succeed with the simpler types, but there should be some way to store also this kinds of stuff. Or is there nothing and I am running into a dead end?