DataDrivenDiffEq.jl: LoadError upon creating DataDrivenProblem from solution object

I just started to make my first steps with DataDrivenDiffEq.jl and was able to reproduce the introductory example from the docs without any problems.

However, I stumbled upon two very similar errors when I try to adapt the sample code to my own ODE problem:

using DataDrivenDiffEq
using ModelingToolkit
using OrdinaryDiffEq
using DataDrivenSparse
using LinearAlgebra


function ode_model(du, u, p, t)
    α, β, γ = p
    a, b, c, d = u

    du[1] = -α * a
    du[2] = α * a - β * b
    du[3] = β * b - γ * c
    du[4] = γ * c

    return nothing
end


u0 = [20.0, 0.0, 0.0, 0.0]
p = [1, 1, 1, 1]
tspan = (0.0, 10.0)

prob = ODEProblem(ode_model, u0, tspan)
sol = solve(prob, Tsit5(), p=p, saveat=0.1)

ddprob = DataDrivenProblem(sol)             # --> LoadError: No matching function wrapper was found!
ddprob = DataDrivenProblem(sol.u, sol.t)    # --> LoadError: MethodError: no method matching DataDrivenProblem(::Vector{Vector{Float64}}, ::Vector{Float64})

While the ODE problem in introductory example code is defined using the “return du” approach, I am using the “in-place method” (see DiffEq docs for details). Although I am not sure how this might result in a differently specified ODEProblem or a solution object, I would assume (but did not check) that such differences are abstracted by the according APIs.

Furthermore, the DataDrivenDiffEq docs state:

You can also directly use a DESolution as an input to your DataDrivenProblem

However, neither passing the sol object, nor sol.u and sol.t to DataDrivenProblem() allowed me to instantiate the respective object and two different LoadErrors were raised.

Passing sol raised (can provide full stacktrace if needed):

ERROR: LoadError: No matching function wrapper was found!

Passing sol.t and sol.u raised:

ERROR: LoadError: MethodError: no method matching DataDrivenProblem(::Vector{Vector{Float64}}, ::Vector{Float64})

Closest candidates are:

DataDrivenProblem(::Any, ::Any, ::Any, ::Any, ::Any, ::F, ::Any; kwargs…) where F<:Function at ~/.julia/packages/DataDrivenDiffEq/donlY/src/problem/type.jl:140

DataDrivenProblem(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any; name, kwargs…) at ~/.julia/packages/DataDrivenDiffEq/donlY/src/problem/type.jl:115

Am am working with Julia 1.8.5 and the following package versions:

DataDrivenDiffEq v1.2.0
DataDrivenSparse v0.1.2
ModelingToolkit v8.57.0
OrdinaryDiffEq v6.51.2
LinearAlgebra

What am I missing here? How can I fix the LoadErrors I am facing?

Try it with prob = ODEProblem{true, SciMLBase.FullSpecialize}(ode_model, u0, tspan)

1 Like