Implicit Nonlinear Dynamics example in DataDrivenDiffEq doesn't work

Hi, I have a DAE system which when structurally simplified gives an ODE system with 7 Differential Equations and 21 parameters. I would like to recover this system from the simulated data. I tried DataDrivenDiffEq for the same but ended up with some error.

I followed the example of Implicit Nonlinear Dynamics: Autoregulation, which doesn’t work for me. Of course it recovers the equations as in the documentation but I couldn’t verify it by transforming the obtained equations and parameter estimates into an ODEsystem and try to simulate that.

I have been using the following package versions.

Status C:\Users\Jisna\DataDriven\DataDriven\Project.toml
[2445eb08] DataDrivenDiffEq v0.8.5
[0c46a032] DifferentialEquations v7.5.0
[a98d9a8b] Interpolations v0.14.6
[961ee093] ModelingToolkit v8.27.0
[91a5bcdd] Plots v1.35.3

and Julia 1.7.1

Here is the example code in documentation I tried, with the error I got.

using DataDrivenDiffEq
using ModelingToolkit
using OrdinaryDiffEq
using LinearAlgebra
using Plots

@parameters begin
    t
    α = 1.0
    β = 1.3
    γ = 2.0
    δ = 0.5
end

@variables begin
    x[1:2](t) = [20.0; 12.0]
end

x = collect(x)
D = Differential(t)

eqs = [
    D(x[1]) ~ α/(1+x[2])-β*x[1];
    D(x[2]) ~ γ/(1+x[1])-δ*x[2];
]

sys = ODESystem(eqs, t, x, [α, β, γ, δ], name = :Autoregulation)

x0 = [x[1] => 20.0; x[2] => 12.0]

tspan = (0.0, 5.0)

de_problem = ODEProblem(sys, x0, tspan)
de_solution = solve(de_problem, Tsit5(), saveat = 0.005)

dd_prob = ContinuousDataDrivenProblem(de_solution)

eqs = [
    polynomial_basis(x, 4); D.(x); x .* D(x[1]); x .* D(x[2])
    ]

basis = Basis(eqs, x, independent_variable = t, implicits = D.(x))

sampler = DataSampler(
    Split(ratio = 0.8), Batcher(n = 10, shuffle = true, repeated = true, batchsize_min = 30)
)

res = solve(dd_prob, basis, ImplicitOptimizer(STLSQ(1e-1:1e-1:9e-1)), by = :min, sampler = sampler, digits = 1)

system = result(res)
@named ode = ODESystem(equations(system), t, x, parameters(system))
ArgumentError: p₁ is not a parameter.

Stacktrace:
 [1] check_parameters(ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}, iv::Sym{Real, Base.ImmutableDict{DataType, Any}})
   @ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\utils.jl:135
 [2] ODESystem(tag::UInt64, deqs::Vector{Equation}, iv::Sym{Real, Base.ImmutableDict{DataType, Any}}, dvs::Vector{Term{Real, Base.ImmutableDict{DataType, Any}}}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}, var_to_name::Dict{Any, Any}, ctrls::Vector{Any}, observed::Vector{Equation}, tgrad::Base.RefValue{Vector{Num}}, jac::Base.RefValue{Any}, ctrl_jac::Base.RefValue{Any}, Wfact::Base.RefValue{Matrix{Num}}, Wfact_t::Base.RefValue{Matrix{Num}}, name::Symbol, systems::Vector{ODESystem}, defaults::Dict{Any, Any}, torn_matching::Nothing, connector_type::Nothing, preface::Nothing, cevents::Vector{ModelingToolkit.SymbolicContinuousCallback}, devents::Vector{ModelingToolkit.SymbolicDiscreteCallback}, metadata::Nothing, tearing_state::Nothing, substitutions::Nothing, complete::Bool; checks::Bool)
   @ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\diffeqs\odesystem.jl:136
 [3] ODESystem(deqs::Vector{Equation}, iv::Num, dvs::Vector{Num}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}; controls::Vector{Num}, observed::Vector{Equation}, systems::Vector{ODESystem}, name::Symbol, default_u0::Dict{Any, Any}, default_p::Dict{Any, Any}, defaults::Dict{Any, Any}, connector_type::Nothing, preface::Nothing, continuous_events::Nothing, discrete_events::Nothing, checks::Bool, metadata::Nothing)
   @ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\diffeqs\odesystem.jl:197
 [4] top-level scope
   @ C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\abstractsystem.jl:866
 [5] eval
   @ .\boot.jl:373 [inlined]
 [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base .\loading.jl:1196

Can I get some help on the same, so that I can proceed with my model in a similar manner ?

Open an issue on the repo. Julius could probably take a look after he’s done traveling, but he won’t find it here.

Ok… will open as issue then.