From ceb02515cf8afb06375da86fbe511ea7b41031c0 Mon Sep 17 00:00:00 2001 From: CompatHelper Julia Date: Thu, 29 May 2025 12:04:51 +0000 Subject: [PATCH 1/4] CompatHelper: bump compat for ModelingToolkit to 10 --- Project.toml | 4 ++-- docs/Project.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 52eaa80ea..3867d2dec 100644 --- a/Project.toml +++ b/Project.toml @@ -30,13 +30,13 @@ DataInterpolations = "4, 5, 6, 7, 8" DiffEqBase = "6" DocStringExtensions = "0.7, 0.8, 0.9" MLUtils = "0.3, 0.4" -ModelingToolkit = "9" +ModelingToolkit = "10" +OrdinaryDiffEqTsit5 = "1" Parameters = "0.12" ProgressMeter = "1.6" QuadGK = "2.4" RecipesBase = "1" Reexport = "1.0" -OrdinaryDiffEqTsit5 = "1" SciMLStructures = "1" Setfield = "1" Statistics = "1" diff --git a/docs/Project.toml b/docs/Project.toml index e37b5ae91..a9d8b18d6 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -13,7 +13,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" DataDrivenDiffEq = "1" Documenter = "1" Literate = "2.14" -ModelingToolkit = "9" +ModelingToolkit = "10" OrdinaryDiffEq = "6" Plots = "1" StableRNGs = "1" From c6359a212c56d7e21b2f2249bb1a4dbb7fd5bba6 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Thu, 29 May 2025 19:14:56 +0530 Subject: [PATCH 2/4] refactor: update to ModelingToolkit@10 --- docs/src/libs/datadrivensparse/example_04.jl | 4 ++-- src/DataDrivenDiffEq.jl | 4 ++-- test/problem/problem.jl | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/src/libs/datadrivensparse/example_04.jl b/docs/src/libs/datadrivensparse/example_04.jl index 48dcbe887..c4567943d 100644 --- a/docs/src/libs/datadrivensparse/example_04.jl +++ b/docs/src/libs/datadrivensparse/example_04.jl @@ -29,9 +29,9 @@ using Test #src end end -@mtkbuild sys = Autoregulation() +@mtkcompile sys = Autoregulation() tspan = (0.0, 5.0) -de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan, []) +de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan) de_solution = solve(de_problem, Tsit5(), saveat = 0.005); #md plot(de_solution) diff --git a/src/DataDrivenDiffEq.jl b/src/DataDrivenDiffEq.jl index 8e353f629..084f9dfeb 100644 --- a/src/DataDrivenDiffEq.jl +++ b/src/DataDrivenDiffEq.jl @@ -13,7 +13,7 @@ using Parameters using Setfield @reexport using ModelingToolkit -using ModelingToolkit: AbstractSystem, AbstractTimeDependentSystem +using ModelingToolkit: AbstractSystem using SciMLStructures: SciMLStructures as SS using SymbolicUtils: operation, arguments, iscall, issym using Symbolics @@ -67,7 +67,7 @@ const __EMPTY_VECTOR = Vector(undef, 0) # Basis with an indicator for implicit use abstract type AbstractDataDrivenFunction{Bool, Bool} end -abstract type AbstractBasis <: AbstractTimeDependentSystem end +abstract type AbstractBasis <: AbstractSystem end # Collect the DataInterpolations Methods into an Interpolation Type abstract type AbstractInterpolationMethod end diff --git a/test/problem/problem.jl b/test/problem/problem.jl index 2611ce796..687e7055b 100644 --- a/test/problem/problem.jl +++ b/test/problem/problem.jl @@ -183,9 +183,9 @@ end end end - @mtkbuild sys = Autoregulation() + @mtkcompile sys = Autoregulation() tspan = (0.0, 5.0) - de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan, []) + de_problem = ODEProblem{true, SciMLBase.NoSpecialize}(sys, [], tspan) de_solution = solve(de_problem, Tsit5(), saveat = 0.005) prob = DataDrivenProblem(de_solution) @test is_valid(prob) From e6451d8c52226b20f28f19db0c00f1e88c94c647 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Mon, 2 Jun 2025 13:54:59 +0530 Subject: [PATCH 3/4] fix: manually implement `controls` for `AbstractBasis` --- src/DataDrivenDiffEq.jl | 4 ++-- src/basis/type.jl | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/DataDrivenDiffEq.jl b/src/DataDrivenDiffEq.jl index 084f9dfeb..ff7e02f09 100644 --- a/src/DataDrivenDiffEq.jl +++ b/src/DataDrivenDiffEq.jl @@ -19,7 +19,7 @@ using SymbolicUtils: operation, arguments, iscall, issym using Symbolics using Symbolics: scalarize, variable, value @reexport using ModelingToolkit: unknowns, parameters, independent_variable, observed, - controls, get_iv, get_observed + get_iv, get_observed using Random using QuadGK @@ -98,7 +98,7 @@ include("./basis/utils.jl") include("./basis/type.jl") export Basis export jacobian, dynamics -export implicit_variables, states +export implicit_variables, states, controls export get_parameter_values, get_parameter_map include("./utils/basis_generators.jl") diff --git a/src/basis/type.jl b/src/basis/type.jl index 7dabbee9b..267805725 100644 --- a/src/basis/type.jl +++ b/src/basis/type.jl @@ -263,6 +263,18 @@ function states(b::AbstractBasis) return getfield(b, :unknowns) end +function controls(b::AbstractBasis) + ctrls = getfield(b, :ctrls) + systems = getfield(b, :systems) + isempty(systems) && return ctrls + + ctrls = copy(ctrls) + for sys in systems + append!(ctrls, unknowns(sys, controls(sys))) + end + return ctrls +end + # For internal use is_implicit(b::Basis{X, <:Any}) where {X} = X is_controlled(b::Basis{<:Any, X}) where {X} = X From e3dc15e7598efbd8e55e11947c5a9ed4916c3bf5 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 2 Jun 2025 09:01:44 +0000 Subject: [PATCH 4/4] Update type.jl --- src/problem/type.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/problem/type.jl b/src/problem/type.jl index 39244e474..2910fd862 100644 --- a/src/problem/type.jl +++ b/src/problem/type.jl @@ -326,7 +326,7 @@ function ModelingToolkit.observed(p::AbstractDataDrivenProblem, i = :, j = :) isempty(x) ? x : getindex(x, i, j) end -function ModelingToolkit.controls(p::AbstractDataDrivenProblem, i = :, j = :) +function controls(p::AbstractDataDrivenProblem, i = :, j = :) x = getfield(p, :U) isempty(x) ? x : getindex(x, i, j) end