# DataDrivenDiffEq.jl: LoadError upon creating DataDrivenProblem from solution object

**URL:** <https://discourse.julialang.org/t/datadrivendiffeq-jl-loaderror-upon-creating-datadrivenproblem-from-solution-object/101065>\
**Category:** General Usage\
**Tags:** diffeq, error\
**Created:** [July 1, 2023, 9:20pm UTC](https://discourse.julialang.org/t/datadrivendiffeq-jl-loaderror-upon-creating-datadrivenproblem-from-solution-object/101065 "2023-07-01T21:20:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlbertEmil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albertemil/32/51178_2.png) [@AlbertEmil](https://discourse.julialang.org/u/AlbertEmil)\
**Post date:** [July 1, 2023, 9:20pm UTC](https://discourse.julialang.org/t/datadrivendiffeq-jl-loaderror-upon-creating-datadrivenproblem-from-solution-object/101065/1 "2023-07-01T21:20:10Z")

</div>

I just started to make my first steps with [DataDrivenDiffEq.jl](https://docs.sciml.ai/DataDrivenDiffEq/stable/#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:

```julia
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](https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#SciMLBase.ODEProblem) 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 `LoadError`s 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 `LoadError`s I am facing?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 2, 2023, 7:29am UTC](https://discourse.julialang.org/t/datadrivendiffeq-jl-loaderror-upon-creating-datadrivenproblem-from-solution-object/101065/2 "2023-07-02T07:29:14Z")

</div>

> [@AlbertEmil](#):
>
> `prob = ODEProblem(ode_model, u0, tspan)`

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