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

Warning: some parameters could not be resolved for type ... #314

Closed
JinraeKim opened this issue May 10, 2021 · 3 comments
Closed

Warning: some parameters could not be resolved for type ... #314

JinraeKim opened this issue May 10, 2021 · 3 comments

Comments

@JinraeKim
Copy link

I'm developing
and encountered a weird warning message.
I wonder if

  1. it has a potential error that might cause data loss.
  2. there is a way of resolving this warning.

Reproducing this error

Sorry for no MWE. It can be reproduced by running test/sim_and_save.jl and, at a new session, test/load_and_plot.jl in this commit.

brief code

  • test/sim_and_save.jl
using FlightSims
using Plots
# using Pipe: @pipe
using JLD2, FileIO


function main()
    dir_log = "data/sim_and_save"
    mkpath(dir_log)
    env = TwoDimensionalNonlinearPolynomialEnv()
    x0 = State(env)()
    # simulation and data processing
    prob, sol = sim(env, x0, apply_inputs(dynamics!(env); u=FlightSims.optimal_input(env)); tf=10.0)
    df = process(env)(prob, sol)
    # df = @pipe sim(env; tf=10.0) |> process(env)(_...)  # shorthand
    # save (for stable data saving, one may save raw data). Here, raw data means e.g. t = 0, 0.01, 0.02, ...
    FlightSims.save(joinpath(dir_log, "test.jld2"), env, prob, sol)
    # to load it, see `main/example_load.jl`
end
  • test/load_and_plot.jl
using JLD2
using FlightSims, OrdinaryDiffEq, ComponentArrays  # for data re-construction
using UnPack

using Plots


function _load()
    # run it in a new session. Be careful for loading packages for re-construction.
    saved_data = load("test.jld2")
    # @unpack env, prob, sol = saved_data
    # df = process(env)(prob, sol)
    # plot(df.times, hcat(df.states...)')
    nothing
end

Warning message

julia> _load()
┌ Warning: some parameters could not be resolved for type ODEFunction{true,FlightSims.#5#6{TwoDimensionalNonlinearPolynomialEnv},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,typeof(SciMLBase.DEFAULT_OBSERVED),Nothing}; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/fAkkN/src/data/reconstructing_datatypes.jl:440
@JonasIsensee
Copy link
Collaborator

Hi @JinraeKim ,

if I understand correctly, you are trying to store and load structures from OrdinaryDiffEq which is problematic.

JLD2 (currently) does not support serializing (anonymous) functions because this is generally a difficult thing to do.
I've tried working on that but have so far failed. I have asked for help but with little success
See e.g. https://discourse.julialang.org/t/serializing-functions-methods-closures/57061

If you really want to store the full function / problem / solution structures, you could consider using the stdlib
Serialization. Note that the resulting files are generally not portable, though.

Alternatively, you could consider extracting the relevant information from these structures and store those using JLD2.

@JinraeKim
Copy link
Author

@JonasIsensee
Thank you for your explanation. Yes, you understood correctly.
How's the outlook of JLD2? Would it support serialising anonymous functions in the near future?

@JonasIsensee
Copy link
Collaborator

Hey @JinraeKim ,
I spent my weekend working on this and seem to have finally made progress.
Have a look at #316

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

No branches or pull requests

2 participants